koishi-plugin-wordpress-notifier 2.8.1 → 2.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,22 +37,43 @@ npm install koishi-plugin-wordpress-notifier
37
37
 
38
38
  在 `koishi.yml` 中配置插件:
39
39
 
40
+ ### 多站点配置(推荐)
41
+
40
42
  ```yaml
41
43
  plugins:
42
44
  wordpress-notifier:
43
- wordpressUrl: 'https://your-wordpress-site.com' # WordPress 网站地址
44
- interval: 3600000 # 检查间隔(毫秒,默认 1 小时)
45
- targets:
46
- - '2801323326' # 推送目标(群号或 QQ 号)
47
- enableAutoPush: true # 是否启用自动推送
48
- enableUpdatePush: false # 是否启用文章更新推送
49
- enableUserPush: false # 是否启用新用户注册推送
50
- mentionAll: false # 是否 @全体成员
51
- maxArticles: 5 # 每次最多推送的文章数量
52
- # 可选:WordPress API 认证配置
53
- # 使用应用程序密码,更安全
54
- # username: 'your-wordpress-username'
55
- # applicationPassword: 'your-application-password' # 例如:hGR2 sPFu Yncl xHc4 AvJq cUtB
45
+ # 多站点配置
46
+ sites:
47
+ - id: 'blog' # 站点唯一标识
48
+ name: '博客站点' # 站点名称(用于显示)
49
+ url: 'https://your-wordpress-site.com' # WordPress 网站地址
50
+ interval: 3600000 # 检查间隔(毫秒,默认 1 小时)
51
+ targets: # 推送目标(群号或 QQ 号)
52
+ - '2801323326'
53
+ enableAutoPush: true # 是否启用自动推送
54
+ enableUpdatePush: false # 是否启用文章更新推送
55
+ enableUserPush: false # 是否启用新用户注册推送
56
+ mentionAll: false # 是否 @全体成员
57
+ maxArticles: 5 # 每次最多推送的文章数量
58
+ username: 'your-wordpress-username' # WordPress 用户名(用于 Basic 认证)
59
+ applicationPassword: 'your-application-password' # WordPress 应用程序密码
60
+ # 推送模板配置
61
+ pushTemplate:
62
+ showExcerpt: false # 是否显示摘要
63
+ dateFormat: 'YYYY-MM-DD HH:mm' # 日期格式
64
+ linkPosition: 'bottom' # 链接位置:top, bottom, none
65
+ showAuthor: false # 是否显示作者
66
+
67
+ # 超级管理员配置
68
+ superAdmins:
69
+ - '123456789' # 超级管理员 QQ 号
70
+
71
+ # 推送失败通知配置
72
+ failureNotification:
73
+ enable: true # 是否启用推送失败通知
74
+ threshold: 3 # 连续失败阈值,达到此值时发送通知
75
+ notificationTargets: # 通知目标(超级管理员 QQ 号),留空则使用 superAdmins
76
+ - '123456789'
56
77
  ```
57
78
 
58
79
  ### 如何获取WordPress应用程序密码
@@ -71,16 +92,29 @@ plugins:
71
92
 
72
93
  | 参数 | 类型 | 默认值 | 说明 |
73
94
  |------|------|--------|------|
74
- | `wordpressUrl` | string | 必填 | WordPress 网站地址(例如:https://example.com) |
75
- | `interval` | number | 3600000 | 检查间隔,单位毫秒(默认 1 小时 = 3600000 毫秒) |
76
- | `targets` | array | 必填 | 推送目标列表,可以是群号或 QQ 号 |
77
- | `enableAutoPush` | boolean | true | 是否启用自动推送 |
78
- | `enableUpdatePush` | boolean | false | 是否启用文章更新推送 |
79
- | `enableUserPush` | boolean | false | 是否启用新用户注册推送 |
80
- | `mentionAll` | boolean | false | 是否在推送时 @全体成员 |
81
- | `maxArticles` | number | 5 | 每次最多推送的文章数量 |
82
- | `username` | string | 可选 | WordPress 用户名(用于 Basic 基础认证,与应用程序密码配合使用) |
83
- | `applicationPassword` | string | 可选 | WordPress 应用程序密码(用于 Basic 基础认证,例如:hGR2sPFuYnclxHc4AvJqcUtB) |
95
+ | `sites` | array | 必填 | 多站点配置列表 |
96
+ | `sites[].id` | string | 必填 | 站点唯一标识(如 "blog"、"news" 等) |
97
+ | `sites[].name` | string | 必填 | 站点名称(用于显示) |
98
+ | `sites[].url` | string | 必填 | WordPress 网站地址(例如:https://example.com) |
99
+ | `sites[].interval` | number | 3600000 | 检查间隔,单位毫秒(默认 1 小时 = 3600000 毫秒) |
100
+ | `sites[].targets` | array | 必填 | 推送目标列表,可以是群号或 QQ 号 |
101
+ | `sites[].enableAutoPush` | boolean | true | 是否启用自动推送 |
102
+ | `sites[].enableUpdatePush` | boolean | false | 是否启用文章更新推送 |
103
+ | `sites[].enableUserPush` | boolean | false | 是否启用新用户注册推送 |
104
+ | `sites[].mentionAll` | boolean | false | 是否在推送时 @全体成员 |
105
+ | `sites[].maxArticles` | number | 5 | 每次最多推送的文章数量 |
106
+ | `sites[].username` | string | 可选 | WordPress 用户名(用于 Basic 基础认证,与应用程序密码配合使用) |
107
+ | `sites[].applicationPassword` | string | 可选 | WordPress 应用程序密码(用于 Basic 基础认证,例如:hGR2sPFuYnclxHc4AvJqcUtB) |
108
+ | `sites[].pushTemplate` | object | 必填 | 推送模板配置 |
109
+ | `sites[].pushTemplate.showExcerpt` | boolean | false | 是否显示摘要 |
110
+ | `sites[].pushTemplate.dateFormat` | string | 'YYYY-MM-DD HH:mm' | 日期格式 |
111
+ | `sites[].pushTemplate.linkPosition` | string | 'bottom' | 链接位置:top, bottom, none |
112
+ | `sites[].pushTemplate.showAuthor` | boolean | false | 是否显示作者 |
113
+ | `superAdmins` | array | [] | 超级管理员 QQ 号列表 |
114
+ | `failureNotification` | object | - | 推送失败通知配置 |
115
+ | `failureNotification.enable` | boolean | true | 是否启用推送失败通知 |
116
+ | `failureNotification.threshold` | number | 3 | 连续失败阈值,达到此值时发送通知 |
117
+ | `failureNotification.notificationTargets` | array | [] | 通知目标(超级管理员 QQ 号),留空则使用 superAdmins |
84
118
 
85
119
  ## 使用命令
86
120
 
@@ -116,45 +150,61 @@ plugins:
116
150
 
117
151
  显示当前插件配置状态,包括网站地址、检查间隔、推送目标等。
118
152
 
119
- ### 切换自动推送开关
153
+ ### 切换指定站点的自动推送开关
120
154
 
121
155
  ```
122
- /wordpress.toggle
156
+ /wordpress.site.toggle <siteId>
123
157
  ```
124
158
 
125
- 开启或关闭自动推送功能。
159
+ 开启或关闭指定站点的自动推送功能。
126
160
 
127
- ### 切换 @全体成员 开关
161
+ ### 切换指定站点的 @全体成员 开关
128
162
 
129
163
  ```
130
- /wordpress.mention
164
+ /wordpress.site.mention <siteId>
131
165
  ```
132
166
 
133
- 开启或关闭 @全体成员 功能。
167
+ 开启或关闭指定站点的 @全体成员 功能。
134
168
 
135
- ### 切换文章更新推送开关
169
+ ### 切换指定站点的文章更新推送开关
136
170
 
137
171
  ```
138
- /wordpress.toggle-update
172
+ /wordpress.site.toggle-update <siteId>
139
173
  ```
140
174
 
141
- 开启或关闭文章更新推送功能。
175
+ 开启或关闭指定站点的文章更新推送功能。
142
176
 
143
- ### 切换新用户注册推送开关
177
+ ### 切换指定站点的新用户注册推送开关
144
178
 
145
179
  ```
146
- /wordpress.toggle-user
180
+ /wordpress.site.toggle-user <siteId>
147
181
  ```
148
182
 
149
- 开启或关闭新用户注册推送功能。
183
+ 开启或关闭指定站点的新用户注册推送功能。
150
184
 
151
- ### 修改 WordPress 站点地址
185
+ ### 修改指定站点的 WordPress 地址
152
186
 
153
187
  ```
154
- /wordpress.set-url <url>
188
+ /wordpress.site.set-url <siteId> <url>
155
189
  ```
156
190
 
157
- 修改 WordPress 站点地址。
191
+ 修改指定站点的 WordPress 地址。
192
+
193
+ ### 查看插件运行指标统计
194
+
195
+ ```
196
+ /wordpress.stats
197
+ ```
198
+
199
+ 查看插件运行指标统计,包括 API 调用次数、推送成功率等。
200
+
201
+ ### 查看插件健康状态
202
+
203
+ ```
204
+ /wordpress.health
205
+ ```
206
+
207
+ 查看插件健康状态,包括数据库连接、API 可达性、Bot 在线状态等。
158
208
 
159
209
  ### 查看已推送文章列表
160
210
 
@@ -339,6 +389,30 @@ npm install
339
389
 
340
390
  ## 版本历史
341
391
 
392
+ ### 2.8.2 (2026-02-19)
393
+
394
+ - 🚀 全面升级插件功能,支持多站点管理和高级配置
395
+
396
+ **核心功能升级**
397
+ - ✅ 支持多站点配置,可同时监控多个 WordPress 站点
398
+ - ✅ 每个站点独立配置推送目标、推送模板和开关状态
399
+ - ✅ 支持自定义推送模板,可配置是否显示摘要、日期格式、链接位置等
400
+ - ✅ 新增推送失败通知功能,关键失败主动提醒超级管理员
401
+
402
+ **稳定性与安全**
403
+ - ✅ 实现 WordPress API 限流防护,避免触发 WordPress API 限流
404
+ - ✅ 添加数据库连接异常处理,自动检测连接状态并恢复
405
+ - ✅ 增强消息内容安全过滤,添加敏感词过滤逻辑
406
+
407
+ **运维与监控**
408
+ - ✅ 新增运行指标统计,支持查看 API 调用成功率、推送成功率等
409
+ - ✅ 新增健康状态检查命令,返回插件核心状态
410
+ - ✅ 优化日志记录,提供更详细的错误信息
411
+
412
+ **命令系统优化**
413
+ - ✅ 新增站点管理命令,支持按站点 ID 管理配置
414
+ - ✅ 保留原有命令的同时,添加更细粒度的站点控制命令
415
+
342
416
  ### 2.8.1 (2026-02-19)
343
417
 
344
418
  - 🐛 修复 MySQL 主键约束错误 (ER_PRIMARY_CANT_HAVE_NULL)
package/lib/index.d.ts CHANGED
@@ -6,16 +6,24 @@ declare module 'koishi' {
6
6
  wordpress_post_updates: WordPressPostUpdateRecord;
7
7
  wordpress_user_registrations: WordPressUserRegistrationRecord;
8
8
  wordpress_config: WordPressConfigRecord;
9
+ wordpress_version: WordPressVersionRecord;
9
10
  }
10
11
  }
12
+ export interface WordPressVersionRecord {
13
+ id: number;
14
+ version: string;
15
+ updatedAt: Date;
16
+ }
11
17
  export interface WordPressConfigRecord {
12
18
  id: number;
13
19
  key: string;
14
20
  value: string;
15
21
  updatedAt: Date;
16
22
  }
17
- export interface Config {
18
- wordpressUrl: string;
23
+ export interface WordPressSiteConfig {
24
+ id: string;
25
+ name: string;
26
+ url: string;
19
27
  interval: number;
20
28
  targets: string[];
21
29
  enableAutoPush: boolean;
@@ -25,7 +33,21 @@ export interface Config {
25
33
  maxArticles: number;
26
34
  username?: string;
27
35
  applicationPassword?: string;
36
+ pushTemplate: {
37
+ showExcerpt: boolean;
38
+ dateFormat: string;
39
+ linkPosition: 'top' | 'bottom' | 'none';
40
+ showAuthor: boolean;
41
+ };
42
+ }
43
+ export interface Config {
44
+ sites: WordPressSiteConfig[];
28
45
  superAdmins: string[];
46
+ failureNotification: {
47
+ enable: boolean;
48
+ threshold: number;
49
+ notificationTargets: string[];
50
+ };
29
51
  }
30
52
  export interface WordPressPost {
31
53
  id: number;
@@ -58,12 +80,14 @@ export interface WordPressUser {
58
80
  }
59
81
  export interface WordPressPostUpdateRecord {
60
82
  id: number;
83
+ siteId: string;
61
84
  postId: number;
62
85
  lastModified: Date;
63
86
  pushedAt: Date;
64
87
  }
65
88
  export interface WordPressUserRegistrationRecord {
66
89
  id: number;
90
+ siteId: string;
67
91
  userId: number;
68
92
  pushedAt: Date;
69
93
  }