koishi-plugin-wordpress-notifier 1.6.0 → 1.7.1
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 +83 -43
- package/lib/index.d.ts +16 -0
- package/lib/index.js +67 -0
- package/package.json +2 -5
package/README.md
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
自动从 WordPress 网站获取最新文章并推送到指定 QQ 群或私聊。
|
|
4
4
|
|
|
5
|
-
## 功能特性
|
|
6
|
-
|
|
7
|
-
- ✅ 自动从 WordPress REST API 获取最新文章
|
|
8
|
-
- ✅ 定时推送新文章到指定 QQ 群或私聊
|
|
9
|
-
- ✅ 支持手动查询最新文章和文章列表
|
|
10
|
-
- ✅
|
|
11
|
-
- ✅
|
|
12
|
-
- ✅
|
|
13
|
-
- ✅
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 自动从 WordPress REST API 获取最新文章
|
|
8
|
+
- ✅ 定时推送新文章到指定 QQ 群或私聊
|
|
9
|
+
- ✅ 支持手动查询最新文章和文章列表
|
|
10
|
+
- ✅ 支持查询 WordPress 站点用户信息
|
|
11
|
+
- ✅ 支持 @全体成员
|
|
12
|
+
- ✅ 完善的去重机制,避免重复推送
|
|
13
|
+
- ✅ 数据库持久化存储,机器人重启不丢失记录
|
|
14
|
+
- ✅ 采用服务模式架构,便于扩展和维护
|
|
14
15
|
- ✅ 支持自动推送开关
|
|
15
16
|
|
|
16
17
|
## 安装
|
|
@@ -97,14 +98,30 @@ plugins:
|
|
|
97
98
|
|
|
98
99
|
开启或关闭自动推送功能。
|
|
99
100
|
|
|
100
|
-
### 切换 @全体成员 开关
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
/wordpress.mention
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
开启或关闭 @全体成员 功能。
|
|
107
|
-
|
|
101
|
+
### 切换 @全体成员 开关
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
/wordpress.mention
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
开启或关闭 @全体成员 功能。
|
|
108
|
+
|
|
109
|
+
### 查看站点用户列表
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
/wordpress.users
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
显示 WordPress 站点的所有用户列表,包含用户 ID、名称、角色和个人主页链接。
|
|
116
|
+
|
|
117
|
+
### 查看特定用户信息
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
/wordpress.user <id>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
显示指定 ID 用户的详细信息,包括用户 ID、昵称、角色、个人主页、注册时间和个人简介。
|
|
124
|
+
|
|
108
125
|
### 插件菜单
|
|
109
126
|
|
|
110
127
|
```
|
|
@@ -204,32 +221,55 @@ cd external/wordpress-notifier
|
|
|
204
221
|
npm install
|
|
205
222
|
```
|
|
206
223
|
|
|
207
|
-
## 版本历史
|
|
208
|
-
|
|
209
|
-
### 1.
|
|
210
|
-
|
|
211
|
-
-
|
|
212
|
-
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
-
|
|
218
|
-
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
- 🐛
|
|
225
|
-
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
-
|
|
231
|
-
|
|
232
|
-
|
|
224
|
+
## 版本历史
|
|
225
|
+
|
|
226
|
+
### 1.7.1 (2026-01-19)
|
|
227
|
+
|
|
228
|
+
- 🐛 修复用户查询功能中 roles 字段为 undefined 的错误
|
|
229
|
+
- 📝 更新 README.md 文档,添加用户查询功能说明
|
|
230
|
+
|
|
231
|
+
### 1.7.0 (2026-01-19)
|
|
232
|
+
|
|
233
|
+
- ✨ 新增查询 WordPress 站点用户信息功能
|
|
234
|
+
- ✅ 添加 `/wordpress.users` 命令,查看站点用户列表
|
|
235
|
+
- ✅ 添加 `/wordpress.user <id>` 命令,查看特定用户信息
|
|
236
|
+
- 📝 更新主菜单,添加新命令选项
|
|
237
|
+
- 🔧 优化数据库表定义
|
|
238
|
+
|
|
239
|
+
### 1.6.0 (2026-01-15)
|
|
240
|
+
|
|
241
|
+
- 🐛 修复消息发送问题,使用 `bot.sendMessage` 替代 `broadcast`
|
|
242
|
+
- 🔧 优化消息发送逻辑
|
|
243
|
+
|
|
244
|
+
### 1.5.0 (2026-01-15)
|
|
245
|
+
|
|
246
|
+
- 🐛 修复数据库主键问题,添加 `id` 字段作为主键
|
|
247
|
+
- 🔧 优化数据库表结构
|
|
248
|
+
|
|
249
|
+
### 1.3.0 (2024-01-14)
|
|
250
|
+
|
|
251
|
+
- 📝 更新作者邮箱为 kate522@88.com
|
|
252
|
+
- 🔗 更新仓库地址为正确的 GitHub URL
|
|
253
|
+
- 📝 优化 README.md 文档和链接
|
|
254
|
+
|
|
255
|
+
### 1.2.0 (2024-01-14)
|
|
256
|
+
|
|
257
|
+
- 📝 优化 README.md 文档,添加详细的安装说明和常见问题
|
|
258
|
+
- 📦 优化 npm 包结构,只包含必要文件
|
|
259
|
+
|
|
260
|
+
### 1.1.0 (2024-01-14)
|
|
261
|
+
|
|
262
|
+
- ✨ 新增数据库持久化存储功能
|
|
263
|
+
- 🐛 修复推送目标配置问题,使用 `ctx.broadcast([target], message)` 正确发送到指定目标
|
|
264
|
+
- 🐛 修复 HTTP 服务注入问题,添加 `'http'` 到 inject 数组
|
|
265
|
+
- 📝 添加 `.npmignore` 文件,确保 npm 发布时只包含必要文件
|
|
266
|
+
- 📦 更新依赖项
|
|
267
|
+
|
|
268
|
+
### 1.0.0 (初始版本)
|
|
269
|
+
|
|
270
|
+
- 🎉 首次发布
|
|
271
|
+
- ✅ 基础推送功能
|
|
272
|
+
- ✅ 命令系统
|
|
233
273
|
- ✅ 去重机制
|
|
234
274
|
|
|
235
275
|
## 许可证
|
package/lib/index.d.ts
CHANGED
|
@@ -28,6 +28,22 @@ export interface WordPressPost {
|
|
|
28
28
|
categories: number[];
|
|
29
29
|
tags: number[];
|
|
30
30
|
}
|
|
31
|
+
export interface WordPressUser {
|
|
32
|
+
id: number;
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
link: string;
|
|
36
|
+
avatar_urls: {
|
|
37
|
+
'24': string;
|
|
38
|
+
'48': string;
|
|
39
|
+
'96': string;
|
|
40
|
+
};
|
|
41
|
+
registered_date?: string;
|
|
42
|
+
roles?: string[];
|
|
43
|
+
slug?: string;
|
|
44
|
+
url?: string;
|
|
45
|
+
meta?: any[];
|
|
46
|
+
}
|
|
31
47
|
export interface WordPressPostRecord {
|
|
32
48
|
id: number;
|
|
33
49
|
postId: number;
|
package/lib/index.js
CHANGED
|
@@ -33,6 +33,31 @@ function apply(ctx, config) {
|
|
|
33
33
|
return [];
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
async function fetchUsers() {
|
|
37
|
+
try {
|
|
38
|
+
const url = `${config.wordpressUrl}/wp-json/wp/v2/users`;
|
|
39
|
+
ctx.logger.info(`正在获取用户信息: ${url}`);
|
|
40
|
+
const response = await ctx.http.get(url);
|
|
41
|
+
ctx.logger.info(`成功获取 ${response.length} 个用户`);
|
|
42
|
+
return response;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
ctx.logger.error(`获取 WordPress 用户信息失败: ${error}`);
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function fetchUserById(userId) {
|
|
50
|
+
try {
|
|
51
|
+
const url = `${config.wordpressUrl}/wp-json/wp/v2/users/${userId}`;
|
|
52
|
+
ctx.logger.info(`正在获取用户信息: ${url}`);
|
|
53
|
+
const response = await ctx.http.get(url);
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
ctx.logger.error(`获取 WordPress 用户信息失败: ${error}`);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
36
61
|
async function isPostPushed(postId) {
|
|
37
62
|
const record = await ctx.database.get('wordpress_posts', { postId });
|
|
38
63
|
return record.length > 0;
|
|
@@ -117,6 +142,46 @@ function apply(ctx, config) {
|
|
|
117
142
|
}
|
|
118
143
|
return message;
|
|
119
144
|
});
|
|
145
|
+
ctx.command('wordpress.users', '查看站点用户列表')
|
|
146
|
+
.action(async () => {
|
|
147
|
+
ctx.logger.info('命令 wordpress.users 被调用');
|
|
148
|
+
const users = await fetchUsers();
|
|
149
|
+
if (users.length === 0) {
|
|
150
|
+
return '暂无用户信息';
|
|
151
|
+
}
|
|
152
|
+
let message = '👥 WordPress 站点用户列表:\n\n';
|
|
153
|
+
for (const user of users) {
|
|
154
|
+
const roles = user.roles || [];
|
|
155
|
+
message += `${user.id}. ${user.name}(${roles.join(', ') || '普通用户'})\n`;
|
|
156
|
+
message += `🔗 ${user.link}\n\n`;
|
|
157
|
+
}
|
|
158
|
+
return message;
|
|
159
|
+
});
|
|
160
|
+
ctx.command('wordpress.user <id>', '查看特定用户信息')
|
|
161
|
+
.action(async ({}, userId) => {
|
|
162
|
+
ctx.logger.info(`命令 wordpress.user 被调用,用户 ID:${userId}`);
|
|
163
|
+
const id = parseInt(userId);
|
|
164
|
+
if (isNaN(id)) {
|
|
165
|
+
return '请输入有效的用户 ID';
|
|
166
|
+
}
|
|
167
|
+
const user = await fetchUserById(id);
|
|
168
|
+
if (!user) {
|
|
169
|
+
return `未找到 ID 为 ${id} 的用户`;
|
|
170
|
+
}
|
|
171
|
+
let message = `👤 用户信息:\n\n`;
|
|
172
|
+
message += `ID: ${user.id}\n`;
|
|
173
|
+
message += `昵称: ${user.name}\n`;
|
|
174
|
+
const roles = user.roles || [];
|
|
175
|
+
message += `角色: ${roles.join(', ') || '普通用户'}\n`;
|
|
176
|
+
message += `个人主页: ${user.link}\n`;
|
|
177
|
+
if (user.description) {
|
|
178
|
+
message += `简介: ${user.description.replace(/<[^>]*>/g, '')}\n`;
|
|
179
|
+
}
|
|
180
|
+
if (user.registered_date) {
|
|
181
|
+
message += `注册时间: ${new Date(user.registered_date).toLocaleString('zh-CN')}\n`;
|
|
182
|
+
}
|
|
183
|
+
return message;
|
|
184
|
+
});
|
|
120
185
|
ctx.command('wordpress.push', '手动推送最新文章')
|
|
121
186
|
.action(async () => {
|
|
122
187
|
ctx.logger.info('命令 wordpress.push 被调用');
|
|
@@ -154,6 +219,8 @@ function apply(ctx, config) {
|
|
|
154
219
|
🔹 /wordpress.status - 查看插件状态
|
|
155
220
|
🔹 /wordpress.latest - 查看最新文章
|
|
156
221
|
🔹 /wordpress.list - 查看文章列表
|
|
222
|
+
🔹 /wordpress.users - 查看站点用户列表
|
|
223
|
+
🔹 /wordpress.user <id> - 查看特定用户信息
|
|
157
224
|
🔹 /wordpress.push - 手动推送最新文章
|
|
158
225
|
🔹 /wordpress.toggle - 切换自动推送开关
|
|
159
226
|
🔹 /wordpress.mention - 切换 @全体成员 开关
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-wordpress-notifier",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "WordPress 文章自动推送到 QQ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -32,10 +32,7 @@
|
|
|
32
32
|
"notifier",
|
|
33
33
|
"qq"
|
|
34
34
|
],
|
|
35
|
-
"repository":
|
|
36
|
-
"type": "git",
|
|
37
|
-
"url": "https://github.com/Lexo0522/koishi-plugin-wordpress-notifier.git"
|
|
38
|
-
},
|
|
35
|
+
"repository": "git+https://github.com/Lexo0522/koishi-plugin-wordpress-notifier.git",
|
|
39
36
|
"homepage": "https://github.com/Lexo0522/koishi-plugin-wordpress-notifier#readme",
|
|
40
37
|
"bugs": {
|
|
41
38
|
"url": "https://github.com/Lexo0522/koishi-plugin-wordpress-notifier/issues"
|