增加PushMe消息通道

This commit is contained in:
雨思 2023-07-18 16:50:37 +08:00 committed by GitHub
parent 4e091b0c3e
commit ba3ef84003
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,6 +141,10 @@ let SMTP_EMAIL = '';
let SMTP_PASSWORD = ''; let SMTP_PASSWORD = '';
let SMTP_NAME = ''; let SMTP_NAME = '';
// =======================================PushMe通知设置区域===========================================
//此处填你的PushMe KEY.
let PUSHME_KEY = '';
//==========================云端环境变量的判断与接收========================= //==========================云端环境变量的判断与接收=========================
if (process.env.GOTIFY_URL) { if (process.env.GOTIFY_URL) {
GOTIFY_URL = process.env.GOTIFY_URL; GOTIFY_URL = process.env.GOTIFY_URL;
@ -288,6 +292,9 @@ if (process.env.SMTP_PASSWORD) {
if (process.env.SMTP_NAME) { if (process.env.SMTP_NAME) {
SMTP_NAME = 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), //智能微秘书 aibotkNotify(text, desp), //智能微秘书
fsBotNotify(text, desp), //飞书机器人 fsBotNotify(text, desp), //飞书机器人
smtpNotify(text, desp), //SMTP 邮件 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 = { module.exports = {
sendNotify, sendNotify,
BARK_PUSH, BARK_PUSH,