@wecode-ai/weibo-openclaw-plugin 2.2.12 → 2.2.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wecode-ai/weibo-openclaw-plugin",
3
- "version": "2.2.12",
3
+ "version": "2.2.13",
4
4
  "type": "module",
5
5
  "description": "OpenClaw Weibo DM channel plugin",
6
6
  "license": "MIT",
@@ -5,6 +5,7 @@
5
5
  "weibo-cron": "1.0.4",
6
6
  "weibo-crowd": "1.0.6",
7
7
  "weibo-hot-search": "1.0.0",
8
+ "weibo-interactive": "1.0.0",
8
9
  "weibo-pic": "1.0.0",
9
10
  "weibo-search": "1.0.0",
10
11
  "weibo-status": "1.0.1",
@@ -0,0 +1,308 @@
1
+ ---
2
+ name: weibo-interactive
3
+ description: |
4
+ 微博互动内容分析工具。获取收到的评论列表、获取自己某条微博的所有评论,
5
+ 并提供互动回复建议分析能力,根据关注关系和认证状态筛选最值得回复的评论。
6
+ 当用户需要查看收到的评论、自己某条微博的评论详情时激活;
7
+ 或当用户询问哪些评论值得回复、如何优先回复粉丝评论、互动建议时激活。
8
+ metadata:
9
+ version: "1.0.0"
10
+ ---
11
+
12
+ # 微博互动内容分析工具
13
+
14
+ 帮助博主发现最值得回复的评论,促进与粉丝之间的真实互动。通过分析评论者的关注关系和认证状态,智能排序推荐优先回复的评论,让每一次互动都更有价值。
15
+
16
+ ## 脚本调用方式
17
+
18
+ ### 获取收到的评论列表
19
+
20
+ ```bash
21
+ node scripts/weibo-interactive.js comments-to-me --token=<token> --uid=<uid>
22
+ ```
23
+
24
+ ### 获取自己某条微博的所有评论
25
+
26
+ ```bash
27
+ node scripts/weibo-interactive.js comments-show --token=<token> --uid=<uid> --id=<weibo_id>
28
+ ```
29
+
30
+ **参数说明**:
31
+
32
+ | 参数 | 必填 | 说明 |
33
+ |------|------|------|
34
+ | `--token` | 是 | 微博 API 访问令牌,通过 `weibo_token` 工具获取 |
35
+ | `--uid` | 是 | 用户 uid |
36
+ | `--id` | comments-show 必填 | 微博 ID(博文 ID) |
37
+
38
+ ---
39
+
40
+ ## 返回数据结构
41
+
42
+ ### 1. 收到的评论列表
43
+
44
+ 接口路径:`GET /open/interactive/comments/to_me`
45
+
46
+ 返回的 `data` 字段包含以下内容:
47
+
48
+ #### `data.comments` — 评论列表(数组)
49
+
50
+ | 字段 | 类型 | 说明 |
51
+ |------|------|------|
52
+ | `createdAt` | string | 评论创建时间(如 "Mon Jun 15 16:14:47 +0800 2026") |
53
+ | `id` | string | 评论 ID |
54
+ | `mid` | string | 评论 mid |
55
+ | `postJumpLink` | string | 原博跳转链接(如 "https://weibo.com/1985772915/5305687166161572") |
56
+ | `text` | string | 评论内容 |
57
+ | `user` | object | 评论用户信息(见下表) |
58
+
59
+ #### `data.comments[].user` — 评论用户信息
60
+
61
+ | 字段 | 类型 | 说明 |
62
+ |------|------|------|
63
+ | `followMe` | boolean | 是否是我的粉丝(true=该用户关注了我) |
64
+ | `following` | boolean | 是否我关注了该用户(true=我关注了该用户) |
65
+ | `id` | string | 用户 ID |
66
+ | `name` | string | 用户昵称 |
67
+ | `verified` | boolean | 是否认证用户(true=认证用户,可能是大V) |
68
+
69
+ #### `data.count` — 评论总数
70
+
71
+ | 字段 | 类型 | 说明 |
72
+ |------|------|------|
73
+ | `count` | number | 评论总数 |
74
+
75
+ #### `data.msg` — 查询结果消息
76
+
77
+ | 字段 | 类型 | 说明 |
78
+ |------|------|------|
79
+ | `msg` | string | 查询结果消息(如 "查询成功") |
80
+
81
+ ---
82
+
83
+ ### 2. 自己某条微博的所有评论
84
+
85
+ 接口路径:`GET /open/interactive/comments/show`
86
+
87
+ 返回结构与"收到的评论列表"一致,区别在于返回的是自己指定微博 ID 下的所有评论。
88
+
89
+ #### `data.comments` — 该微博的评论列表(数组)
90
+
91
+ 结构与"收到的评论列表"中的 `data.comments` 相同。
92
+
93
+ ---
94
+
95
+ ## 使用示例
96
+
97
+ ```bash
98
+ # 获取收到的评论列表
99
+ node scripts/weibo-interactive.js comments-to-me --token=<your_token> --uid=<your_uid>
100
+
101
+ # 获取自己某条微博的所有评论
102
+ node scripts/weibo-interactive.js comments-show --token=<your_token> --uid=<your_uid> --id=<weibo_id>
103
+
104
+ # 查看帮助
105
+ node scripts/weibo-interactive.js help
106
+ ```
107
+
108
+ 返回示例(comments-to-me):
109
+
110
+ ```json
111
+ {
112
+ "code": 0,
113
+ "data": {
114
+ "code": 0,
115
+ "comments": [
116
+ {
117
+ "createdAt": "Mon Jun 15 16:14:47 +0800 2026",
118
+ "id": "5310105566577890",
119
+ "mid": "5310105566577890",
120
+ "postJumpLink": "https://weibo.com/<uid>/<mid>",
121
+ "text": "评论内容...",
122
+ "user": {
123
+ "followMe": false,
124
+ "following": false,
125
+ "id": "用户ID",
126
+ "name": "用户昵称",
127
+ "verified": false
128
+ }
129
+ }
130
+ ],
131
+ "count": 1,
132
+ "msg": "查询成功"
133
+ },
134
+ "message": "success"
135
+ }
136
+ ```
137
+
138
+ 返回示例(comments-show):
139
+
140
+ ```json
141
+ {
142
+ "code": 0,
143
+ "data": {
144
+ "code": 0,
145
+ "comments": [
146
+ {
147
+ "createdAt": "Mon Jun 15 16:14:47 +0800 2026",
148
+ "id": "5310105566577890",
149
+ "mid": "5310105566577890",
150
+ "postJumpLink": "https://weibo.com/<uid>/<mid>",
151
+ "text": "评论内容...",
152
+ "user": {
153
+ "followMe": true,
154
+ "following": false,
155
+ "id": "用户ID",
156
+ "name": "用户昵称",
157
+ "verified": false
158
+ }
159
+ },
160
+ {
161
+ "createdAt": "Mon Jun 15 15:58:46 +0800 2026",
162
+ "id": "5310101537687411",
163
+ "mid": "5310101537687411",
164
+ "postJumpLink": "https://weibo.com/<uid>/<mid>",
165
+ "text": "另一条评论内容...",
166
+ "user": {
167
+ "followMe": false,
168
+ "following": true,
169
+ "id": "用户ID",
170
+ "name": "用户昵称",
171
+ "verified": true
172
+ }
173
+ }
174
+ ],
175
+ "count": 2,
176
+ "msg": "查询成功"
177
+ },
178
+ "message": "success"
179
+ }
180
+ ```
181
+
182
+ ---
183
+
184
+ ## 注意事项
185
+
186
+ 1. 需要有效的 `token`,可通过 `weibo_token` 工具获取
187
+ 2. `uid` 参数为当前用户的 uid
188
+ 3. `comments-show` 接口的 `id` 参数为微博 ID(博文 ID),不是评论 ID
189
+ 4. `postJumpLink` 可直接用于定位到评论对应的原博,格式为 `https://weibo.com/<uid>/<mid>`
190
+ 5. 评论中的 `followMe` 和 `following` 字段反映了评论发出时与博主的关系,可能随时间变化
191
+
192
+ ---
193
+
194
+ ## 数据分析能力
195
+
196
+ 本技能在基础数据之上,提供互动回复建议分析能力。当用户询问哪些评论值得回复、如何优先回复、互动建议等问题时,综合运用以下能力输出分析报告。
197
+
198
+ > ⚠️ **分析报告必须遵守以下规则**:
199
+ > 1. **报告中提及的每一条评论,都必须附带该评论对应的原博链接**(`postJumpLink`),无论出现在哪个部分,确保用户可以直接点击跳转查看原博和评论上下文。不允许出现没有链接的评论提及。**原博链接必须使用 Markdown 链接格式** `[url](url)` 输出。
200
+ > 2. 每条评论必须给出 **AI 建议的回复示例**(用 `💬 AI回复示例:` 标识),根据评论内容、关系类型和认证状态量身定制,语气自然友好,供用户参考或直接复制使用。
201
+ > 3. 每条评论必须给出**简短的回复思路说明**(用 `📝 回复思路:` 标识),解释 AI 回复示例为什么这么写——即回复策略和措辞背后的考量,一句话即可。
202
+
203
+ ---
204
+
205
+ ### 一、互动回复建议分析
206
+
207
+ 针对收到的评论,通过关注关系和认证状态维度分析,给出建议博主最值得回复的评论,促进博主和粉丝之间的互动。
208
+
209
+ #### 关系字段说明
210
+
211
+ | 字段 | 含义 | 互动价值 |
212
+ |------|------|----------|
213
+ | `followMe=true` | 发评论的用户是我的粉丝 | 回复粉丝能增强粘性 |
214
+ | `following=true` | 我关注了发评论的用户 | 回复关注的人能维护关系 |
215
+ | `followMe=true && following=true` | 发评论的用户和我是互粉关系 | 最值得互动的核心用户 |
216
+ | `verified=true` | 发评论的用户是认证用户,可能是大V | 回复大V能提升曝光 |
217
+
218
+ #### 优先级排序规则
219
+
220
+ 值得回复的评论按以下优先级排序:
221
+
222
+ 1. **互粉关系**(`followMe=true && following=true`)> **我的粉丝**(`followMe=true && following=false`)> **我关注的**(`followMe=false && following=true`)> **无关系**(`followMe=false && following=false`)
223
+ 2. 在上一条规则基础上,如果发评论的用户是认证用户(`verified=true`),则更加值得优先回复
224
+
225
+ #### 分析步骤
226
+
227
+ **第一步:获取评论数据**
228
+
229
+ 调用 `comments-to-me` 接口获取收到的评论列表。若用户指定了自己的某条微博,则调用 `comments-show` 接口获取该微博下的所有评论。
230
+
231
+ **第二步:分类统计**
232
+
233
+ 对评论按关注关系分类统计:
234
+
235
+ | 分类 | 判断条件 | 说明 |
236
+ |------|----------|------|
237
+ | 互粉用户评论 | `followMe=true && following=true` | 与博主互粉,最值得回复 |
238
+ | 粉丝评论 | `followMe=true && following=false` | 博主的粉丝,次值得回复 |
239
+ | 我关注的用户评论 | `followMe=false && following=true` | 博主关注的人,第三优先 |
240
+ | 无关系用户评论 | `followMe=false && following=false` | 无关注关系,优先级最低 |
241
+
242
+ 同时统计认证用户评论数(`verified=true`)。
243
+
244
+ **第三步:按优先级排序筛选**
245
+
246
+ 对每条评论计算优先级分数:
247
+
248
+ | 关系类型 | 基础分 | 认证用户加成 |
249
+ |----------|--------|-------------|
250
+ | 互粉 | 30 | +5 |
251
+ | 我的粉丝 | 20 | +5 |
252
+ | 我关注的 | 10 | +5 |
253
+ | 无关系 | 0 | +5 |
254
+
255
+ 按优先级分数降序排列,分数相同时按评论时间降序(最新优先)。
256
+
257
+ 默认筛选出前 **5** 条值得回复的评论,最大建议不超过 **20** 条。
258
+
259
+ **第四步:输出分析报告**
260
+
261
+ 报告包含:
262
+ - **分类统计摘要**:一行紧凑展示各类型评论数量
263
+ - **推荐回复的评论列表**:每条评论含排名、关系类型、用户昵称、评论内容、时间、建议回复原因、AI 回复示例、评论对应的原博链接(`postJumpLink`)
264
+ - **引导获取更多评论**:提示用户可通过指定微博ID获取该微博下的完整评论列表
265
+
266
+ #### 报告结构
267
+
268
+ > ⚠️ 报告中每条评论的原博链接**必须使用 Markdown 链接格式** `[url](url)` 输出,方便用户点击跳转。
269
+
270
+ ```
271
+ 📊 互动回复建议报告
272
+
273
+ 评论统计:共 12 条(互粉 2 | 粉丝 4 | 我关注 1 | 认证用户 3 | 无关系 5)
274
+
275
+ 建议回复的评论(按优先级排序):
276
+
277
+ 1. 🌟 互粉 · 认证用户 | 科技博主老王
278
+ 「这个观点很有深度,补充一下…」 · 06-15 16:14
279
+ 💬 AI回复示例:感谢补充!你说的这个角度确实值得深入探讨,回头我整理一下展开聊聊~
280
+ 📝 回复思路:对方补充了观点,顺势表示认同并承诺后续展开,既回应了内容又留下互动钩子
281
+ 🔗 [https://weibo.com/uid/mid](https://weibo.com/uid/mid)
282
+
283
+ 2. 🌟 互粉 | 小明
284
+ 「支持!说得对」 · 06-15 15:30
285
+ 💬 AI回复示例:谢谢支持!有你认同我就放心了😄
286
+ 📝 回复思路:评论简短,回复也保持轻松,加入情感表达让互动更真实自然
287
+ 🔗 [https://weibo.com/uid/mid](https://weibo.com/uid/mid)
288
+
289
+ 3. 💬 粉丝 · 认证用户 | 行业观察者
290
+ 「期待更多这样的内容」 · 06-15 14:20
291
+ 💬 AI回复示例:感谢关注!会继续分享这类内容,有想了解的话题也可以告诉我~
292
+ 📝 回复思路:回应期待的同时邀请对方提需求,把单向互动变成双向对话
293
+ 🔗 [https://weibo.com/uid/mid](https://weibo.com/uid/mid)
294
+
295
+ 4. 💬 粉丝 | 小红
296
+ 「学到了,感谢分享」 · 06-15 13:10
297
+ 💬 AI回复示例:能帮到你就好!以后还会分享更多实用内容,记得关注哦~
298
+ 📝 回复思路:肯定对方的收获感,顺带引导关注,自然不突兀
299
+ 🔗 [https://weibo.com/uid/mid](https://weibo.com/uid/mid)
300
+
301
+ 5. 👁 我关注的 | 大V张三
302
+ 「有意思」 · 06-15 12:00
303
+ 💬 AI回复示例:哈哈谢谢!你那边也经常发有趣的内容,互相学习~
304
+ 📝 回复思路:评论很简短,回复轻松回应即可,顺带夸对方内容,维护平等的社交关系
305
+ 🔗 [https://weibo.com/uid/mid](https://weibo.com/uid/mid)
306
+
307
+ 💡 想查看自己某条微博的更多评论?告诉我微博ID,我可以帮你获取该微博下的完整评论列表,发现更多值得互动的内容。
308
+ ```
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * 微博互动内容脚本
5
+ *
6
+ * 使用方法:
7
+ * node weibo-interactive.js <command> [options]
8
+ *
9
+ * 命令:
10
+ * comments-to-me 获取收到的评论列表
11
+ * comments-show 获取某条微博的所有评论
12
+ * help 显示帮助信息
13
+ */
14
+
15
+ import https from 'https';
16
+ import http from 'http';
17
+ import { URL } from 'url';
18
+
19
+ const BASE_URL = 'https://open-im.api.weibo.com';
20
+
21
+ // ============================================================================
22
+ // HTTP 请求
23
+ // ============================================================================
24
+
25
+ /**
26
+ * 发送 HTTP 请求
27
+ * @param {string} method - HTTP 方法
28
+ * @param {string} url - 请求 URL
29
+ * @param {object|null} data - 请求数据(POST 时使用)
30
+ * @returns {Promise<object>} 响应数据
31
+ */
32
+ function request(method, url, data = null) {
33
+ return new Promise((resolve, reject) => {
34
+ const urlObj = new URL(url);
35
+ const isHttps = urlObj.protocol === 'https:';
36
+ const httpModule = isHttps ? https : http;
37
+
38
+ const options = {
39
+ hostname: urlObj.hostname,
40
+ port: urlObj.port || (isHttps ? 443 : 80),
41
+ path: urlObj.pathname + urlObj.search,
42
+ method: method,
43
+ headers: {
44
+ 'Content-Type': 'application/json',
45
+ 'Accept': 'application/json',
46
+ },
47
+ };
48
+
49
+ const req = httpModule.request(options, (res) => {
50
+ let body = '';
51
+ res.on('data', (chunk) => { body += chunk; });
52
+ res.on('end', () => {
53
+ try { resolve(JSON.parse(body)); }
54
+ catch (e) { reject(new Error(`解析响应失败: ${body}`)); }
55
+ });
56
+ });
57
+
58
+ req.on('error', (e) => { reject(e); });
59
+ if (data) req.write(JSON.stringify(data));
60
+ req.end();
61
+ });
62
+ }
63
+
64
+ // ============================================================================
65
+ // API 函数
66
+ // ============================================================================
67
+
68
+ /**
69
+ * 获取收到的评论列表
70
+ *
71
+ * 接口路径:GET /open/interactive/comments/to_me
72
+ *
73
+ * @param {string} token - 认证令牌
74
+ * @param {string} uid - 用户 uid(字符串,避免超大整数精度丢失)
75
+ * @returns {Promise<object>} 收到的评论列表
76
+ */
77
+ async function getCommentsToMe(token, uid) {
78
+ const params = new URLSearchParams({ token, uid: String(uid) });
79
+ const url = `${BASE_URL}/open/interactive/comments/to_me?${params.toString()}`;
80
+ return request('GET', url);
81
+ }
82
+
83
+ /**
84
+ * 获取自己某条微博的所有评论
85
+ *
86
+ * 接口路径:GET /open/interactive/comments/show
87
+ *
88
+ * @param {string} token - 认证令牌
89
+ * @param {string} uid - 用户 uid(字符串,避免超大整数精度丢失)
90
+ * @param {string} weiboId - 微博 ID(博文 ID,字符串,避免超大整数精度丢失)
91
+ * @returns {Promise<object>} 该微博的评论列表
92
+ */
93
+ async function getCommentsShow(token, uid, weiboId) {
94
+ const params = new URLSearchParams({ token, uid: String(uid), id: String(weiboId) });
95
+ const url = `${BASE_URL}/open/interactive/comments/show?${params.toString()}`;
96
+ return request('GET', url);
97
+ }
98
+
99
+ // ============================================================================
100
+ // 命令行参数解析
101
+ // ============================================================================
102
+
103
+ /**
104
+ * 解析命令行参数
105
+ * @param {string[]} args - 命令行参数
106
+ * @returns {object} 解析后的参数对象
107
+ */
108
+ function parseArgs(args) {
109
+ const result = {};
110
+ for (let i = 0; i < args.length; i++) {
111
+ const arg = args[i];
112
+ if (arg.startsWith('--')) {
113
+ const [key, ...valueParts] = arg.slice(2).split('=');
114
+ const value = valueParts.join('=') || args[++i] || true;
115
+ result[key] = value;
116
+ }
117
+ }
118
+ return result;
119
+ }
120
+
121
+ // ============================================================================
122
+ // 帮助信息
123
+ // ============================================================================
124
+
125
+ function printHelp() {
126
+ console.log(`
127
+ 微博互动内容脚本
128
+
129
+ 使用方法:
130
+ node weibo-interactive.js <command> [options]
131
+
132
+ 命令:
133
+ comments-to-me 获取收到的评论列表
134
+ comments-show 获取某条微博的所有评论
135
+ help 显示帮助信息
136
+
137
+ 选项:
138
+ --token=<token> 微博 API 访问令牌(必填,通过 weibo_token 工具获取)
139
+ --uid=<uid> 用户 uid(必填)
140
+ --id=<id> 微博 ID / 博文 ID(comments-show 命令必填)
141
+
142
+ 示例:
143
+ # 获取收到的评论列表
144
+ node weibo-interactive.js comments-to-me --token=<your_token> --uid=1234567890
145
+
146
+ # 获取某条微博的所有评论
147
+ node weibo-interactive.js comments-show --token=<your_token> --uid=1234567890 --id=5305687166161572
148
+ `);
149
+ }
150
+
151
+ // ============================================================================
152
+ // 主函数
153
+ // ============================================================================
154
+
155
+ async function main() {
156
+ const args = process.argv.slice(2);
157
+ const command = args[0];
158
+ const options = parseArgs(args.slice(1));
159
+
160
+ if (!command || command === 'help') {
161
+ printHelp();
162
+ return;
163
+ }
164
+
165
+ try {
166
+ let result;
167
+
168
+ switch (command) {
169
+ case 'comments-to-me': {
170
+ if (!options.token) {
171
+ console.error('需要指定 --token 参数,请先通过 weibo_token 工具获取');
172
+ process.exit(1);
173
+ }
174
+ if (!options.uid) {
175
+ console.error('需要指定 --uid 参数');
176
+ process.exit(1);
177
+ }
178
+ result = await getCommentsToMe(options.token, options.uid);
179
+ break;
180
+ }
181
+
182
+ case 'comments-show': {
183
+ if (!options.token) {
184
+ console.error('需要指定 --token 参数,请先通过 weibo_token 工具获取');
185
+ process.exit(1);
186
+ }
187
+ if (!options.uid) {
188
+ console.error('需要指定 --uid 参数');
189
+ process.exit(1);
190
+ }
191
+ if (!options.id) {
192
+ console.error('需要指定 --id 参数(微博 ID / 博文 ID)');
193
+ process.exit(1);
194
+ }
195
+ result = await getCommentsShow(options.token, options.uid, options.id);
196
+ break;
197
+ }
198
+
199
+ default:
200
+ console.error(`未知命令: ${command}`);
201
+ console.log('使用 "node weibo-interactive.js help" 查看帮助信息');
202
+ process.exit(1);
203
+ }
204
+
205
+ console.log(JSON.stringify(result, null, 2));
206
+
207
+ } catch (error) {
208
+ console.error(`请求失败: ${error.message}`);
209
+ process.exit(1);
210
+ }
211
+ }
212
+
213
+ // 导出函数供模块使用
214
+ export {
215
+ getCommentsToMe,
216
+ getCommentsShow,
217
+ };
218
+
219
+ main();