增加微加机器人消息通道 (#2373)

Co-authored-by: chensiyuan <chensiyuan@pushplus.plus>
This commit is contained in:
陈大人
2024-05-25 00:33:31 +08:00
committed by GitHub
parent b309ac7613
commit e77d4c4337
8 changed files with 198 additions and 14 deletions
+37
View File
@@ -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;