diff --git a/githubAction.md b/githubAction.md index 1635b8fb..e284c8c6 100644 --- a/githubAction.md +++ b/githubAction.md @@ -92,6 +92,8 @@ | `IGOT_PUSH_KEY` | iGot推送 | 非必须 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) | | `QQ_SKEY` | 酷推(Cool Push)推送 | 非必须 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) | | `QQ_MODE` | 酷推(Cool Push)推送 | 非必须 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) | +| `PUSH_PLUS_TOKEN` | pushplus推送 | 非必须 | pushplus微信推送,支持一对一,一对多推送 [官方网站](http://pushplus.hxtrip.com/) | +| `PUSH_PLUS_USER` | pushplus推送 | 非必须 | pushplus微信推送,一对多推送所需的群组 (需订阅者扫描二维码),只填TOKEN默认为一对一推送 | | `PET_NOTIFY_CONTROL` | 东东萌宠推送开关 | 非必须 | 控制京东萌宠是否静默运行,`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | | `FRUIT_NOTIFY_CONTROL` | 东东农场推送开关 | 非必须 | 控制京东农场是否静默运行,`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | | `JD_JOY_REWARD_NOTIFY` | 宠汪汪兑换京豆推送开关 | 非必须 | 控制jd_joy_reward.js脚本是否静默运行,`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) diff --git a/sendNotify.js b/sendNotify.js index 6392824b..23c2d9d6 100644 --- a/sendNotify.js +++ b/sendNotify.js @@ -48,6 +48,11 @@ let DD_BOT_SECRET = ''; //注:此处设置github action用户填写到Settings-Secrets里面(Name输入IGOT_PUSH_KEY) let IGOT_PUSH_KEY = ''; +// =======================================push+设置区域======================================= +//PUSH_PLUS_USER 填一对多推送的订阅组, 官网叫做(topic) +let PUSH_PLUS_TOKEN = ''; +let PUSH_PLUS_USER = ''; + if (process.env.PUSH_KEY) { SCKEY = process.env.PUSH_KEY; } @@ -96,6 +101,13 @@ if (process.env.IGOT_PUSH_KEY) { IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY } +if (process.env.PUSH_PLUS_TOKEN) { + PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN; +} +if (process.env.PUSH_PLUS_USER) { + PUSH_PLUS_USER = process.env.PUSH_PLUS_USER; +} + async function sendNotify(text, desp, params = {}) { //提供六种通知 await serverNotify(text, desp); @@ -105,6 +117,7 @@ async function sendNotify(text, desp, params = {}) { await ddBotNotify(text, desp); await iGotNotify(text, desp, params); await CoolPush(text, desp); + await pushPlusNotify(text, desp); } function serverNotify(text, desp, timeout = 2100) { @@ -379,6 +392,43 @@ function iGotNotify(text, desp, params={}){ }) } +function pushPlusNotify(text, desp) { + return new Promise(resolve => { + if (PUSH_PLUS_TOKEN) { + desp = desp.replace(/[\n\r]/g, '
'); // 默认为html, 不支持plaintext + const options = { + url: `http://pushplus.hxtrip.com/send`, + body: `token=${PUSH_PLUS_TOKEN}&title=${text}&content=${desp}&topic=${PUSH_PLUS_USER}`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('\npush+发送通知消息失败!!\n') + console.log(err); + } else { + data = JSON.parse(data); + if (data.code === 200) { + console.log('\npush+发送通知消息完成。\n') + } else { + console.log('\npush+发送通知消息失败!!\n') + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + } else { + console.log('\n您未提供push+推送所需的PUSH_PLUS_TOKEN,取消push+推送消息通知\n'); + resolve() + } + }) +} + module.exports = { sendNotify }