diff --git a/sample/notify.js b/sample/notify.js index c4307640..dc6939bb 100644 --- a/sample/notify.js +++ b/sample/notify.js @@ -141,6 +141,10 @@ let SMTP_EMAIL = ''; let SMTP_PASSWORD = ''; let SMTP_NAME = ''; +// =======================================PushMe通知设置区域=========================================== +//此处填你的PushMe KEY. +let PUSHME_KEY = ''; + //==========================云端环境变量的判断与接收========================= if (process.env.GOTIFY_URL) { GOTIFY_URL = process.env.GOTIFY_URL; @@ -288,6 +292,9 @@ 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; +} //==========================云端环境变量的判断与接收========================= /** @@ -336,6 +343,7 @@ async function sendNotify( aibotkNotify(text, desp), //智能微秘书 fsBotNotify(text, desp), //飞书机器人 smtpNotify(text, desp), //SMTP 邮件 + PushMeNotify(text, desp), //PushMe ]); } @@ -1117,6 +1125,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,