From 69c297ecaaef37b565e98eb5f422e9d663b965f6 Mon Sep 17 00:00:00 2001 From: andywang425 <13120989656@163.com> Date: Sat, 2 Sep 2023 17:54:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0Gotify=E6=8E=A8?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env.example.js | 12 ++++++---- lib/helper/notify.js | 55 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/env.example.js b/env.example.js index b3c06ec..967ca7a 100644 --- a/env.example.js +++ b/env.example.js @@ -12,12 +12,12 @@ module.exports = Object.freeze({ * ## 调试相关 * - `LOTTERY_LOG_LEVEL` 输出日志等级 Error { + if (GOTIFY_APPKEY) { + send({ + method: 'POST', + url: GOTIFY_URL, + contents: { + title: test, + message: desp, + }, + config: { + retry: false + }, + headers: { + accept: 'application/json, text/plain, */*', + 'content-type': 'application/json', + 'authorization': 'Bearer ' + GOTIFY_APPKEY + }, + success: () => { + // HTTP 响应码 200 就说明成功了 + log.info('发送通知', 'Gotify 发送通知消息成功') + resolve(); + }, + failure: err => { + log.error('发送通知', 'Gotify 发送通知调用API失败!!' + err) + resolve(); + } + }) + } else { + log.debug('发送通知', '您未提供Gotify推送所需的GOTIFY_APPKEY,取消Gotify推送消息通知'); + resolve() + } + }) +} + async function qmsg(text, desp) { return new Promise(resolve => { if (QMSG_KEY) { @@ -889,4 +940,4 @@ async function email(text, desp) { } } -module.exports = { sendNotify } \ No newline at end of file +module.exports = { sendNotify }