koishi-plugin-wordpress-notifier 2.8.1 → 2.8.3
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 +126 -38
- package/lib/index.d.ts +26 -2
- package/lib/index.js +762 -264
- package/package.json +1 -1
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
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
|
+
### 切换指定站点的自动推送开关
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
/wordpress.site.toggle <siteId>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
开启或关闭指定站点的自动推送功能。
|
|
160
|
+
|
|
161
|
+
### 切换指定站点的 @全体成员 开关
|
|
120
162
|
|
|
121
163
|
```
|
|
122
|
-
/wordpress.
|
|
164
|
+
/wordpress.site.mention <siteId>
|
|
123
165
|
```
|
|
124
166
|
|
|
125
|
-
|
|
167
|
+
开启或关闭指定站点的 @全体成员 功能。
|
|
126
168
|
|
|
127
|
-
###
|
|
169
|
+
### 切换指定站点的文章更新推送开关
|
|
128
170
|
|
|
129
171
|
```
|
|
130
|
-
/wordpress.
|
|
172
|
+
/wordpress.site.toggle-update <siteId>
|
|
131
173
|
```
|
|
132
174
|
|
|
133
|
-
|
|
175
|
+
开启或关闭指定站点的文章更新推送功能。
|
|
134
176
|
|
|
135
|
-
###
|
|
177
|
+
### 切换指定站点的新用户注册推送开关
|
|
136
178
|
|
|
137
179
|
```
|
|
138
|
-
/wordpress.toggle-
|
|
180
|
+
/wordpress.site.toggle-user <siteId>
|
|
139
181
|
```
|
|
140
182
|
|
|
141
|
-
|
|
183
|
+
开启或关闭指定站点的新用户注册推送功能。
|
|
142
184
|
|
|
143
|
-
###
|
|
185
|
+
### 修改指定站点的 WordPress 地址
|
|
144
186
|
|
|
145
187
|
```
|
|
146
|
-
/wordpress.
|
|
188
|
+
/wordpress.site.set-url <siteId> <url>
|
|
147
189
|
```
|
|
148
190
|
|
|
149
|
-
|
|
191
|
+
修改指定站点的 WordPress 地址。
|
|
150
192
|
|
|
151
|
-
###
|
|
193
|
+
### 查看插件运行指标统计
|
|
152
194
|
|
|
153
195
|
```
|
|
154
|
-
/wordpress.
|
|
196
|
+
/wordpress.stats
|
|
155
197
|
```
|
|
156
198
|
|
|
157
|
-
|
|
199
|
+
查看插件运行指标统计,包括 API 调用次数、推送成功率等。
|
|
200
|
+
|
|
201
|
+
### 查看插件健康状态
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
/wordpress.health
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
查看插件健康状态,包括数据库连接、API 可达性、Bot 在线状态等。
|
|
158
208
|
|
|
159
209
|
### 查看已推送文章列表
|
|
160
210
|
|
|
@@ -339,6 +389,44 @@ npm install
|
|
|
339
389
|
|
|
340
390
|
## 版本历史
|
|
341
391
|
|
|
392
|
+
### 2.8.3 (2026-02-19)
|
|
393
|
+
|
|
394
|
+
- 🐛 修复数据库表结构初始化问题
|
|
395
|
+
|
|
396
|
+
**核心修复**
|
|
397
|
+
- ✅ 修复 `checkAndFixTableStructure` 函数中的表结构重新初始化逻辑
|
|
398
|
+
- ✅ 确保 `wordpress_post_updates` 表重新初始化时包含 `siteId` 字段,并且唯一约束为 `['siteId', 'postId']`
|
|
399
|
+
- ✅ 确保 `wordpress_user_registrations` 表重新初始化时包含 `siteId` 字段,并且唯一约束为 `['siteId', 'userId']`
|
|
400
|
+
- ✅ 解决了多站点模式下唯一约束失败的问题
|
|
401
|
+
|
|
402
|
+
**稳定性提升**
|
|
403
|
+
- ✅ 提高了插件在数据库表结构异常情况下的恢复能力
|
|
404
|
+
- ✅ 确保表结构重新初始化时与当前代码版本保持一致
|
|
405
|
+
|
|
406
|
+
### 2.8.2 (2026-02-19)
|
|
407
|
+
|
|
408
|
+
- 🚀 全面升级插件功能,支持多站点管理和高级配置
|
|
409
|
+
|
|
410
|
+
**核心功能升级**
|
|
411
|
+
- ✅ 支持多站点配置,可同时监控多个 WordPress 站点
|
|
412
|
+
- ✅ 每个站点独立配置推送目标、推送模板和开关状态
|
|
413
|
+
- ✅ 支持自定义推送模板,可配置是否显示摘要、日期格式、链接位置等
|
|
414
|
+
- ✅ 新增推送失败通知功能,关键失败主动提醒超级管理员
|
|
415
|
+
|
|
416
|
+
**稳定性与安全**
|
|
417
|
+
- ✅ 实现 WordPress API 限流防护,避免触发 WordPress API 限流
|
|
418
|
+
- ✅ 添加数据库连接异常处理,自动检测连接状态并恢复
|
|
419
|
+
- ✅ 增强消息内容安全过滤,添加敏感词过滤逻辑
|
|
420
|
+
|
|
421
|
+
**运维与监控**
|
|
422
|
+
- ✅ 新增运行指标统计,支持查看 API 调用成功率、推送成功率等
|
|
423
|
+
- ✅ 新增健康状态检查命令,返回插件核心状态
|
|
424
|
+
- ✅ 优化日志记录,提供更详细的错误信息
|
|
425
|
+
|
|
426
|
+
**命令系统优化**
|
|
427
|
+
- ✅ 新增站点管理命令,支持按站点 ID 管理配置
|
|
428
|
+
- ✅ 保留原有命令的同时,添加更细粒度的站点控制命令
|
|
429
|
+
|
|
342
430
|
### 2.8.1 (2026-02-19)
|
|
343
431
|
|
|
344
432
|
- 🐛 修复 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
|
|
18
|
-
|
|
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
|
}
|