mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
增加微加机器人消息通道 (#2373)
Co-authored-by: chensiyuan <chensiyuan@pushplus.plus>
This commit is contained in:
parent
b309ac7613
commit
e77d4c4337
|
@ -14,6 +14,7 @@ export enum NotificationMode {
|
|||
'aibotk' = 'aibotk',
|
||||
'iGot' = 'iGot',
|
||||
'pushPlus' = 'pushPlus',
|
||||
'wePlusBot' = 'wePlusBot',
|
||||
'email' = 'email',
|
||||
'pushMe' = 'pushMe',
|
||||
'feishu' = 'feishu',
|
||||
|
@ -100,6 +101,12 @@ export class PushPlusNotification extends NotificationBaseInfo {
|
|||
public pushPlusUser = '';
|
||||
}
|
||||
|
||||
export class WePlusBotNotification extends NotificationBaseInfo {
|
||||
public wePlusBotToken = '';
|
||||
public wePlusBotReceiver = '';
|
||||
public wePlusBotVersion = '';
|
||||
}
|
||||
|
||||
export class EmailNotification extends NotificationBaseInfo {
|
||||
public emailService: string = '';
|
||||
public emailUser: string = '';
|
||||
|
@ -146,6 +153,7 @@ export interface NotificationInfo
|
|||
AibotkNotification,
|
||||
IGotNotification,
|
||||
PushPlusNotification,
|
||||
WePlusBotNotification,
|
||||
EmailNotification,
|
||||
PushMeNotification,
|
||||
WebhookNotification,
|
||||
|
|
|
@ -27,6 +27,7 @@ export default class NotificationService {
|
|||
['aibotk', this.aibotk],
|
||||
['iGot', this.iGot],
|
||||
['pushPlus', this.pushPlus],
|
||||
['wePlusBot',this.wePlusBot],
|
||||
['email', this.email],
|
||||
['pushMe', this.pushMe],
|
||||
['webhook', this.webhook],
|
||||
|
@ -513,6 +514,42 @@ export default class NotificationService {
|
|||
}
|
||||
}
|
||||
|
||||
private async wePlusBot() {
|
||||
const { wePlusBotToken, wePlusBotReceiver, wePlusBotVersion } = this.params;
|
||||
|
||||
let content = this.content;
|
||||
let template = 'txt';
|
||||
if(this.content.length>800){
|
||||
template = 'html';
|
||||
content = content.replace(/[\n\r]/g, '<br>');
|
||||
}
|
||||
|
||||
const url = `https://www.weplusbot.com/send`;
|
||||
try {
|
||||
const res: any = await got
|
||||
.post(url, {
|
||||
...this.gotOption,
|
||||
json: {
|
||||
token: `${wePlusBotToken}`,
|
||||
title: `${this.title}`,
|
||||
template: `${template}`,
|
||||
content: `${content}`,
|
||||
receiver: `${wePlusBotReceiver || ''}`,
|
||||
version: `${wePlusBotVersion || 'pro'}`,
|
||||
},
|
||||
})
|
||||
.json();
|
||||
|
||||
if (res.code === 200) {
|
||||
return true;
|
||||
} else {
|
||||
throw new Error(JSON.stringify(res));
|
||||
}
|
||||
} catch (error: any) {
|
||||
throw new Error(error.response ? error.response.body : error);
|
||||
}
|
||||
}
|
||||
|
||||
private async lark() {
|
||||
let { larkKey } = this.params;
|
||||
|
||||
|
|
|
@ -118,7 +118,18 @@ export PUSH_PLUS_TOKEN=""
|
|||
## 1. 需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送
|
||||
export PUSH_PLUS_USER=""
|
||||
|
||||
## 9. go-cqhttp
|
||||
## 9. 微加机器人
|
||||
## 官方网站:http://www.weplusbot.com
|
||||
## 下方填写您的Token;微信扫描登录后在"我的"->"设置"->"令牌"中获取
|
||||
export WE_PLUS_BOT_TOKEN=""
|
||||
## 消息接收人;
|
||||
## 个人版填写接收消息的群编码,不填发送给自己的微信号
|
||||
## 专业版不填默认发给机器人自己,发送给好友填写wxid,发送给微信群填写群编码
|
||||
export WE_PLUS_BOT_RECEIVER=""
|
||||
## 调用版本;分为专业版和个人版,专业版填写pro,个人版填写personal
|
||||
export WE_PLUS_BOT_VERSION="pro"
|
||||
|
||||
## 10. go-cqhttp
|
||||
## gobot_url 推送到个人QQ: http://127.0.0.1/send_private_msg 群:http://127.0.0.1/send_group_msg
|
||||
## gobot_token 填写在go-cqhttp文件设置的访问密钥
|
||||
## gobot_qq 如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群
|
||||
|
@ -127,7 +138,7 @@ export GOBOT_URL=""
|
|||
export GOBOT_TOKEN=""
|
||||
export GOBOT_QQ=""
|
||||
|
||||
## 10. gotify
|
||||
## 11. gotify
|
||||
## gotify_url 填写gotify地址,如https://push.example.de:8080
|
||||
## gotify_token 填写gotify的消息应用token
|
||||
## gotify_priority 填写推送消息优先级,默认为0
|
||||
|
@ -135,17 +146,17 @@ export GOTIFY_URL=""
|
|||
export GOTIFY_TOKEN=""
|
||||
export GOTIFY_PRIORITY=0
|
||||
|
||||
## 11. PushDeer
|
||||
## 12. PushDeer
|
||||
## deer_key 填写PushDeer的key
|
||||
export DEER_KEY=""
|
||||
|
||||
## 12. Chat
|
||||
## 13. Chat
|
||||
## chat_url 填写synology chat地址,http://IP:PORT/webapi/***token=
|
||||
## chat_token 填写后面的token
|
||||
export CHAT_URL=""
|
||||
export CHAT_TOKEN=""
|
||||
|
||||
## 13. aibotk
|
||||
## 14. aibotk
|
||||
## 官方说明文档:http://wechat.aibotk.com/oapi/oapi?from=ql
|
||||
## aibotk_key (必填)填写智能微秘书个人中心的apikey
|
||||
export AIBOTK_KEY=""
|
||||
|
@ -154,7 +165,7 @@ export AIBOTK_TYPE=""
|
|||
## aibotk_name (必填)填写群名或用户昵称,和上面的type类型要对应
|
||||
export AIBOTK_NAME=""
|
||||
|
||||
## 13. CHRONOCAT
|
||||
## 15. CHRONOCAT
|
||||
## CHRONOCAT_URL 推送 http://127.0.0.1:16530
|
||||
## CHRONOCAT_TOKEN 填写在CHRONOCAT文件生成的访问密钥
|
||||
## CHRONOCAT_QQ 个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群 如:user_id=xxx;group_id=xxxx;group_id=xxxxx
|
||||
|
@ -163,7 +174,7 @@ export CHRONOCAT_URL=""
|
|||
export CHRONOCAT_QQ=""
|
||||
export CHRONOCAT_TOKEN=""
|
||||
|
||||
## 14. SMTP
|
||||
## 16. SMTP
|
||||
## 邮箱服务名称,比如126、163、Gmail、QQ等,支持列表 https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json
|
||||
export SMTP_SERVICE=""
|
||||
## smtp_email 填写 SMTP 收发件邮箱,通知将会由自己发给自己
|
||||
|
@ -173,26 +184,26 @@ export SMTP_PASSWORD=""
|
|||
## smtp_name 填写 SMTP 收发件人姓名,可随意填写
|
||||
export SMTP_NAME=""
|
||||
|
||||
## 15. PushMe
|
||||
## 17. PushMe
|
||||
## 官方说明文档:https://push.i-i.me/
|
||||
## PUSHME_KEY (必填)填写PushMe APP上获取的push_key
|
||||
## PUSHME_URL (选填)填写自建的PushMeServer消息服务接口地址,例如:http://127.0.0.1:3010,不填则使用官方接口服务
|
||||
export PUSHME_KEY=""
|
||||
export PUSHME_URL=""
|
||||
|
||||
## 16. 飞书机器人
|
||||
## 18. 飞书机器人
|
||||
## 官方文档:https://www.feishu.cn/hc/zh-CN/articles/360024984973
|
||||
## FSKEY 飞书机器人的 FSKEY
|
||||
export FSKEY=""
|
||||
|
||||
## 17. Qmsg酱
|
||||
## 19. Qmsg酱
|
||||
## 官方文档:https://qmsg.zendee.cn/docs/api/
|
||||
## qmsg 酱的 QMSG_KEY
|
||||
## qmsg 酱的 QMSG_TYPE send 为私聊,group 为群聊
|
||||
export QMSG_KEY=""
|
||||
export QMSG_TYPE=""
|
||||
|
||||
## 18. 自定义通知
|
||||
## 20. 自定义通知
|
||||
## 自定义通知 接收回调的URL
|
||||
export WEBHOOK_URL=""
|
||||
## WEBHOOK_BODY 和 WEBHOOK_HEADERS 多个参数时,直接换行或者使用 $'\n' 连接多行字符串,比如 export dd="line 1"$'\n'"line 2"
|
||||
|
|
|
@ -44,6 +44,11 @@ const push_config = {
|
|||
PUSH_PLUS_TOKEN: '', // push+ 微信推送的用户令牌
|
||||
PUSH_PLUS_USER: '', // push+ 微信推送的群组编码
|
||||
|
||||
// 微加机器人,官方网站:https://www.weplusbot.com/
|
||||
WE_PLUS_BOT_TOKEN: '', // 微加机器人的用户令牌
|
||||
WE_PLUS_BOT_RECEIVER: '', // 微加机器人的消息接收人
|
||||
WE_PLUS_BOT_VERSION: 'pro', //微加机器人调用版本,pro和personal;为空默认使用pro(专业版),个人版填写:personal
|
||||
|
||||
QMSG_KEY: '', // qmsg 酱的 QMSG_KEY
|
||||
QMSG_TYPE: '', // qmsg 酱的 QMSG_TYPE
|
||||
|
||||
|
@ -801,6 +806,61 @@ function pushPlusNotify(text, desp) {
|
|||
});
|
||||
}
|
||||
|
||||
function wePlusBotNotify(text, desp) {
|
||||
return new Promise((resolve) => {
|
||||
const { WE_PLUS_BOT_TOKEN, WE_PLUS_BOT_RECEIVER, WE_PLUS_BOT_VERSION } = push_config;
|
||||
if (WE_PLUS_BOT_TOKEN) {
|
||||
const template = 'txt';
|
||||
if(desp.length>800){
|
||||
desp = desp.replace(/[\n\r]/g, '<br>');
|
||||
template = 'html';
|
||||
}
|
||||
const body = {
|
||||
token: `${WE_PLUS_BOT_TOKEN}`,
|
||||
title: `${text}`,
|
||||
content: `${desp}`,
|
||||
template: `${template}`,
|
||||
receiver: `${WE_PLUS_BOT_RECEIVER}`,
|
||||
version: `${WE_PLUS_BOT_VERSION}`,
|
||||
};
|
||||
const options = {
|
||||
url: `https://www.weplusbot.com/send`,
|
||||
body: JSON.stringify(body),
|
||||
headers: {
|
||||
'Content-Type': ' application/json',
|
||||
},
|
||||
timeout,
|
||||
};
|
||||
$.post(options, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(
|
||||
`微加机器人 发送通知消息失败😞\n`,
|
||||
err,
|
||||
);
|
||||
} else {
|
||||
if (data.code === 200) {
|
||||
console.log(
|
||||
`微加机器人 发送通知消息完成🎉\n`,
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`微加机器人 发送通知消息异常 ${data.msg}\n`,
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp);
|
||||
} finally {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function aibotkNotify(text, desp) {
|
||||
return new Promise((resolve) => {
|
||||
const { AIBOTK_KEY, AIBOTK_TYPE, AIBOTK_NAME } = push_config;
|
||||
|
@ -1236,6 +1296,7 @@ async function sendNotify(text, desp, params = {}) {
|
|||
await Promise.all([
|
||||
serverNotify(text, desp), // 微信server酱
|
||||
pushPlusNotify(text, desp), // pushplus
|
||||
wePlusBotNotify(text, desp), // 微加机器人
|
||||
barkNotify(text, desp, params), // iOS Bark APP
|
||||
tgBotNotify(text, desp), // telegram 机器人
|
||||
ddBotNotify(text, desp), // 钉钉机器人
|
||||
|
|
|
@ -75,6 +75,10 @@ push_config = {
|
|||
'PUSH_PLUS_TOKEN': '', # push+ 微信推送的用户令牌
|
||||
'PUSH_PLUS_USER': '', # push+ 微信推送的群组编码
|
||||
|
||||
'WE_PLUS_BOT_TOKEN': '', # 微加机器人的用户令牌
|
||||
'WE_PLUS_BOT_RECEIVER': '', # 微加机器人的消息接收者
|
||||
'WE_PLUS_BOT_VERSION': 'pro', # 微加机器人的调用版本
|
||||
|
||||
'QMSG_KEY': '', # qmsg 酱的 QMSG_KEY
|
||||
'QMSG_TYPE': '', # qmsg 酱的 QMSG_TYPE
|
||||
|
||||
|
@ -381,6 +385,37 @@ def pushplus_bot(title: str, content: str) -> None:
|
|||
else:
|
||||
print("PUSHPLUS 推送失败!")
|
||||
|
||||
def weplus_bot(title: str, content: str) -> None:
|
||||
"""
|
||||
通过 微加机器人 推送消息。
|
||||
"""
|
||||
if not push_config.get("WE_PLUS_BOT_TOKEN"):
|
||||
print("微加机器人 服务的 WE_PLUS_BOT_TOKEN 未设置!!\n取消推送")
|
||||
return
|
||||
print("微加机器人 服务启动")
|
||||
|
||||
template = "txt"
|
||||
if len(content) > 800:
|
||||
template = "html"
|
||||
|
||||
url = "https://www.weplusbot.com/send"
|
||||
data = {
|
||||
"token": push_config.get("WE_PLUS_BOT_TOKEN"),
|
||||
"title": title,
|
||||
"content": content,
|
||||
"template": template,
|
||||
"receiver": push_config.get("WE_PLUS_BOT_RECEIVER"),
|
||||
"version": push_config.get("WE_PLUS_BOT_VERSION"),
|
||||
}
|
||||
body = json.dumps(data).encode(encoding="utf-8")
|
||||
headers = {"Content-Type": "application/json"}
|
||||
response = requests.post(url=url, data=body, headers=headers).json()
|
||||
|
||||
if response["code"] == 200:
|
||||
print("微加机器人 推送成功!")
|
||||
else:
|
||||
print("微加机器人 推送失败!")
|
||||
|
||||
|
||||
def qmsg_bot(title: str, content: str) -> None:
|
||||
"""
|
||||
|
@ -858,6 +893,8 @@ def add_notify_function():
|
|||
notify_function.append(chat)
|
||||
if push_config.get("PUSH_PLUS_TOKEN"):
|
||||
notify_function.append(pushplus_bot)
|
||||
if push_config.get("WE_PLUS_BOT_TOKEN"):
|
||||
notify_function.append(weplus_bot)
|
||||
if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"):
|
||||
notify_function.append(qmsg_bot)
|
||||
if push_config.get("QYWX_AM"):
|
||||
|
|
|
@ -336,6 +336,7 @@
|
|||
"企业微信应用": "WeChat Work App",
|
||||
"智能微秘书": "Smart WeChat Assistant",
|
||||
"群晖chat": "Synology Chat",
|
||||
"微加机器人": "WePlusBot",
|
||||
"邮箱": "Email",
|
||||
"飞书机器人": "Feishu Bot",
|
||||
"自定义通知": "Custom Notification",
|
||||
|
@ -378,6 +379,9 @@
|
|||
"iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX": "iGot information push key, e.g., https://push.hellyw.com/XXXXXXXX",
|
||||
"微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/": "After WeChat scan login, one-to-one or one-to-many push using the provided token (your Token). If PUSH_PLUS_USER is not provided, it defaults to one-to-one push. See reference at https://www.pushplus.plus/",
|
||||
"一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "The 'group code' for one-to-many push (one-to-many push -> your group (if none, create one) -> group code). If you are the creator of the group, you need to click 'View QR code' to scan and bind, otherwise, you won't receive group messages.",
|
||||
"用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/": "Token, which can be obtained after scanning and logging in, is available under 'My Account' -> 'Settings' -> 'Tokens'. Please refer to the instructions for detailed steps: https://www.weplusbot.com/",
|
||||
"消息接收人": "message recipient",
|
||||
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "Version, you can specify 'pro' for the Professional version and 'personal' for the Personal version. If left blank, it will default to the Professional version.",
|
||||
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "Feishu group bot: https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
||||
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "Email service name, e.g., 126, 163, Gmail, QQ, etc. Supported list: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
||||
"邮箱地址": "Email Address",
|
||||
|
|
|
@ -336,6 +336,7 @@
|
|||
"企业微信应用": "企业微信应用",
|
||||
"智能微秘书": "智能微秘书",
|
||||
"群晖chat": "群晖chat",
|
||||
"微加机器人": "微加机器人",
|
||||
"邮箱": "邮箱",
|
||||
"飞书机器人": "飞书机器人",
|
||||
"自定义通知": "自定义通知",
|
||||
|
@ -378,6 +379,9 @@
|
|||
"iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX": "iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX",
|
||||
"微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/": "微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/",
|
||||
"一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)",
|
||||
"用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/": "用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/",
|
||||
"消息接收人": "消息接收人",
|
||||
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版",
|
||||
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
||||
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
||||
"邮箱地址": "邮箱地址",
|
||||
|
|
|
@ -95,6 +95,7 @@ export default {
|
|||
{ value: 'aibotk', label: intl.get('智能微秘书') },
|
||||
{ value: 'iGot', label: 'IGot' },
|
||||
{ value: 'pushPlus', label: 'PushPlus' },
|
||||
{ value: 'wePlusBot', label: intl.get('微加机器人') },
|
||||
{ value: 'chat', label: intl.get('群晖chat') },
|
||||
{ value: 'email', label: intl.get('邮箱') },
|
||||
{ value: 'lark', label: intl.get('飞书机器人') },
|
||||
|
@ -312,6 +313,27 @@ export default {
|
|||
),
|
||||
},
|
||||
],
|
||||
wePlusBot: [
|
||||
{
|
||||
label: 'wePlusBotToken',
|
||||
tip: intl.get(
|
||||
'用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/',
|
||||
),
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: 'wePlusBotReceiver',
|
||||
tip: intl.get(
|
||||
'消息接收人',
|
||||
),
|
||||
},
|
||||
{
|
||||
label: 'wePlusBotVersion',
|
||||
tip: intl.get(
|
||||
'调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版',
|
||||
),
|
||||
},
|
||||
],
|
||||
lark: [
|
||||
{
|
||||
label: 'larkKey',
|
||||
|
|
Loading…
Reference in New Issue
Block a user