perf: 新增server酱3通知

This commit is contained in:
xiaojunnuo
2024-12-03 10:32:47 +08:00
parent 393ea27fa4
commit 6aa487269c
17 changed files with 86 additions and 19 deletions
@@ -40,7 +40,7 @@ export class AnPushNotification extends BaseNotification {
},
data: {
title: body.title,
content: body.content + '[查看详情](' + body.url + ')',
content: body.content + '\n\n[查看详情](' + body.url + ')',
channel: this.channel,
},
};
@@ -49,7 +49,7 @@ export class BarkNotification extends BaseNotification {
}
const payload = {
body: body.content, // 使用传入的内容或默认内容
body: `${body.content}\n\n[查看详情](${body.url})`, // 使用传入的内容或默认内容
title: body.title, // 使用传入的标题或默认标题
};
@@ -57,7 +57,7 @@ export class DiscordNotification extends BaseNotification {
}
// 创建 Discord 消息体
let content = `${body.title}\n${body.content}\n[查看详情](${body.url})`;
let content = `${body.title}\n${body.content}\n\n[查看详情](${body.url})`;
if (this.mentionedList && this.mentionedList.length > 0) {
content += `\n${this.mentionedList.map(item => `<@${item}> `).join('')}`;
}
@@ -22,7 +22,7 @@ export class EmailNotification extends BaseNotification {
async send(body: NotificationBody) {
await this.ctx.emailService.send({
subject: body.title,
content: body.content + '\n[查看详情](' + body.url + ')',
content: body.content + '\n\n[查看详情](' + body.url + ')',
receivers: this.receivers,
});
}
@@ -3,6 +3,7 @@ export * from './email/index.js';
export * from './iyuu/index.js';
export * from './webhook/index.js';
export * from './serverchan/index.js';
export * from './serverchan3/index.js';
export * from './anpush/index.js';
export * from './telegram/index.js';
export * from './discord/index.js';
@@ -26,7 +26,7 @@ export class IyuuNotification extends BaseNotification {
method: 'POST',
data: {
text: body.title,
desp: body.content + '[查看详情](' + body.url + ')',
desp: body.content + '\n\n[查看详情](' + body.url + ')',
},
});
@@ -49,7 +49,7 @@ export class QywxNotification extends BaseNotification {
data: {
msgtype: 'markdown',
markdown: {
content: `# ${body.title}\n\n${body.content}\n[查看详情](${body.url})`,
content: `# ${body.title}\n\n${body.content}\n\n[查看详情](${body.url})`,
mentioned_list: this.mentionedList,
},
},
@@ -2,7 +2,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
@IsNotification({
name: 'serverchan',
title: 'Server酱',
title: 'Server酱',
desc: 'https://sct.ftqq.com/',
needPlus: true,
})
@@ -64,7 +64,7 @@ export class ServerChanNotification extends BaseNotification {
method: 'POST',
data: {
text: body.title,
desp: body.content + '[查看详情](' + body.url + ')',
desp: body.content + '\n\n[查看详情](' + body.url + ')',
},
skipSslVerify: this.skipSslVerify,
});
@@ -0,0 +1,65 @@
import { BaseNotification, IsNotification, NotificationBody, NotificationInput } from '@certd/pipeline';
@IsNotification({
name: 'serverchan3',
title: 'Server酱³',
desc: 'https://doc.sc3.ft07.com/serverchan3',
needPlus: true,
})
export class ServerChan3Notification extends BaseNotification {
@NotificationInput({
title: 'ApiURL',
component: {
placeholder: 'https://uid.push.ft07.com/send/sendKey.send',
},
required: true,
})
apiURL = '';
@NotificationInput({
title: '标签Tags',
component: {
name: 'a-select',
vModel: 'value',
mode: 'tags',
open: false,
},
helper: '支持多个,回车后填写下一个',
required: false,
})
tags: string[];
@NotificationInput({
title: 'short',
required: false,
})
short: string;
@NotificationInput({
title: '忽略证书校验',
value: false,
component: {
name: 'a-switch',
vModel: 'checked',
},
required: false,
})
skipSslVerify: boolean;
async send(body: NotificationBody) {
if (!this.apiURL) {
throw new Error('sendKey不能为空');
}
await this.http.request({
url: `${this.apiURL}`,
method: 'POST',
data: {
text: body.title,
desp: body.content + '\n\n[查看详情](' + body.url + ')',
tags: this.tags.join('|'),
short: this.short,
},
skipSslVerify: this.skipSslVerify,
});
}
}
@@ -47,7 +47,7 @@ export class SlackNotification extends BaseNotification {
url: this.webhook,
method: 'POST',
data: {
text: `${body.title}\n${body.content}\n[查看详情](${body.url})`,
text: `${body.title}\n${body.content}\n\n[查看详情](${body.url})`,
},
httpProxy: this.httpsProxy,
skipSslVerify: this.skipSslVerify,
@@ -64,7 +64,7 @@ export class TelegramNotification extends BaseNotification {
}
// 构建消息内容
const messageContent = `*${body.title}*\n\n${body.content}\n[查看详情](${body.url})`;
const messageContent = `*${body.title}*\n\n${body.content}\n\n[查看详情](${body.url})`;
// Telegram API URL
const url = `https://api.telegram.org/bot${this.botToken}/sendMessage`;
@@ -79,7 +79,7 @@ export class VoceChatNotification extends BaseNotification {
'x-api-key': this.apiKey,
'Content-Type': 'text/markdown',
},
data: `# ${body.title}\n\n${body.content}\n[查看详情](${body.url})`,
data: `# ${body.title}\n\n${body.content}\n\n[查看详情](${body.url})`,
skipSslVerify: this.skipSslVerify,
});
}