增加PushDeer推送

This commit is contained in:
NekoMio 2022-02-28 19:16:20 +08:00
parent a0d0197ad7
commit 8c3690366c
No known key found for this signature in database
GPG Key ID: 4151059D56C21E8E
3 changed files with 30 additions and 9 deletions

View File

@ -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,

View File

@ -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=<key>&text=标题&desp=<markdown>&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')) {

View File

@ -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',