mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-15 19:57:07 +08:00
feat: add WPUSH notification provider (#3066)
Add WPUSH as a notification channel for Qinglong panel settings and sample notify scripts (Python/JS), using POST https://api.wpush.cn/api/v1/send with success code === 0. Supports optional channel and topic_code.
This commit is contained in:
+9
-1
@@ -21,6 +21,7 @@ export enum NotificationMode {
|
||||
'ntfy' = 'ntfy',
|
||||
'wxPusherBot' = 'wxPusherBot',
|
||||
'openiLink' = 'openiLink',
|
||||
'wpush' = 'wpush',
|
||||
}
|
||||
|
||||
abstract class NotificationBaseInfo {
|
||||
@@ -172,6 +173,12 @@ export class OpeniLinkNotification extends NotificationBaseInfo {
|
||||
public openiLinkContextToken = '';
|
||||
}
|
||||
|
||||
export class WpushNotification extends NotificationBaseInfo {
|
||||
public wpushApiKey = '';
|
||||
public wpushChannel = '';
|
||||
public wpushTopicCode = '';
|
||||
}
|
||||
|
||||
export interface NotificationInfo
|
||||
extends GoCqHttpBotNotification,
|
||||
GotifyNotification,
|
||||
@@ -195,4 +202,5 @@ export interface NotificationInfo
|
||||
NtfyNotification,
|
||||
WxPusherBotNotification,
|
||||
WxPusherSptNotification,
|
||||
OpeniLinkNotification {}
|
||||
OpeniLinkNotification,
|
||||
WpushNotification {}
|
||||
|
||||
@@ -37,6 +37,7 @@ export default class NotificationService {
|
||||
['wxPusherBot', this.wxPusherBot],
|
||||
['wxPusherSpt', this.wxPusherSpt],
|
||||
['openiLink', this.openiLink],
|
||||
['wpush', this.wpush],
|
||||
]);
|
||||
|
||||
private title = '';
|
||||
@@ -947,4 +948,31 @@ export default class NotificationService {
|
||||
throw new Error(error.response ? error.response.body : error);
|
||||
}
|
||||
}
|
||||
private async wpush() {
|
||||
const { wpushApiKey, wpushChannel, wpushTopicCode } = this.params;
|
||||
const url = 'https://api.wpush.cn/api/v1/send';
|
||||
const json: Record<string, string> = {
|
||||
apikey: `${wpushApiKey}`,
|
||||
title: `${this.title}`,
|
||||
content: `${this.content}`,
|
||||
channel: `${wpushChannel || 'wechat'}`,
|
||||
};
|
||||
if (wpushTopicCode) {
|
||||
json.topic_code = `${wpushTopicCode}`;
|
||||
}
|
||||
try {
|
||||
const res = await httpClient.post(url, {
|
||||
...this.gotOption,
|
||||
json,
|
||||
});
|
||||
if (res.code === 0) {
|
||||
return true;
|
||||
} else {
|
||||
throw new Error(JSON.stringify(res));
|
||||
}
|
||||
} catch (error: any) {
|
||||
throw new Error(error.response ? error.response.body : error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user