From 3ad5bb1cf206bdc47dd1855c1d8e0a212fb08810 Mon Sep 17 00:00:00 2001 From: smallfawn <101914820+smallfawn@users.noreply.github.com> Date: Wed, 26 Jul 2023 12:30:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=90=84=E7=A7=8D=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sendNotify.js | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/sendNotify.js b/sendNotify.js index f71c15c..9868454 100644 --- a/sendNotify.js +++ b/sendNotify.js @@ -8,8 +8,6 @@ * @param desp 通知体 * @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' } * @param author 作者仓库等信息 例:`本通知 By:https://github.com/whyour/qinglong` - * @魔改:smallfawn https://github.com/smallfawn/QLScriptPublic 参考:ccwav https://github.com/ccwav/QLScript2 - * @魔改位置 sendNotify函数 黑白名单模式 */ const querystring = require('querystring'); @@ -143,6 +141,11 @@ let SMTP_EMAIL = ''; let SMTP_PASSWORD = ''; let SMTP_NAME = ''; +// =======================================PushMe通知设置区域=========================================== +//官方文档:https://push.i-i.me/ +//此处填你的PushMe KEY. +let PUSHME_KEY = ''; + //==========================云端环境变量的判断与接收========================= if (process.env.GOTIFY_URL) { GOTIFY_URL = process.env.GOTIFY_URL; @@ -290,12 +293,13 @@ if (process.env.SMTP_PASSWORD) { if (process.env.SMTP_NAME) { SMTP_NAME = process.env.SMTP_NAME; } +if (process.env.PUSHME_KEY) { + PUSHME_KEY = process.env.PUSHME_KEY; +} //==========================云端环境变量的判断与接收========================= /** * sendNotify 推送通知功能 - * 魔改:smallfawn https://github.com/smallfawn 增加黑白名单模式 - * 变量值 smallfawnPushWhite白名单 smallfawnPushBlack黑名单 不写默认通知 黑白名单二选一 * @param text 通知头 * @param desp 通知体 * @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' } @@ -308,7 +312,6 @@ async function sendNotify( params = {}, author = '\n\n本通知 By:https://github.com/whyour/qinglong', ) { - let pushType = ["smallfawnPushWhite", "smallfawnPushBlack", 'default'] /* 判断 黑白名单 或默认模式 */ function checkSmallfawnPushType() { @@ -410,7 +413,6 @@ async function sendNotify( smtpNotify(text, desp), //SMTP 邮件 ]); } - } function gotifyNotify(text, desp) { @@ -1188,6 +1190,41 @@ function smtpNotify(text, desp) { }); } +function PushMeNotify(text, desp) { + return new Promise((resolve) => { + if (PUSHME_KEY) { + const options = { + url: `https://push.i-i.me?push_key=${PUSHME_KEY}`, + json: { title: text, content: desp }, + headers: { + 'Content-Type': 'application/json', + }, + timeout, + }; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('PushMeNotify发送通知调用API失败!!\n'); + console.log(err); + } else { + if (data === 'success') { + console.log('PushMe发送通知消息成功🎉\n'); + } else { + console.log(`${data}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }); + } else { + resolve(); + } + }); +} + module.exports = { sendNotify, BARK_PUSH,