mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-28 23:46:06 +08:00
增加PushDeer推送
This commit is contained in:
parent
a0d0197ad7
commit
8c3690366c
|
@ -2,6 +2,7 @@ export enum NotificationMode {
|
||||||
'gotify' = 'gotify',
|
'gotify' = 'gotify',
|
||||||
'goCqHttpBot' = 'goCqHttpBot',
|
'goCqHttpBot' = 'goCqHttpBot',
|
||||||
'serverChan' = 'serverChan',
|
'serverChan' = 'serverChan',
|
||||||
|
'PushDeer' = 'PushDeer',
|
||||||
'bark' = 'bark',
|
'bark' = 'bark',
|
||||||
'telegramBot' = 'telegramBot',
|
'telegramBot' = 'telegramBot',
|
||||||
'dingtalkBot' = 'dingtalkBot',
|
'dingtalkBot' = 'dingtalkBot',
|
||||||
|
@ -32,6 +33,10 @@ export class ServerChanNotification extends NotificationBaseInfo {
|
||||||
public serverChanKey = '';
|
public serverChanKey = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class PushDeerNotification extends NotificationBaseInfo {
|
||||||
|
public PushDeerKey = '';
|
||||||
|
}
|
||||||
|
|
||||||
export class BarkNotification extends NotificationBaseInfo {
|
export class BarkNotification extends NotificationBaseInfo {
|
||||||
public barkPush = '';
|
public barkPush = '';
|
||||||
public barkIcon =
|
public barkIcon =
|
||||||
|
@ -81,6 +86,7 @@ export interface NotificationInfo
|
||||||
extends GoCqHttpBotNotification,
|
extends GoCqHttpBotNotification,
|
||||||
GotifyNotification,
|
GotifyNotification,
|
||||||
ServerChanNotification,
|
ServerChanNotification,
|
||||||
|
PushDeerNotification,
|
||||||
BarkNotification,
|
BarkNotification,
|
||||||
TelegramBotNotification,
|
TelegramBotNotification,
|
||||||
DingtalkBotNotification,
|
DingtalkBotNotification,
|
||||||
|
|
|
@ -16,6 +16,7 @@ export default class NotificationService {
|
||||||
['gotify', this.gotify],
|
['gotify', this.gotify],
|
||||||
['goCqHttpBot', this.goCqHttpBot],
|
['goCqHttpBot', this.goCqHttpBot],
|
||||||
['serverChan', this.serverChan],
|
['serverChan', this.serverChan],
|
||||||
|
['PushDeer', this.PushDeer],
|
||||||
['bark', this.bark],
|
['bark', this.bark],
|
||||||
['telegramBot', this.telegramBot],
|
['telegramBot', this.telegramBot],
|
||||||
['dingtalkBot', this.dingtalkBot],
|
['dingtalkBot', this.dingtalkBot],
|
||||||
|
@ -90,15 +91,12 @@ export default class NotificationService {
|
||||||
private async goCqHttpBot() {
|
private async goCqHttpBot() {
|
||||||
const { goCqHttpBotQq, goCqHttpBotToken, goCqHttpBotUrl } = this.params;
|
const { goCqHttpBotQq, goCqHttpBotToken, goCqHttpBotUrl } = this.params;
|
||||||
const res: any = await got
|
const res: any = await got
|
||||||
.post(
|
.post(`${goCqHttpBotUrl}?${goCqHttpBotQq}`, {
|
||||||
`${goCqHttpBotUrl}?${goCqHttpBotQq}`,
|
timeout: this.timeout,
|
||||||
{
|
retry: 0,
|
||||||
timeout: this.timeout,
|
json: { message: `${this.title}\n${this.content}` },
|
||||||
retry: 0,
|
headers: { Authorization: 'Bearer ' + goCqHttpBotToken },
|
||||||
json: { message: `${this.title}\n${this.content}` },
|
})
|
||||||
headers: { 'Authorization': 'Bearer '+goCqHttpBotToken },
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.json();
|
.json();
|
||||||
return res.retcode === 0;
|
return res.retcode === 0;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +117,21 @@ export default class NotificationService {
|
||||||
return res.errno === 0 || res.data.errno === 0;
|
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() {
|
private async bark() {
|
||||||
let { barkPush, barkIcon, barkSound, barkGroup } = this.params;
|
let { barkPush, barkIcon, barkSound, barkGroup } = this.params;
|
||||||
if (!barkPush.startsWith('http') && !barkPush.startsWith('https')) {
|
if (!barkPush.startsWith('http') && !barkPush.startsWith('https')) {
|
||||||
|
|
|
@ -77,6 +77,7 @@ export default {
|
||||||
{ value: 'gotify', label: 'Gotify' },
|
{ value: 'gotify', label: 'Gotify' },
|
||||||
{ value: 'goCqHttpBot', label: 'GoCqHttpBot' },
|
{ value: 'goCqHttpBot', label: 'GoCqHttpBot' },
|
||||||
{ value: 'serverChan', label: 'Server酱' },
|
{ value: 'serverChan', label: 'Server酱' },
|
||||||
|
{ value: 'PushDeer', label: 'PushDeer' },
|
||||||
{ value: 'bark', label: 'Bark' },
|
{ value: 'bark', label: 'Bark' },
|
||||||
{ value: 'telegramBot', label: 'Telegram机器人' },
|
{ value: 'telegramBot', label: 'Telegram机器人' },
|
||||||
{ value: 'dingtalkBot', label: '钉钉机器人' },
|
{ value: 'dingtalkBot', label: '钉钉机器人' },
|
||||||
|
@ -113,6 +114,7 @@ export default {
|
||||||
serverChan: [
|
serverChan: [
|
||||||
{ label: 'serverChanKey', tip: 'Server酱SENDKEY', required: true },
|
{ label: 'serverChanKey', tip: 'Server酱SENDKEY', required: true },
|
||||||
],
|
],
|
||||||
|
PushDeer: [{ label: 'PushDeerKey', tip: 'PushDeer的Key', required: true }],
|
||||||
bark: [
|
bark: [
|
||||||
{
|
{
|
||||||
label: 'barkPush',
|
label: 'barkPush',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user