diff --git a/conf/user.ini.example b/conf/user.ini.example index 2504a6e..61262d5 100644 --- a/conf/user.ini.example +++ b/conf/user.ini.example @@ -209,6 +209,10 @@ url = "" token = target_qq = +; 飞书机器人|依赖USE_NOTIFY +[notify.feishu] +token = + ; Debug|个人调试推送|url|token [notify.debug] url = "" diff --git a/src/core/Env.php b/src/core/Env.php index e6bf433..27d35c8 100644 --- a/src/core/Env.php +++ b/src/core/Env.php @@ -28,7 +28,7 @@ class Env public function __construct() { set_time_limit(0); - header("Content-Type:text/html; charset=utf-8"); + // header("Content-Type:text/html; charset=utf-8"); // ini_set('date.timezone', 'Asia/Shanghai'); date_default_timezone_set('Asia/Shanghai'); ini_set('display_errors', 'on'); diff --git a/src/plugin/Notice.php b/src/plugin/Notice.php index de85122..f3d2cc4 100644 --- a/src/plugin/Notice.php +++ b/src/plugin/Notice.php @@ -171,6 +171,9 @@ class Notice if (getConf('corp_id', 'notify.we_com_app') && getConf('corp_secret', 'notify.we_com_app') && getConf('agent_id', 'notify.we_com_app')) { self::weComApp($info); } + if (getConf('token', 'notify.feishu')) { + self::feiShuSend($info); + } } /** @@ -419,4 +422,32 @@ class Notice } } + + /** + * @use 飞书推送 + * @doc https://developers.dingtalk.com/document/robots/custom-robot-access + * @param array $info + */ + private static function feiShuSend(array $info) + { + Log::info('使用飞书webhook机器人推送消息'); + $url = 'https://open.feishu.cn/open-apis/bot/v2/hook/' . getConf('token', 'notify.feishu'); + $payload = [ + 'msg_type' => 'text', + 'content' => [ + 'text' => $info['title'] . $info['content'], + ] + ]; + $headers = [ + 'Content-Type' => 'application/json;charset=utf-8' + ]; + $raw = Curl::put('other', $url, $payload, $headers); + $de_raw = json_decode($raw, true); + if ($de_raw['StatusCode'] == 0) { + Log::notice("推送消息成功: {$de_raw['StatusCode']}"); + } else { + Log::warning("推送消息失败: $raw"); + } + } + } \ No newline at end of file