mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
系统通知增加gotify (#936)
This commit is contained in:
parent
1a1067966c
commit
f64c78919d
|
@ -1,4 +1,5 @@
|
||||||
export enum NotificationMode {
|
export enum NotificationMode {
|
||||||
|
'gotify' = 'gotify',
|
||||||
'goCqHttpBot' = 'goCqHttpBot',
|
'goCqHttpBot' = 'goCqHttpBot',
|
||||||
'serverChan' = 'serverChan',
|
'serverChan' = 'serverChan',
|
||||||
'bark' = 'bark',
|
'bark' = 'bark',
|
||||||
|
@ -15,6 +16,12 @@ abstract class NotificationBaseInfo {
|
||||||
public type!: NotificationMode;
|
public type!: NotificationMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class GotifyNotification extends NotificationBaseInfo {
|
||||||
|
public gotifyUrl = '';
|
||||||
|
public gotifyToken = '';
|
||||||
|
public gotifyPriority = 0;
|
||||||
|
}
|
||||||
|
|
||||||
export class GoCqHttpBotNotification extends NotificationBaseInfo {
|
export class GoCqHttpBotNotification extends NotificationBaseInfo {
|
||||||
public goCqHttpBotUrl = '';
|
public goCqHttpBotUrl = '';
|
||||||
public goCqHttpBotToken = '';
|
public goCqHttpBotToken = '';
|
||||||
|
@ -70,6 +77,7 @@ export class EmailNotification extends NotificationBaseInfo {
|
||||||
|
|
||||||
export interface NotificationInfo
|
export interface NotificationInfo
|
||||||
extends GoCqHttpBotNotification,
|
extends GoCqHttpBotNotification,
|
||||||
|
GotifyNotification,
|
||||||
ServerChanNotification,
|
ServerChanNotification,
|
||||||
BarkNotification,
|
BarkNotification,
|
||||||
TelegramBotNotification,
|
TelegramBotNotification,
|
||||||
|
|
|
@ -13,6 +13,7 @@ export default class NotificationService {
|
||||||
private userService!: UserService;
|
private userService!: UserService;
|
||||||
|
|
||||||
private modeMap = new Map([
|
private modeMap = new Map([
|
||||||
|
['gotify', this.gotify],
|
||||||
['goCqHttpBot', this.goCqHttpBot],
|
['goCqHttpBot', this.goCqHttpBot],
|
||||||
['serverChan', this.serverChan],
|
['serverChan', this.serverChan],
|
||||||
['bark', this.bark],
|
['bark', this.bark],
|
||||||
|
@ -67,6 +68,25 @@ export default class NotificationService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async gotify() {
|
||||||
|
const { gotifyUrl, gotifyToken, gotifyPriority } = this.params;
|
||||||
|
const res: any = await got
|
||||||
|
.post(`${gotifyUrl}/message?token=${gotifyToken}`, {
|
||||||
|
timeout: this.timeout,
|
||||||
|
retry: 0,
|
||||||
|
body: `title=${encodeURIComponent(
|
||||||
|
this.title,
|
||||||
|
)}&message=${encodeURIComponent(
|
||||||
|
this.content,
|
||||||
|
)}&priority=${gotifyPriority}`,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.json();
|
||||||
|
return typeof res.id === 'number';
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -112,4 +112,12 @@ export GOBOT_URL=""
|
||||||
export GOBOT_TOKEN=""
|
export GOBOT_TOKEN=""
|
||||||
export GOBOT_QQ=""
|
export GOBOT_QQ=""
|
||||||
|
|
||||||
|
## 10. gotify
|
||||||
|
## gotify_url 填写gotify地址,如https://push.example.de:8080
|
||||||
|
## gotify_token 填写gotify的消息应用token
|
||||||
|
## gotify_priority 填写推送消息优先级,默认为0
|
||||||
|
export GOTIFY_URL="";
|
||||||
|
export GOTIFY_TOKEN="";
|
||||||
|
export GOTIFY_PRIORITY=0;
|
||||||
|
|
||||||
## 其他需要的变量,脚本中需要的变量使用 export 变量名= 声明即可
|
## 其他需要的变量,脚本中需要的变量使用 export 变量名= 声明即可
|
||||||
|
|
Loading…
Reference in New Issue
Block a user