From 00eb147dfcb0ec06cfcf9dd1b11e50c18b068e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E5=A5=88=E5=8D=83=E7=A5=81?= Date: Fri, 29 Dec 2023 10:28:25 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E9=A3=9E=E4=B9=A6?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BAWebhook=E6=8E=89=E7=BA=BF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 千奈千祁 --- config/default_config/notice.yaml | 5 ++++- lib/events/offline.js | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/config/default_config/notice.yaml b/config/default_config/notice.yaml index 0db3a25..b136606 100644 --- a/config/default_config/notice.yaml +++ b/config/default_config/notice.yaml @@ -2,4 +2,7 @@ iyuu: # Server酱(https://sct.ftqq.com/) -sct: \ No newline at end of file +sct: + +# 飞书自定义机器人Webhook (https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot) +feishu_webhook: \ No newline at end of file diff --git a/lib/events/offline.js b/lib/events/offline.js index 6c0a57f..c067c12 100644 --- a/lib/events/offline.js +++ b/lib/events/offline.js @@ -21,5 +21,30 @@ export default class offlineEvent extends EventListener { if (config.sct) { await fetch(`https://sctapi.ftqq.com/${config.sct}.send?title=${title}&content=${e.message}`) } + if (config.feishu_webhook){ + let offline_content = { + msg_type: 'post', + content: { + post: { + 'zh-cn': { + title: title, + content: [ + [{ + tag: "text", + text: e.message + }] + ] + } + } + } + }; + fetch(config.feishu_webhook, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(offline_content) + }) + } } }