koishi-plugin-wordpress-notifier 2.8.0 → 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 +127 -38
- package/lib/index.d.ts +26 -2
- package/lib/index.js +839 -266
- 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
|
+
### 切换指定站点的 @全体成员 开关
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
/wordpress.site.mention <siteId>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
开启或关闭指定站点的 @全体成员 功能。
|
|
168
|
+
|
|
169
|
+
### 切换指定站点的文章更新推送开关
|
|
120
170
|
|
|
121
171
|
```
|
|
122
|
-
/wordpress.toggle
|
|
172
|
+
/wordpress.site.toggle-update <siteId>
|
|
123
173
|
```
|
|
124
174
|
|
|
125
|
-
|
|
175
|
+
开启或关闭指定站点的文章更新推送功能。
|
|
126
176
|
|
|
127
|
-
###
|
|
177
|
+
### 切换指定站点的新用户注册推送开关
|
|
128
178
|
|
|
129
179
|
```
|
|
130
|
-
/wordpress.
|
|
180
|
+
/wordpress.site.toggle-user <siteId>
|
|
131
181
|
```
|
|
132
182
|
|
|
133
|
-
|
|
183
|
+
开启或关闭指定站点的新用户注册推送功能。
|
|
134
184
|
|
|
135
|
-
###
|
|
185
|
+
### 修改指定站点的 WordPress 地址
|
|
136
186
|
|
|
137
187
|
```
|
|
138
|
-
/wordpress.
|
|
188
|
+
/wordpress.site.set-url <siteId> <url>
|
|
139
189
|
```
|
|
140
190
|
|
|
141
|
-
|
|
191
|
+
修改指定站点的 WordPress 地址。
|
|
142
192
|
|
|
143
|
-
###
|
|
193
|
+
### 查看插件运行指标统计
|
|
144
194
|
|
|
145
195
|
```
|
|
146
|
-
/wordpress.
|
|
196
|
+
/wordpress.stats
|
|
147
197
|
```
|
|
148
198
|
|
|
149
|
-
|
|
199
|
+
查看插件运行指标统计,包括 API 调用次数、推送成功率等。
|
|
150
200
|
|
|
151
|
-
###
|
|
201
|
+
### 查看插件健康状态
|
|
152
202
|
|
|
153
203
|
```
|
|
154
|
-
/wordpress.
|
|
204
|
+
/wordpress.health
|
|
155
205
|
```
|
|
156
206
|
|
|
157
|
-
|
|
207
|
+
查看插件健康状态,包括数据库连接、API 可达性、Bot 在线状态等。
|
|
158
208
|
|
|
159
209
|
### 查看已推送文章列表
|
|
160
210
|
|
|
@@ -339,6 +389,45 @@ 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
|
+
|
|
416
|
+
### 2.8.1 (2026-02-19)
|
|
417
|
+
|
|
418
|
+
- 🐛 修复 MySQL 主键约束错误 (ER_PRIMARY_CANT_HAVE_NULL)
|
|
419
|
+
|
|
420
|
+
**核心修复**
|
|
421
|
+
- ✅ 增强 `checkAndFixTableStructure` 函数,添加表结构自动修复机制
|
|
422
|
+
- ✅ 当表结构不正确时,自动删除旧表并重新初始化,确保主键约束正确设置
|
|
423
|
+
- ✅ 为 `wordpress_post_updates`、`wordpress_user_registrations` 和 `wordpress_config` 表添加自动修复逻辑
|
|
424
|
+
- ✅ 优化 `loadPersistentConfig` 函数,添加更详细的错误处理,确保即使数据库操作失败也能继续运行
|
|
425
|
+
- ✅ 修改 `updatePostUpdateRecord` 函数,移除错误抛出,确保推送流程不会被数据库操作失败中断
|
|
426
|
+
|
|
427
|
+
**稳定性提升**
|
|
428
|
+
- ✅ 增加数据库操作的容错能力,提高插件在各种环境下的稳定性
|
|
429
|
+
- ✅ 优化错误日志记录,提供更详细的错误信息,便于排查问题
|
|
430
|
+
|
|
342
431
|
### 2.8.0 (2026-02-18)
|
|
343
432
|
|
|
344
433
|
- 🚀 全面优化插件稳定性、性能和功能完整性
|
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
|
}
|