Merge pull request #154 from Dishesdog/master

添加飞书推送
This commit is contained in:
lkeme 2022-01-28 12:52:05 +08:00 committed by GitHub
commit 01a94ba729
2 changed files with 35 additions and 0 deletions

View File

@ -209,6 +209,10 @@ url = ""
token =
target_qq =
; 飞书机器人|依赖USE_NOTIFY
[notify.feishu]
token =
; Debug|个人调试推送|url|token
[notify.debug]
url = ""

View File

@ -167,6 +167,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);
}
}
/**
@ -415,4 +418,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");
}
}
}