mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
增加微加机器人消息通道 (#2373)
Co-authored-by: chensiyuan <chensiyuan@pushplus.plus>
This commit is contained in:
+9
-1
@@ -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,9 +153,10 @@ export interface NotificationInfo
|
||||
AibotkNotification,
|
||||
IGotNotification,
|
||||
PushPlusNotification,
|
||||
WePlusBotNotification,
|
||||
EmailNotification,
|
||||
PushMeNotification,
|
||||
WebhookNotification,
|
||||
ChronocatNotification,
|
||||
LarkNotification {}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user