diff --git a/back/data/notify.ts b/back/data/notify.ts index bcd3c050..ec996b86 100644 --- a/back/data/notify.ts +++ b/back/data/notify.ts @@ -2,6 +2,7 @@ export enum NotificationMode { 'gotify' = 'gotify', 'goCqHttpBot' = 'goCqHttpBot', 'serverChan' = 'serverChan', + 'PushDeer' = 'PushDeer', 'bark' = 'bark', 'telegramBot' = 'telegramBot', 'dingtalkBot' = 'dingtalkBot', @@ -32,6 +33,10 @@ export class ServerChanNotification extends NotificationBaseInfo { public serverChanKey = ''; } +export class PushDeerNotification extends NotificationBaseInfo { + public PushDeerKey = ''; +} + export class BarkNotification extends NotificationBaseInfo { public barkPush = ''; public barkIcon = @@ -81,6 +86,7 @@ export interface NotificationInfo extends GoCqHttpBotNotification, GotifyNotification, ServerChanNotification, + PushDeerNotification, BarkNotification, TelegramBotNotification, DingtalkBotNotification, diff --git a/back/services/notify.ts b/back/services/notify.ts index 7b6edc55..53c198ac 100644 --- a/back/services/notify.ts +++ b/back/services/notify.ts @@ -16,6 +16,7 @@ export default class NotificationService { ['gotify', this.gotify], ['goCqHttpBot', this.goCqHttpBot], ['serverChan', this.serverChan], + ['PushDeer', this.PushDeer], ['bark', this.bark], ['telegramBot', this.telegramBot], ['dingtalkBot', this.dingtalkBot], @@ -90,15 +91,12 @@ export default class NotificationService { private async goCqHttpBot() { const { goCqHttpBotQq, goCqHttpBotToken, goCqHttpBotUrl } = this.params; const res: any = await got - .post( - `${goCqHttpBotUrl}?${goCqHttpBotQq}`, - { - timeout: this.timeout, - retry: 0, - json: { message: `${this.title}\n${this.content}` }, - headers: { 'Authorization': 'Bearer '+goCqHttpBotToken }, - }, - ) + .post(`${goCqHttpBotUrl}?${goCqHttpBotQq}`, { + timeout: this.timeout, + retry: 0, + json: { message: `${this.title}\n${this.content}` }, + headers: { Authorization: 'Bearer ' + goCqHttpBotToken }, + }) .json(); return res.retcode === 0; } @@ -119,6 +117,21 @@ export default class NotificationService { return res.errno === 0 || res.data.errno === 0; } + private async PushDeer() { + const { PushDeerKey } = this.params; + // https://api2.pushdeer.com/message/push?pushkey=&text=标题&desp=&type=markdown + const url = `https://api2.pushdeer.com/message/push`; + const res: any = await got + .post(url, { + timeout: this.timeout, + retry: 0, + body: `pushkey=${PushDeerKey}&text=${this.title}&desp=${this.content}&type=markdown`, + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + }) + .json(); + return res.result.success === 'ok'; + } + private async bark() { let { barkPush, barkIcon, barkSound, barkGroup } = this.params; if (!barkPush.startsWith('http') && !barkPush.startsWith('https')) { diff --git a/src/utils/config.ts b/src/utils/config.ts index 1ee94f3b..bdcde9d9 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -77,6 +77,7 @@ export default { { value: 'gotify', label: 'Gotify' }, { value: 'goCqHttpBot', label: 'GoCqHttpBot' }, { value: 'serverChan', label: 'Server酱' }, + { value: 'PushDeer', label: 'PushDeer' }, { value: 'bark', label: 'Bark' }, { value: 'telegramBot', label: 'Telegram机器人' }, { value: 'dingtalkBot', label: '钉钉机器人' }, @@ -113,6 +114,7 @@ export default { serverChan: [ { label: 'serverChanKey', tip: 'Server酱SENDKEY', required: true }, ], + PushDeer: [{ label: 'PushDeerKey', tip: 'PushDeer的Key', required: true }], bark: [ { label: 'barkPush',