mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
完善pushplus通知方式的代码逻辑 (#2454)
* 1. pushplus通知方式返回结果优化 2. pushplus通知方式适配更多参数 * 细节bug修改 * 删除没用的空格 --------- Co-authored-by: 陈思远 <chensiyuan@yiban.com.cn> Co-authored-by: 陈大人 <chensiyuan@pushplus.plus>
This commit is contained in:
+19
-8
@@ -40,9 +40,15 @@ const push_config = {
|
||||
CHAT_URL: '', // synology chat url
|
||||
CHAT_TOKEN: '', // synology chat token
|
||||
|
||||
// 官方文档:http://www.pushplus.plus/
|
||||
PUSH_PLUS_TOKEN: '', // push+ 微信推送的用户令牌
|
||||
PUSH_PLUS_USER: '', // push+ 微信推送的群组编码
|
||||
// 官方文档:https://www.pushplus.plus/
|
||||
PUSH_PLUS_TOKEN: '', // pushplus 推送的用户令牌
|
||||
PUSH_PLUS_USER: '', // pushplus 推送的群组编码
|
||||
PUSH_PLUS_TEMPLATE: 'html', // pushplus 发送模板,支持html,txt,json,markdown,cloudMonitor,jenkins,route,pay
|
||||
PUSH_PLUS_CHANNEL: 'wechat', // pushplus 发送渠道,支持wechat,webhook,cp,mail,sms
|
||||
PUSH_PLUS_WEBHOOK: '', // pushplus webhook编码,可在pushplus公众号上扩展配置出更多渠道
|
||||
PUSH_PLUS_CALLBACKURL: '', // pushplus 发送结果回调地址,会把推送最终结果通知到这个地址上
|
||||
PUSH_PLUS_TO: '', // pushplus 好友令牌,微信公众号渠道填写好友令牌,企业微信渠道填写企业微信用户id
|
||||
|
||||
|
||||
// 微加机器人,官方网站:https://www.weplusbot.com/
|
||||
WE_PLUS_BOT_TOKEN: '', // 微加机器人的用户令牌
|
||||
@@ -765,7 +771,7 @@ function iGotNotify(text, desp, params = {}) {
|
||||
|
||||
function pushPlusNotify(text, desp) {
|
||||
return new Promise((resolve) => {
|
||||
const { PUSH_PLUS_TOKEN, PUSH_PLUS_USER } = push_config;
|
||||
const { PUSH_PLUS_TOKEN, PUSH_PLUS_USER, PUSH_PLUS_TEMPLATE, PUSH_PLUS_CHANNEL, PUSH_PLUS_WEBHOOK, PUSH_PLUS_CALLBACKURL, PUSH_PLUS_TO } = push_config;
|
||||
if (PUSH_PLUS_TOKEN) {
|
||||
desp = desp.replace(/[\n\r]/g, '<br>'); // 默认为html, 不支持plaintext
|
||||
const body = {
|
||||
@@ -773,6 +779,11 @@ function pushPlusNotify(text, desp) {
|
||||
title: `${text}`,
|
||||
content: `${desp}`,
|
||||
topic: `${PUSH_PLUS_USER}`,
|
||||
template: `${PUSH_PLUS_TEMPLATE}`,
|
||||
channel: `${PUSH_PLUS_CHANNEL}`,
|
||||
webhook: `${PUSH_PLUS_WEBHOOK}`,
|
||||
callbackUrl: `${PUSH_PLUS_CALLBACKURL}`,
|
||||
to: `${PUSH_PLUS_TO}`
|
||||
};
|
||||
const options = {
|
||||
url: `https://www.pushplus.plus/send`,
|
||||
@@ -786,7 +797,7 @@ function pushPlusNotify(text, desp) {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(
|
||||
`Push+ 发送${
|
||||
`pushplus 发送${
|
||||
PUSH_PLUS_USER ? '一对多' : '一对一'
|
||||
}通知消息失败😞\n`,
|
||||
err,
|
||||
@@ -794,13 +805,13 @@ function pushPlusNotify(text, desp) {
|
||||
} else {
|
||||
if (data.code === 200) {
|
||||
console.log(
|
||||
`Push+ 发送${
|
||||
`pushplus 发送${
|
||||
PUSH_PLUS_USER ? '一对多' : '一对一'
|
||||
}通知消息完成🎉\n`,
|
||||
}通知请求成功🎉,可根据流水号查询推送结果:${data.data}\n注意:请求成功并不代表推送成功,如未收到消息,请到pushplus官网使用流水号查询推送最终结果`,
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`Push+ 发送${
|
||||
`pushplus 发送${
|
||||
PUSH_PLUS_USER ? '一对多' : '一对一'
|
||||
}通知消息异常 ${data.msg}\n`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user