diff --git a/back/data/notify.ts b/back/data/notify.ts
index b6e9fa7a..1bd001b7 100644
--- a/back/data/notify.ts
+++ b/back/data/notify.ts
@@ -21,6 +21,7 @@ export enum NotificationMode {
'webhook' = 'webhook',
'chronocat' = 'Chronocat',
'ntfy' = 'ntfy',
+ 'wxPusherBot' = 'wxPusherBot',
}
abstract class NotificationBaseInfo {
@@ -145,6 +146,13 @@ export class NtfyNotification extends NotificationBaseInfo {
public ntfyTopic = '';
public ntfyPriority = '';
}
+
+export class WxPusherBotNotification extends NotificationBaseInfo {
+ public wxPusherBotAppToken = '';
+ public wxPusherBotTopicIds = '';
+ public wxPusherBotUids = '';
+}
+
export interface NotificationInfo
extends GoCqHttpBotNotification,
GotifyNotification,
@@ -165,5 +173,5 @@ export interface NotificationInfo
WebhookNotification,
ChronocatNotification,
LarkNotification,
- NtfyNotification {}
-
+ NtfyNotification,
+ WxPusherBotNotification {}
diff --git a/back/services/notify.ts b/back/services/notify.ts
index e76ea30f..26990243 100644
--- a/back/services/notify.ts
+++ b/back/services/notify.ts
@@ -36,6 +36,7 @@ export default class NotificationService {
['lark', this.lark],
['chronocat', this.chronocat],
['ntfy', this.ntfy],
+ ['wxPusherBot', this.wxPusherBot],
]);
private title = '';
@@ -689,6 +690,51 @@ export default class NotificationService {
}
}
+ private async wxPusherBot() {
+ const { wxPusherBotAppToken, wxPusherBotTopicIds, wxPusherBotUids } = this.params;
+ // 处理 topicIds,将分号分隔的字符串转为数组
+ const topicIds = wxPusherBotTopicIds ? wxPusherBotTopicIds.split(';')
+ .map(id => id.trim())
+ .filter(id => id)
+ .map(id => parseInt(id)) : [];
+
+ // 处理 uids,将分号分隔的字符串转为数组
+ const uids = wxPusherBotUids ? wxPusherBotUids.split(';')
+ .map(uid => uid.trim())
+ .filter(uid => uid) : [];
+
+ // topic_ids 和 uids 至少要有一个
+ if (!topicIds.length && !uids.length) {
+ throw new Error('wxPusher 服务的 TopicIds 和 Uids 至少配置一个才行');
+ }
+
+ const url = `https://wxpusher.zjiecode.com/api/send/message`;
+ try {
+ const res: any = await got
+ .post(url, {
+ ...this.gotOption,
+ json: {
+ appToken: wxPusherBotAppToken,
+ content: `
${this.title}
${this.content}
`,
+ summary: this.title,
+ contentType: 2,
+ topicIds: topicIds,
+ uids: uids,
+ verifyPayType: 0
+ },
+ })
+ .json();
+
+ if (res.code === 1000) {
+ return true;
+ } else {
+ throw new Error(JSON.stringify(res));
+ }
+ } catch (error: any) {
+ throw new Error(error.response ? error.response.body : error);
+ }
+ }
+
private async chronocat() {
const { chronocatURL, chronocatQQ, chronocatToken } = this.params;
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index 9a6179ce..d37f9765 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -390,6 +390,9 @@
"自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口": "The self built PushMeServer message interface address, for example: http://127.0.0.1:3010 If left blank, use the official message interface",
"ntfy的url地址,例如 https://ntfy.sh'": "The URL address of ntfy, for example, https://ntfy.sh.",
"ntfy的消息应用topic": "The topic for ntfy's messaging application.",
+ "wxPusherBot的appToken": "wxPusherBot's appToken, obtain according to docs https://wxpusher.zjiecode.com/docs/",
+ "wxPusherBot的topicIds": "wxPusherBot's topicIds, at least one of topicIds or uids must be configured",
+ "wxPusherBot的uids": "wxPusherBot's uids, at least one of topicIds or uids must be configured",
"请求方法": "Request Method",
"请求头Content-Type": "Request Header Content-Type",
"请求链接以http或者https开头。url或者body中必须包含$title,$content可选,对应api内容的位置": "Request URL should start with http or https. URL or body must contain $title, $content is optional and corresponds to the API content position.",
diff --git a/src/locales/zh-CN.json b/src/locales/zh-CN.json
index bb440a32..b70fd84e 100644
--- a/src/locales/zh-CN.json
+++ b/src/locales/zh-CN.json
@@ -390,6 +390,9 @@
"自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口": "自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口",
"ntfy的url地址,例如 https://ntfy.sh": "ntfy的url地址,例如 https://ntfy.sh",
"ntfy的消息应用topic": "ntfy的消息应用topic",
+ "wxPusherBot的appToken": "wxPusherBot的appToken, 按照文档获取 https://wxpusher.zjiecode.com/docs/",
+ "wxPusherBot的topicIds": "wxPusherBot的topicIds, topicIds 和 uids 至少配置一个才行",
+ "wxPusherBot的uids": "wxPusherBot的uids, topicIds 和 uids 至少配置一个才行",
"请求方法": "请求方法",
"请求头Content-Type": "请求头Content-Type",
"请求链接以http或者https开头。url或者body中必须包含$title,$content可选,对应api内容的位置": "请求链接以http或者https开头。url或者body中必须包含$title,$content可选,对应api内容的位置",
diff --git a/src/utils/config.ts b/src/utils/config.ts
index a8f0b699..131941b8 100644
--- a/src/utils/config.ts
+++ b/src/utils/config.ts
@@ -97,6 +97,7 @@ export default {
{ value: 'iGot', label: 'IGot' },
{ value: 'pushPlus', label: 'PushPlus' },
{ value: 'wePlusBot', label: intl.get('微加机器人') },
+ { value: 'wxPusherBot', label: 'wxPusher' },
{ value: 'chat', label: intl.get('群晖chat') },
{ value: 'email', label: intl.get('邮箱') },
{ value: 'lark', label: intl.get('飞书机器人') },
@@ -348,6 +349,23 @@ export default {
),
},
],
+ wxPusherBot: [
+ {
+ label: 'wxPusherBotAppToken',
+ tip: intl.get('wxPusherBot的appToken'),
+ required: true,
+ },
+ {
+ label: 'wxPusherBotTopicIds',
+ tip: intl.get('wxPusherBot的topicIds'),
+ required: false,
+ },
+ {
+ label: 'wxPusherBotUids',
+ tip: intl.get('wxPusherBot的uids'),
+ required: false,
+ },
+ ],
lark: [
{
label: 'larkKey',