mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
feat: 添加Qmsg酱推送(#115)
This commit is contained in:
parent
4d90d83b67
commit
266ecf75a9
48
README.md
48
README.md
@ -266,29 +266,31 @@ $ tree
|
|||||||
|
|
||||||
以下是支持的推送方式
|
以下是支持的推送方式
|
||||||
|
|
||||||
| Name | 归属 | 属性 | 说明 |
|
| Name | 归属 | 说明 |
|
||||||
| :---------------: | :--------------------------------------------------------------------------------: | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| :---------------: | :--------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `SCKEY` | 微信server酱推送(于2021/4月下线) | 非必须 | server酱的微信通知[官方文档](http://sc.ftqq.com/3.version) |
|
| `SCKEY` | 微信server酱推送(于2021/4月下线) | server酱的微信通知[官方文档](http://sc.ftqq.com/3.version) |
|
||||||
| `SENDKEY` | 微信server酱(Turbo版)推送 | 非必须 | [获取SENDKEY](https://sct.ftqq.com/sendkey) [选择消息通道](https://sct.ftqq.com/forward) |
|
| `SENDKEY` | 微信server酱(Turbo版)推送 | [获取SENDKEY](https://sct.ftqq.com/sendkey) [选择消息通道](https://sct.ftqq.com/forward) |
|
||||||
| `BARK_PUSH` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | 非必须 | IOS用户下载BARK这个APP,填写内容是app提供的`设备码`,例如:<https://api.day.app/123> ,那么此处的设备码就是`123`,再不懂看 [这个图](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/bark.jpg)(注:支持自建填完整链接即可) |
|
| `BARK_PUSH` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | IOS用户下载BARK这个APP,填写内容是app提供的`设备码`,例如:<https://api.day.app/123> ,那么此处的设备码就是`123`,再不懂看 [这个图](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/bark.jpg)(注:支持自建填完整链接即可) |
|
||||||
| `BARK_SOUND` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | 非必须 | bark推送声音设置,例如`choo`,具体值请在`bark`-`推送铃声`-`查看所有铃声` |
|
| `BARK_SOUND` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | bark推送声音设置,例如`choo`,具体值请在`bark`-`推送铃声`-`查看所有铃声` |
|
||||||
| `TG_BOT_TOKEN` | telegram推送 | 非必须 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](doc/TG_PUSH.md) |
|
| `TG_BOT_TOKEN` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](doc/TG_PUSH.md) |
|
||||||
| `TG_USER_ID` | telegram推送 | 非必须 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](doc/TG_PUSH.md) |
|
| `TG_USER_ID` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](doc/TG_PUSH.md) |
|
||||||
| `TG_PROXY_HOST` | Telegram 代理的 IP | 非必须 | 代理类型为 http。例子:http代理 <http://127.0.0.1:1080> 则填写 127.0.0.1 |
|
| `TG_PROXY_HOST` | Telegram 代理的 IP | 代理类型为 http。例子:http代理 <http://127.0.0.1:1080> 则填写 127.0.0.1 |
|
||||||
| `TG_PROXY_PORT` | Telegram 代理的端口 | 非必须 | 例子:http代理 <http://127.0.0.1:1080> 则填写 1080 |
|
| `TG_PROXY_PORT` | Telegram 代理的端口 | 例子:http代理 <http://127.0.0.1:1080> 则填写 1080 |
|
||||||
| `DD_BOT_TOKEN` | 钉钉推送 | 非必须 | 钉钉推送(`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需)[官方文档](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于`=`符号后面的XXX即可 |
|
| `DD_BOT_TOKEN` | 钉钉推送 | 钉钉推送(`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需)[官方文档](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于`=`符号后面的XXX即可 |
|
||||||
| `DD_BOT_SECRET` | 钉钉推送 | 非必须 | (`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需) ,密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的`SECXXXXXXXXXX`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/DD_bot.png) |
|
| `DD_BOT_SECRET` | 钉钉推送 | (`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需) ,密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的`SECXXXXXXXXXX`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/DD_bot.png) |
|
||||||
| `IGOT_PUSH_KEY` | iGot推送 | 非必须 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) |
|
| `IGOT_PUSH_KEY` | iGot推送 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) |
|
||||||
| `QQ_SKEY` | 酷推(Cool Push)推送 | 非必须 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) |
|
| `QQ_SKEY` | 酷推(Cool Push)推送 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) |
|
||||||
| `QQ_MODE` | 酷推(Cool Push)推送 | 非必须 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) |
|
| `QQ_MODE` | 酷推(Cool Push)推送 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) |
|
||||||
| `QYWX_KEY` | 企业微信推送 | 非必须 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) |
|
| `QYWX_KEY` | 企业微信推送 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) |
|
||||||
| `PUSH_PLUS_TOKEN` | pushplus推送 | 非必须 | 微信扫码登录后一对一推送或一对多推送下面的token(您的Token) [官方网站](http://pushplus.hxtrip.com/) |
|
| `PUSH_PLUS_TOKEN` | pushplus推送 | 微信扫码登录后一对一推送或一对多推送下面的token(您的Token) [官方网站](http://pushplus.hxtrip.com/) |
|
||||||
| `PUSH_PLUS_USER` | pushplus推送 | 非必须 | 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码)注:(1、需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送),只填`PUSH_PLUS_TOKEN`默认为一对一推送 |
|
| `PUSH_PLUS_USER` | pushplus推送 | 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码)注:(1、需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送),只填`PUSH_PLUS_TOKEN`默认为一对一推送 |
|
||||||
| `SMTP_HOST` | 电子邮件 | 非必须 | smtp服务器的主机名 如: `smtp.qq.com` |
|
| `QMSG_KEY` | [Qmsg酱](https://qmsg.zendee.cn)私聊推送 | [Qmsg注册](https://qmsg.zendee.cn/login.html) |
|
||||||
| `SMTP_PORT` | 电子邮件 | 非必须 | smtp服务器的端口 如: `465` |
|
| `QMSG_QQ` | 私聊消息推送接口,指定需要接收消息的QQ | 指定的QQ号必须在你的[管理台](https://qmsg.zendee.cn/me.html)已添加 |
|
||||||
| `SMTP_USER` | 电子邮件 | 非必须 | 发送方的电子邮件 如: `xxxxxxxxx@qq.com` |
|
| `SMTP_HOST` | 电子邮件 | smtp服务器的主机名 如: `smtp.qq.com` |
|
||||||
| `SMTP_PASS` | 电子邮件 | 非必须 | smtp服务对应的授权码 |
|
| `SMTP_PORT` | 电子邮件 | smtp服务器的端口 如: `465` |
|
||||||
| `SMTP_TO_USER` | 电子邮件 | 非必须 | 接收方电子邮件 |
|
| `SMTP_USER` | 电子邮件 | 发送方的电子邮件 如: `xxxxxxxxx@qq.com` |
|
||||||
|
| `SMTP_PASS` | 电子邮件 | smtp服务对应的授权码 |
|
||||||
|
| `SMTP_TO_USER` | 电子邮件 | 接收方电子邮件 |
|
||||||
|
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -61,6 +61,8 @@ module.exports = Object.freeze({
|
|||||||
IGOT_PUSH_KEY: "",
|
IGOT_PUSH_KEY: "",
|
||||||
PUSH_PLUS_TOKEN: "",
|
PUSH_PLUS_TOKEN: "",
|
||||||
PUSH_PLUS_USER: "",
|
PUSH_PLUS_USER: "",
|
||||||
|
QMSG_KEY: "",
|
||||||
|
QMSG_QQ: "",
|
||||||
SMTP_HOST: "",
|
SMTP_HOST: "",
|
||||||
SMTP_PORT: "",
|
SMTP_PORT: "",
|
||||||
SMTP_USER: "",
|
SMTP_USER: "",
|
||||||
|
|||||||
@ -60,6 +60,10 @@ let IGOT_PUSH_KEY = '';
|
|||||||
let PUSH_PLUS_TOKEN = '';
|
let PUSH_PLUS_TOKEN = '';
|
||||||
let PUSH_PLUS_USER = '';
|
let PUSH_PLUS_USER = '';
|
||||||
|
|
||||||
|
// ===========================================QMSG===========================================
|
||||||
|
let QMSG_KEY = '';
|
||||||
|
let QMSG_QQ = '';
|
||||||
|
|
||||||
// ===========================================邮件推送===============================================
|
// ===========================================邮件推送===============================================
|
||||||
let SMTP_HOST = '';
|
let SMTP_HOST = '';
|
||||||
let SMTP_PORT = '';
|
let SMTP_PORT = '';
|
||||||
@ -136,6 +140,14 @@ if (process.env.PUSH_PLUS_USER) {
|
|||||||
PUSH_PLUS_USER = process.env.PUSH_PLUS_USER;
|
PUSH_PLUS_USER = process.env.PUSH_PLUS_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.QMSG_KEY) {
|
||||||
|
QMSG_KEY = process.env.QMSG_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.QMSG_QQ) {
|
||||||
|
QMSG_QQ = process.env.QMSG_QQ;
|
||||||
|
}
|
||||||
|
|
||||||
if (process.env.SMTP_HOST) {
|
if (process.env.SMTP_HOST) {
|
||||||
SMTP_HOST = process.env.SMTP_HOST;
|
SMTP_HOST = process.env.SMTP_HOST;
|
||||||
}
|
}
|
||||||
@ -177,6 +189,8 @@ async function sendNotify(text, desp, params = {}) {
|
|||||||
iGotNotify(text, desp, params),
|
iGotNotify(text, desp, params),
|
||||||
//QQ酷推
|
//QQ酷推
|
||||||
coolPush(text, desp),
|
coolPush(text, desp),
|
||||||
|
// Qmsg
|
||||||
|
qmsg(text, desp),
|
||||||
//电子邮件
|
//电子邮件
|
||||||
email(text, desp)
|
email(text, desp)
|
||||||
])
|
])
|
||||||
@ -216,8 +230,8 @@ function serverNotify(text, desp) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: err => {
|
failure: err => {
|
||||||
log.error('发送通知', 'server酱 发送通知调用API失败!!')
|
log.error('发送通知', 'server酱 发送通知调用API失败!!' + err)
|
||||||
throw new Error(err);
|
resolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -258,8 +272,8 @@ function serverNotifyTurbo(text, desp) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: err => {
|
failure: err => {
|
||||||
log.error('发送通知', 'server酱(Turbo版) 发送通知调用API失败!!')
|
log.error('发送通知', 'server酱(Turbo版) 发送通知调用API失败!!' + err)
|
||||||
throw new Error(err);
|
resolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -314,8 +328,8 @@ function coolPush(text, desp) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: err => {
|
failure: err => {
|
||||||
log.error('发送通知', `酷推 发送${pushMode(QQ_MODE)}通知调用API失败!!`)
|
log.error('发送通知', `酷推 发送${pushMode(QQ_MODE)}通知调用API失败!!${err}`)
|
||||||
throw new Error(err);
|
resolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -356,9 +370,8 @@ function barkNotify(text, desp, params = {}) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: err => {
|
failure: err => {
|
||||||
log.error('发送通知', 'Bark APP发送通知调用API失败!!');
|
log.error('发送通知', 'Bark APP发送通知调用API失败!!' + err);
|
||||||
resolve();
|
resolve();
|
||||||
throw new Error(err)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -404,9 +417,8 @@ function tgBotNotify(text, desp) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: err => {
|
failure: err => {
|
||||||
log.error('发送通知', 'telegram发送通知消息失败!!')
|
log.error('发送通知', 'telegram发送通知消息失败!!' + err)
|
||||||
resolve()
|
resolve()
|
||||||
throw new Error(err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TG_PROXY_HOST && TG_PROXY_PORT) {
|
if (TG_PROXY_HOST && TG_PROXY_PORT) {
|
||||||
@ -467,8 +479,8 @@ function ddBotNotify(text, desp) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: err => {
|
failure: err => {
|
||||||
log.error('发送通知', '钉钉发送通知消息失败!!')
|
log.error('发送通知', '钉钉发送通知消息失败!!' + err)
|
||||||
throw new Error(err);
|
resolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if (DD_BOT_TOKEN) {
|
} else if (DD_BOT_TOKEN) {
|
||||||
@ -506,9 +518,8 @@ function ddBotNotify(text, desp) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: err => {
|
failure: err => {
|
||||||
log.error('发送通知', '钉钉发送通知消息失败!!');
|
log.error('发送通知', '钉钉发送通知消息失败!!' + err);
|
||||||
resolve();
|
resolve();
|
||||||
throw new Error(err)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -552,9 +563,8 @@ function qywxBotNotify(text, desp) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: err => {
|
failure: err => {
|
||||||
log.error('发送通知', '企业微信发送通知消息失败!!');
|
log.error('发送通知', '企业微信发送通知消息失败!!' + err);
|
||||||
resolve();
|
resolve();
|
||||||
throw new Error(err)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -604,9 +614,8 @@ function iGotNotify(text, desp, params = {}) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: err => {
|
failure: err => {
|
||||||
log.error('发送通知', 'iGot 发送通知调用API失败!!')
|
log.error('发送通知', 'iGot 发送通知调用API失败!!' + err)
|
||||||
resolve();
|
resolve();
|
||||||
throw new Error(err)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -650,9 +659,8 @@ function pushPlusNotify(text, desp) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: err => {
|
failure: err => {
|
||||||
log.error('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!`)
|
log.error('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!${err}`)
|
||||||
resolve();
|
resolve();
|
||||||
throw new Error(err)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -662,6 +670,49 @@ function pushPlusNotify(text, desp) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function qmsg(text, desp) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
if (QMSG_KEY) {
|
||||||
|
send({
|
||||||
|
method: 'POST',
|
||||||
|
url: 'https://qmsg.zendee.cn/send/' + QMSG_KEY,
|
||||||
|
contents: {
|
||||||
|
msg: text + "\n\n" + desp,
|
||||||
|
qq: QMSG_QQ
|
||||||
|
},
|
||||||
|
config: {
|
||||||
|
retry: false
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
accept: 'application/json, text/plain, */*',
|
||||||
|
'content-type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
success: res => {
|
||||||
|
try {
|
||||||
|
const data = JSON.parse(res.body);
|
||||||
|
if (data.code === 200) {
|
||||||
|
log.info('发送通知', `qmsg发送通知消息完成。`)
|
||||||
|
} else {
|
||||||
|
log.error('发送通知', `qmsg通知消息失败: ${data.reason}`)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log.error('发送通知', e);
|
||||||
|
} finally {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
failure: err => {
|
||||||
|
log.error('发送通知', `qmsg通知消息失败!!` + err)
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
log.debug('发送通知', '您未提供qmsg推送所需的QMSG_KEY,取消qmsg推送消息通知');
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function email(text, desp) {
|
async function email(text, desp) {
|
||||||
if (SMTP_HOST && SMTP_PORT && SMTP_USER && SMTP_PASS && SMTP_TO_USER) {
|
if (SMTP_HOST && SMTP_PORT && SMTP_USER && SMTP_PASS && SMTP_TO_USER) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user