yz-yuki-plugin 2.0.2 → 2.0.3-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.
Files changed (45) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/README.md +6 -5
  3. package/lib/apps/bilibili.js +81 -8
  4. package/lib/apps/help.js +3 -0
  5. package/lib/apps/version.js +3 -0
  6. package/lib/apps/weibo.js +31 -1
  7. package/lib/components/dynamic/Account.js +2 -0
  8. package/lib/components/dynamic/Content.js +2 -0
  9. package/lib/components/dynamic/Footer.js +1 -0
  10. package/lib/components/dynamic/ForwardContent.js +2 -0
  11. package/lib/components/dynamic/LogoText.js +2 -0
  12. package/lib/components/dynamic/MainPage.js +1 -0
  13. package/lib/components/help/Help.js +1 -0
  14. package/lib/components/loginQrcode/Page.js +1 -0
  15. package/lib/index.js +20 -1
  16. package/lib/models/bilibili/bilibili.api.d.ts +3 -0
  17. package/lib/models/bilibili/bilibili.api.js +9 -0
  18. package/lib/models/bilibili/bilibili.get.web.data.d.ts +3 -0
  19. package/lib/models/bilibili/bilibili.get.web.data.js +4 -0
  20. package/lib/models/bilibili/bilibili.models.d.ts +37 -0
  21. package/lib/models/bilibili/bilibili.models.js +71 -19
  22. package/lib/models/bilibili/bilibili.query.d.ts +24 -0
  23. package/lib/models/bilibili/bilibili.query.js +69 -11
  24. package/lib/models/bilibili/bilibili.task.d.ts +41 -0
  25. package/lib/models/bilibili/bilibili.task.js +77 -34
  26. package/lib/models/bilibili/bilibili.wbi.d.ts +6 -0
  27. package/lib/models/bilibili/bilibili.wbi.js +16 -3
  28. package/lib/models/version/version.d.ts +10 -0
  29. package/lib/models/version/version.js +11 -0
  30. package/lib/models/weibo/weibo.api.d.ts +1 -0
  31. package/lib/models/weibo/weibo.api.js +2 -0
  32. package/lib/models/weibo/weibo.get.web.data.d.ts +3 -0
  33. package/lib/models/weibo/weibo.get.web.data.js +3 -0
  34. package/lib/models/weibo/weibo.query.d.ts +20 -0
  35. package/lib/models/weibo/weibo.query.js +63 -6
  36. package/lib/models/weibo/weibo.task.d.ts +49 -0
  37. package/lib/models/weibo/weibo.task.js +84 -34
  38. package/lib/utils/config.d.ts +51 -1
  39. package/lib/utils/config.js +61 -8
  40. package/lib/utils/image.d.ts +11 -0
  41. package/lib/utils/image.js +15 -0
  42. package/lib/utils/paths.js +7 -7
  43. package/lib/utils/puppeteer.render.d.ts +15 -0
  44. package/lib/utils/puppeteer.render.js +37 -15
  45. package/package.json +8 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
+ # 2.0.3
2
+ * 优化提示信息
3
+
1
4
  # 2.0.2
2
- * 优化Task加载
5
+ * fix DYNAMIC_TYPE_ARTICLE
6
+ * 优化Next npm包插件 Task加载
3
7
 
4
8
  # 2.0.1
5
9
  * 规范版本号
package/README.md CHANGED
@@ -75,6 +75,12 @@ pnpm install --filter=yuki-plugin
75
75
  ```
76
76
 
77
77
  ## 📦插件配置
78
+
79
+ > [!IMPORTANT]
80
+ > 统一的配置文件路径:
81
+
82
+ `Yunzai/data/yuki-plugin/config/`,启动一次后,即可查看配置文件。
83
+
78
84
  ### 1.B站动态功能:
79
85
  使用建议先绑定B站账号或配置cookie,绑定后即可使用相关功能。
80
86
 
@@ -127,11 +133,6 @@ https://m.weibo.cn/u/7643376782 # 7643376782 为崩坏星穹铁道博主uid
127
133
 
128
134
  <details><summary>点击展开</summary>
129
135
 
130
- > [!IMPORTANT]
131
- > 统一的配置文件路径:
132
-
133
- `Yunzai/data/yuki-plugin/config/`,启动一次后,即可查看配置文件。
134
-
135
136
  > [!TIP]
136
137
  > 指令前缀:`#优纪`、`#yuki`、`/优纪`、`/yuki`,
137
138
 
@@ -9,36 +9,46 @@ import { applyLoginQRCode, pollLoginQRCode, saveLoginCookie, postGateway, exitBi
9
9
 
10
10
  const message = new Messages('message');
11
11
  let biliPushData = Config.getConfigData("config", "bilibili", "push");
12
+ /** 推送任务 函数 */
12
13
  async function biliNewPushTask(e) {
13
14
  await new BiliTask(e).runTask();
14
15
  }
16
+ /**B站动态推送 */
15
17
  message.use(async (e) => {
16
18
  await biliNewPushTask(e);
17
19
  }, [/^(#|\/)(yuki|优纪)?执行(b站|B站|bili|bilibili|哔哩|哔哩哔哩)任务$/]);
20
+ /** 添加B站动态订阅 */
18
21
  message.use(async (e) => {
19
22
  if (!e.isMaster) {
20
23
  e.reply("未取得bot主人身份,无权限添加B站动态订阅");
21
24
  }
22
25
  else {
26
+ // 从消息中提取UID
23
27
  const uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(订阅|添加|add|ADD)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*/g, "").trim().replace(/^(uid|UID)?(:|:)?/g, '');
24
28
  if (!uid) {
25
29
  e.reply(`请在指令末尾指定订阅的B站up主的UID!`);
26
30
  return true;
27
31
  }
32
+ // 获取或初始化推送数据
28
33
  let subData = biliPushData || { group: {}, private: {} };
34
+ // 根据聊天类型初始化数据
29
35
  let chatType = e.isGroup ? "group" : "private";
30
36
  let chatId = e.isGroup ? e.group_id : e.user_id;
37
+ // 初始化群组或私聊数据
31
38
  if (!subData[chatType][chatId]) {
32
39
  subData[chatType][chatId] = [];
33
40
  }
41
+ // 检查该 uid 是否已存在
34
42
  const upData = subData[chatType][chatId].find((item) => item.uid === uid);
35
43
  if (upData) {
44
+ // 更新推送类型
36
45
  upData.type = BiliQuery.typeHandle(upData, e.msg, "add");
37
46
  biliPushData = subData;
38
47
  Config.saveConfig("config", "bilibili", "push", subData);
39
48
  e.reply(`修改b站推送动态类型成功~\n${upData.name}:${uid}`);
40
49
  return;
41
50
  }
51
+ // 获取 Bilibili 动态信息
42
52
  const res = await new BiliGetWebData(e).getBiliDynamicListDataByUid(uid);
43
53
  if (res.statusText !== "OK") {
44
54
  e.reply("出了点网络问题,等会再试试吧~");
@@ -46,14 +56,40 @@ message.use(async (e) => {
46
56
  }
47
57
  const { code, data } = res.data || {};
48
58
  if (code === -352) {
49
- e.reply(`遭遇风控,订阅校验失败~\n请检查Cookie配置后再试~`);
59
+ e.reply(`遭遇风控,该uid的主页空间动态内容检查失败~\n请检查Cookie配置后再试~\n将跳过校验并保存订阅,请自行检查uid是否正确。`);
50
60
  logger.mark(`yuki-plugin addDynamicSub Failed:${JSON.stringify(res.data)}`);
51
61
  return true;
52
62
  }
53
63
  const { has_more, items } = data || {};
64
+ let infoName;
54
65
  if ((code === 0) && (has_more === false)) {
55
- e.reply(`订阅校验失败~\nup主uid:${uid} 无效,请核对uid后再试~`);
56
- return;
66
+ e.reply(`检测到该uid的主页空间动态内容为空,\n执行uid:${uid} 校验...`);
67
+ const resp = await new BiliGetWebData(e).getBilibiUserInfoByUid(uid);
68
+ if (resp.statusText !== 'OK') {
69
+ e.reply("出了点网络问题,发起uid校验失败,等会再试试吧~");
70
+ return false;
71
+ }
72
+ const { code, data } = resp.data || {};
73
+ if (code === -400) {
74
+ e.reply("发起uid检验请求错误~\n将跳过校验并保存订阅,请自行检查uid是否正确。");
75
+ return true;
76
+ }
77
+ else if (code === -403) {
78
+ e.reply("可能是Cookie过期或api参数错误,\n访问权限不足,发起uid检验失败。\n将跳过校验并保存订阅,请自行检查uid是否正确。");
79
+ return true;
80
+ }
81
+ else if (code === -404) {
82
+ e.reply(`经过校验,该用户不存在,\n输入的uid: ${uid} 无效。订阅失败。`);
83
+ return false;
84
+ }
85
+ else {
86
+ infoName = data?.name;
87
+ e.reply(`昵称:${infoName} \nuid:${uid} 校验成功!`);
88
+ return true;
89
+ }
90
+ }
91
+ else if (code === 0 && (has_more === true)) {
92
+ return true;
57
93
  }
58
94
  let name;
59
95
  if (Array.isArray(items)) {
@@ -61,11 +97,15 @@ message.use(async (e) => {
61
97
  name = items[0].modules?.module_author?.name || uid;
62
98
  }
63
99
  }
100
+ else if (infoName) {
101
+ name = infoName;
102
+ }
64
103
  else {
65
104
  name = uid;
66
105
  }
106
+ // 添加新的推送数据
67
107
  subData[chatType][chatId].push({
68
- bot_id: e.self_id,
108
+ bot_id: e.self_id, // 使用 bot_id, 对应 e_self_id
69
109
  uid,
70
110
  name: name,
71
111
  type: BiliQuery.typeHandle({ uid, name }, e.msg, "add"),
@@ -75,30 +115,38 @@ message.use(async (e) => {
75
115
  e.reply(`添加b站推送成功~\n${name}:${uid}`);
76
116
  }
77
117
  }, [/^(#|\/)(yuki|优纪)?(订阅|添加|add|ADD)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*.*$/]);
118
+ /** 删除B站动态订阅 */
78
119
  message.use(async (e) => {
79
120
  if (!e.isMaster) {
80
121
  e.reply("未取得bot主人身份,无权限删除B站动态订阅");
81
122
  }
82
123
  else {
124
+ // 提取用户输入的UID
83
125
  const uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*/g, "").trim().replace(/^(uid|UID)?(:|:)?/g, '');
84
126
  if (!uid) {
85
127
  e.reply(`请在指令末尾指定订阅的B站up主的UID!`);
86
128
  return;
87
129
  }
130
+ // 获取或初始化B站推送数据
88
131
  let subData = Config.getConfigData("config", "bilibili", "push") || { group: {}, private: {} };
132
+ // 根据聊天类型初始化数据
89
133
  let chatType = e.isGroup ? "group" : "private";
90
134
  let chatId = e.isGroup ? e.group_id : e.user_id;
135
+ // 初始化群组或私聊数据
91
136
  if (!subData[chatType][chatId]) {
92
137
  subData[chatType][chatId] = [];
93
138
  }
139
+ // 查找指定UID的订阅数据
94
140
  const upData = subData[chatType][chatId].find((item) => item.uid == uid);
95
141
  if (!upData) {
96
142
  e.reply(`订阅列表中没有找到该UID~\n${uid}可能是无效的`);
97
143
  return;
98
144
  }
145
+ // 处理订阅类型
99
146
  const newType = BiliQuery.typeHandle(upData, e.msg, "del");
100
147
  let isDel = false;
101
148
  if (newType.length) {
149
+ // 更新订阅类型
102
150
  subData[chatType][chatId] = subData[chatType][chatId].map((item) => {
103
151
  if (item.uid == uid) {
104
152
  item.type = newType;
@@ -107,23 +155,31 @@ message.use(async (e) => {
107
155
  });
108
156
  }
109
157
  else {
158
+ // 删除订阅
110
159
  isDel = true;
111
160
  subData[chatType][chatId] = subData[chatType][chatId].filter((item) => item.uid !== uid);
112
161
  }
162
+ // 保存更新后的数据
163
+ //biliPushData = subData;
113
164
  Config.saveConfig("config", "bilibili", "push", subData);
165
+ // 回复用户操作结果
114
166
  e.reply(`${isDel ? "删除" : "修改"}b站推送成功~\n${uid}`);
115
167
  }
116
168
  }, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*.*$/]);
169
+ /** 扫码登录B站 */
117
170
  message.use(async (e) => {
118
171
  if (e.isMaster) {
119
172
  try {
120
173
  const token = await applyLoginQRCode(e);
121
174
  let biliLoginCk = await pollLoginQRCode(e, token);
175
+ //let _uuid = readSavedCookieItems(biliLoginCk, ['_uuid'])
176
+ //const buvid_fp = await get_buvid_fp(_uuid);
177
+ //biliLoginCk = buvid_fp + biliLoginCk;
122
178
  if (lodash.trim(biliLoginCk).length != 0) {
123
179
  await saveLoginCookie(e, biliLoginCk);
124
180
  e.reply(`get bilibili LoginCk:成功!`);
125
- const result = await postGateway(biliLoginCk);
126
- const { code, data } = await result.data;
181
+ const result = await postGateway(biliLoginCk); //激活ck
182
+ const { code, data } = await result.data; // 解析校验结果
127
183
  switch (code) {
128
184
  case 0:
129
185
  (logger ?? Bot.logger)?.mark(`优纪插件:获取biliLoginCK,Gateway校验成功:${JSON.stringify(data)}`);
@@ -145,6 +201,7 @@ message.use(async (e) => {
145
201
  e.reply("未取得bot主人身份,无权限配置B站登录ck");
146
202
  }
147
203
  }, [/^(#|\/)(yuki|优纪)?(扫码|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
204
+ /** 删除登陆的B站ck */
148
205
  message.use(async (e) => {
149
206
  if (e.isMaster) {
150
207
  await exitBiliLogin(e);
@@ -155,6 +212,7 @@ message.use(async (e) => {
155
212
  e.reply("未取得bot主人身份,无权限删除B站登录ck");
156
213
  }
157
214
  }, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
215
+ /** 显示我的B站登录信息 */
158
216
  message.use(async (e) => {
159
217
  if (e.isMaster) {
160
218
  await checkBiliLogin(e);
@@ -163,6 +221,7 @@ message.use(async (e) => {
163
221
  e.reply("未取得bot主人身份,无权限查看B站登录状态");
164
222
  }
165
223
  }, [/^(#|\/)(yuki|优纪)?我的(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
224
+ /** 手动绑定本地获取的B站cookie */
166
225
  message.use(async (e) => {
167
226
  if (e.isMaster) {
168
227
  if (e.isPrivate) {
@@ -172,6 +231,7 @@ message.use(async (e) => {
172
231
  let localBiliCookie = e.msg.replace(/^(#|\/)(yuki|优纪)?(绑定|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(ck|CK|cookie|COOKIE)(:|:)?/g, "").trim();
173
232
  let param = {};
174
233
  localBiliCookie.split(';').forEach((v) => {
234
+ // 处理分割特殊cookie_token
175
235
  let tmp = lodash.trim(v).replace('=', '$').split('$');
176
236
  param[tmp[0]] = tmp[1];
177
237
  });
@@ -195,13 +255,16 @@ message.use(async (e) => {
195
255
  }
196
256
  return;
197
257
  }
258
+ //筛选ck
198
259
  localBiliCookie = await readSavedCookieItems(localBiliCookie, ['buvid3', 'buvid4', '_uuid', 'SESSDATA', 'DedeUserID', 'DedeUserID__ckMd5', 'bili_jct', 'b_nut', 'b_lsid'], false);
260
+ //const buvid_fp = await get_buvid_fp(param._uuid)
261
+ //localBiliCookie = buvid_fp + localBiliCookie; //添加buvid_fp值
199
262
  await saveLocalBiliCk(localBiliCookie);
200
263
  logger.mark(`${e.logFnc} 保存B站cookie成功 [UID:${param.DedeUserID}]`);
201
264
  let uidMsg = [`好耶~绑定B站cookie成功:\n${param.DedeUserID}`];
202
265
  await e.reply(uidMsg);
203
- const result = await postGateway(localBiliCookie);
204
- const { code, data } = await result.data;
266
+ const result = await postGateway(localBiliCookie); //激活ck
267
+ const { code, data } = await result.data; // 解析校验结果
205
268
  switch (code) {
206
269
  case 0:
207
270
  (logger ?? Bot.logger)?.mark(`优纪插件:绑定localCK,Gateway校验成功:${JSON.stringify(data)}`);
@@ -216,6 +279,7 @@ message.use(async (e) => {
216
279
  e.reply("未取得bot主人身份,无权限配置B站登录ck");
217
280
  }
218
281
  }, [/^^(#|\/)(yuki|优纪)?(绑定|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)(:|:)?.*$/]);
282
+ /** 删除绑定的本地B站ck */
219
283
  message.use(async (e) => {
220
284
  if (e.isMaster) {
221
285
  await saveLocalBiliCk("");
@@ -225,6 +289,7 @@ message.use(async (e) => {
225
289
  e.reply("未取得bot主人身份,无权限删除B站登录ck");
226
290
  }
227
291
  }, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)$/]);
292
+ /** 当前正在使用的B站ck */
228
293
  message.use(async (e) => {
229
294
  if (e.isGroup) {
230
295
  await e.reply('注意账号安全,请私聊查看叭');
@@ -253,6 +318,7 @@ message.use(async (e) => {
253
318
  }
254
319
  }
255
320
  }, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)$/]);
321
+ /** 删除并刷新redis缓存的临时B站ck */
256
322
  message.use(async (e) => {
257
323
  try {
258
324
  await getNewTempCk();
@@ -269,6 +335,7 @@ message.use(async (e) => {
269
335
  (logger ?? Bot.logger)?.mark(`优纪插件:B站临时ck刷新error:${error}`);
270
336
  }
271
337
  }, [/^(#|\/)(yuki|优纪)?刷新(b站|B站|bili|bilibili|哔哩|哔哩哔哩)临时(ck|CK|cookie|COOKIE)$/]);
338
+ /** 订阅的全部b站推送列表 */
272
339
  message.use(async (e) => {
273
340
  if (!e.isMaster) {
274
341
  e.reply("未取得bot主人身份,无权限查看Bot的全部B站订阅列表");
@@ -284,6 +351,7 @@ message.use(async (e) => {
284
351
  DYNAMIC_TYPE_FORWARD: "转发",
285
352
  DYNAMIC_TYPE_LIVE_RCMD: "直播",
286
353
  };
354
+ // 处理群组订阅
287
355
  if (subData.group && Object.keys(subData.group).length > 0) {
288
356
  messages.push("------群组B站订阅------\n");
289
357
  Object.keys(subData.group).forEach((groupId) => {
@@ -301,6 +369,7 @@ message.use(async (e) => {
301
369
  });
302
370
  });
303
371
  }
372
+ // 处理私聊订阅
304
373
  if (subData.private && Object.keys(subData.private).length > 0) {
305
374
  messages.push("\n------私聊B站订阅------");
306
375
  Object.keys(subData.private).forEach((userId) => {
@@ -321,6 +390,7 @@ message.use(async (e) => {
321
390
  e.reply(`推送列表如下:\n${messages.join("\n")}`);
322
391
  }
323
392
  }, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)全部(推送|动态|订阅)列表$/]);
393
+ /** 单独群聊或私聊的订阅的b站推送列表 */
324
394
  message.use(async (e) => {
325
395
  let subData = Config.getConfigData("config", "bilibili", "push") || { group: {}, private: {} };
326
396
  const messages = [];
@@ -332,6 +402,7 @@ message.use(async (e) => {
332
402
  DYNAMIC_TYPE_FORWARD: "转发",
333
403
  DYNAMIC_TYPE_LIVE_RCMD: "直播",
334
404
  };
405
+ // 根据聊天类型初始化数据
335
406
  let chatType = e.isGroup ? "group" : "private";
336
407
  let chatId = e.isGroup ? e.group_id : e.user_id;
337
408
  if (!subData[chatType][chatId]) {
@@ -350,6 +421,7 @@ message.use(async (e) => {
350
421
  });
351
422
  e.reply(`推送列表如下:\n${messages.join("\n")}`);
352
423
  }, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(推送|动态|订阅)列表$/]);
424
+ /**通过uid获取up主信息 */
353
425
  message.use(async (e) => {
354
426
  let uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主/g, "").trim();
355
427
  const res = await new BiliGetWebData(e).getBilibiUserInfoByUid(uid);
@@ -381,6 +453,7 @@ message.use(async (e) => {
381
453
  }
382
454
  e.reply(message);
383
455
  }, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主.*$/]);
456
+ /** 根据名称搜索up的uid*/
384
457
  message.use(async (e) => {
385
458
  let keyword = e.msg.replace(/^(#|\/)(yuki|优纪)?搜索(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主/g, "").trim();
386
459
  const res = await new BiliGetWebData(e).searchBiliUserInfoByKeyword(keyword);
package/lib/apps/help.js CHANGED
@@ -3,6 +3,9 @@ import Image from '../utils/image.js';
3
3
  import Help from '../models/help/help.js';
4
4
 
5
5
  const message = new Messages('message');
6
+ /**
7
+ * 优纪帮助
8
+ */
6
9
  message.use(async (e) => {
7
10
  const helpData = await Help.get();
8
11
  const renderData = {
@@ -3,6 +3,9 @@ import Image from '../utils/image.js';
3
3
  import VersionData from '../models/version/version.js';
4
4
 
5
5
  const message = new Messages('message');
6
+ /**
7
+ * 优纪版本
8
+ */
6
9
  message.use(async (e) => {
7
10
  const version = new VersionData;
8
11
  const versionData = await version.getChangelogContent();
package/lib/apps/weibo.js CHANGED
@@ -6,36 +6,46 @@ import { WeiboGetWebData } from '../models/weibo/weibo.get.web.data.js';
6
6
 
7
7
  const message = new Messages('message');
8
8
  let weiboPushData = Config.getConfigData("config", "weibo", "push");
9
+ /** 定义 动态任务 函数 */
9
10
  async function weiboNewPushTask(e) {
10
11
  await new WeiboTask(e).runTask();
11
12
  }
13
+ /**微博动态推送 */
12
14
  message.use(async (e) => {
13
15
  await weiboNewPushTask(e);
14
16
  }, [/^(#|\/)(yuki|优纪)?执行(微博|weibo|WEIBO)任务$/]);
17
+ /** 添加微博动态订阅 */
15
18
  message.use(async (e) => {
16
19
  if (!e.isMaster) {
17
20
  e.reply("未取得bot主人身份,无权限添加微博动态订阅");
18
21
  }
19
22
  else {
23
+ // 从消息中提取UID
20
24
  const uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(订阅|添加|add|ADD)(微博|weibo|WEIBO)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*)*/g, "").trim();
21
25
  if (!uid) {
22
26
  e.reply(`请在指令末尾指定订阅的微博博主的UID!`);
23
27
  return true;
24
28
  }
29
+ // 获取或初始化推送数据
25
30
  let subData = weiboPushData || { group: {}, private: {} };
31
+ // 根据聊天类型初始化数据
26
32
  let chatType = e.isGroup ? "group" : "private";
27
33
  let chatId = e.isGroup ? e.group_id : e.user_id;
34
+ // 初始化群组或私聊数据
28
35
  if (!subData[chatType][chatId]) {
29
36
  subData[chatType][chatId] = [];
30
37
  }
38
+ // 检查该 uid 是否已存在
31
39
  const upData = subData[chatType][chatId].find((item) => item.uid === uid);
32
40
  if (upData) {
41
+ // 更新推送类型
33
42
  upData.type = WeiboQuery.typeHandle(upData, e.msg, "add");
34
43
  weiboPushData = subData;
35
44
  Config.saveConfig("config", "weibo", "push", subData);
36
45
  e.reply(`修改微博推送动态类型成功~\n${upData.name}:${uid}`);
37
46
  return;
38
47
  }
48
+ // 获取 微博 博主信息
39
49
  const res = await new WeiboGetWebData(e).getBloggerInfo(uid);
40
50
  if (res.statusText !== "OK") {
41
51
  e.reply("出了点网络问题,等会再试试吧~");
@@ -51,8 +61,9 @@ message.use(async (e) => {
51
61
  if (userInfo && (userInfo.length !== 0)) {
52
62
  name = userInfo.screen_name || uid;
53
63
  }
64
+ // 添加新的推送数据
54
65
  subData[chatType][chatId].push({
55
- bot_id: e?.self_id,
66
+ bot_id: e?.self_id, // 使用 bot_id 对应 e_self_id
56
67
  uid,
57
68
  name: name,
58
69
  type: WeiboQuery.typeHandle({ uid, name }, e.msg, "add"),
@@ -62,30 +73,38 @@ message.use(async (e) => {
62
73
  e.reply(`添加微博推送成功~\n${name}:${uid}`);
63
74
  }
64
75
  }, [/^(#|\/)(yuki|优纪)?(订阅|添加|add|ADD)(微博|weibo|WEIBO)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*)*.*$/]);
76
+ /** 删除微博动态订阅 */
65
77
  message.use(async (e) => {
66
78
  if (!e.isMaster) {
67
79
  e.reply("未取得bot主人身份,无权限删除微博动态订阅");
68
80
  }
69
81
  else {
82
+ // 提取用户输入的UID
70
83
  const uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(微博|weibo|WEIBO)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*)*/g, "").trim();
71
84
  if (!uid) {
72
85
  e.reply(`请在指令末尾指定订阅的微博博主的UID!`);
73
86
  return;
74
87
  }
88
+ // 获取或初始化微博推送数据
75
89
  let data = weiboPushData || { group: {}, private: {} };
90
+ // 根据聊天类型初始化数据
76
91
  let chatType = e.isGroup ? "group" : "private";
77
92
  let chatId = e.isGroup ? e.group_id : e.user_id;
93
+ // 初始化群组或私聊数据
78
94
  if (!data[chatType][chatId]) {
79
95
  data[chatType][chatId] = [];
80
96
  }
97
+ // 查找指定UID的订阅数据
81
98
  const upData = data[chatType][chatId].find((item) => item.uid == uid);
82
99
  if (!upData) {
83
100
  e.reply(`订阅列表中没有找到该UID~\n${uid}可能是无效的`);
84
101
  return;
85
102
  }
103
+ // 处理订阅类型
86
104
  const newType = WeiboQuery.typeHandle(upData, e.msg, "del");
87
105
  let isDel = false;
88
106
  if (newType.length) {
107
+ // 更新订阅类型
89
108
  data[chatType][chatId] = data[chatType][chatId].map((item) => {
90
109
  if (item.uid == uid) {
91
110
  item.type = newType;
@@ -94,13 +113,18 @@ message.use(async (e) => {
94
113
  });
95
114
  }
96
115
  else {
116
+ // 删除订阅
97
117
  isDel = true;
98
118
  data[chatType][chatId] = data[chatType][chatId].filter((item) => item.uid !== uid);
99
119
  }
120
+ // 保存更新后的数据
121
+ //weiboPushData = data;
100
122
  Config.saveConfig("config", "weibo", "push", data);
123
+ // 回复用户操作结果
101
124
  e.reply(`${isDel ? "删除" : "修改"}微博推送成功~\n${uid}`);
102
125
  }
103
126
  }, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(微博|weibo|WEIBO)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*)*.*$/]);
127
+ /** 订阅的全部微博推送列表 */
104
128
  message.use(async (e) => {
105
129
  if (!e.isMaster) {
106
130
  e.reply("未取得bot主人身份,无权限查看Bot的全部微博推送列表");
@@ -115,6 +139,7 @@ message.use(async (e) => {
115
139
  DYNAMIC_TYPE_ARTICLE: "文章",
116
140
  DYNAMIC_TYPE_FORWARD: "转发",
117
141
  };
142
+ // 处理群组订阅
118
143
  if (subData.group && Object.keys(subData.group).length > 0) {
119
144
  messages.push("------群组微博订阅------");
120
145
  Object.keys(subData.group).forEach((groupId) => {
@@ -132,6 +157,7 @@ message.use(async (e) => {
132
157
  });
133
158
  });
134
159
  }
160
+ // 处理私聊订阅
135
161
  if (subData.private && Object.keys(subData.private).length > 0) {
136
162
  messages.push("------私聊微博订阅------");
137
163
  Object.keys(subData.private).forEach((userId) => {
@@ -152,6 +178,7 @@ message.use(async (e) => {
152
178
  e.reply(`推送列表如下:\n${messages.join("\n")}`);
153
179
  }
154
180
  }, [/^(#|\/)(yuki|优纪)?(微博|weibo|WEIBO)全部(推送|动态|订阅)列表$/]);
181
+ /** 单独群聊或私聊的订阅的b站推送列表 */
155
182
  message.use(async (e) => {
156
183
  let subData = weiboPushData || { group: {}, private: {} };
157
184
  const messages = [];
@@ -162,6 +189,7 @@ message.use(async (e) => {
162
189
  DYNAMIC_TYPE_ARTICLE: "文章",
163
190
  DYNAMIC_TYPE_FORWARD: "转发",
164
191
  };
192
+ // 根据聊天类型初始化数据
165
193
  let chatType = e.isGroup ? "group" : "private";
166
194
  let chatId = e.isGroup ? e.group_id : e.user_id;
167
195
  if (!subData[chatType][chatId]) {
@@ -180,6 +208,7 @@ message.use(async (e) => {
180
208
  });
181
209
  e.reply(`推送列表如下:\n${messages.join("\n")}`);
182
210
  }, [/^(#|\/)(yuki|优纪)?(微博|weibo|WEIBO)(推送|动态|订阅)列表$/]);
211
+ /**通过uid获取up主信息 */
183
212
  message.use(async (e) => {
184
213
  let uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(微博|weibo|WEIBO)(博|bo|BO)主/g, "").trim();
185
214
  const res = await new WeiboGetWebData(e).getBloggerInfo(uid);
@@ -208,6 +237,7 @@ message.use(async (e) => {
208
237
  ];
209
238
  e.reply(message);
210
239
  }, [/^(#|\/)(yuki|优纪)?(微博|weibo|WEIBO)(博|bo|BO)主.*$/]);
240
+ /** 根据昵称搜索博主信息*/
211
241
  message.use(async (e) => {
212
242
  let keyword = e.msg.replace(/^(#|\/)(yuki|优纪)?搜索(微博|weibo|WEIBO)(博|bo|BO)主/g, "").trim();
213
243
  const res = await new WeiboGetWebData(e).searchBloggerInfo(keyword);
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import LogoText from './LogoText.js';
3
3
  import { createRequire } from 'react-puppeteer';
4
4
 
5
+ // Account
6
+ // up账户组件
5
7
  const require = createRequire(import.meta.url);
6
8
  const bilibililogo = require('./../../../resources/img/icon/dynamic/bilibili.svg');
7
9
  const weibilogo = require('./../../../resources/img/icon/dynamic/weibo.svg');
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { createRequire } from 'react-puppeteer';
3
3
 
4
+ // DynamicContent.tsx
4
5
  const require = createRequire(import.meta.url);
5
6
  const Content = ({ data }) => {
6
7
  const picItems = data.pics && (React.createElement("div", { className: 'pic-content' }, data.pics.map((item, index) => {
@@ -12,6 +13,7 @@ const Content = ({ data }) => {
12
13
  })));
13
14
  const boxGrid_4 = React.createElement("link", { key: "0", rel: "stylesheet", href: require('./../../../resources/css/dynamic/Content.box.grid.4.css') });
14
15
  const boxGrid_9 = React.createElement("link", { key: "0", rel: "stylesheet", href: require('./../../../resources/css/dynamic/Content.box.grid.9.css') });
16
+ /**动态宫格样式 */
15
17
  function getBoxGridStyle(pics) {
16
18
  if (!Array.isArray(pics) || pics.length === 0) {
17
19
  return null;
@@ -3,6 +3,7 @@ import { ConfigController, BOT_NAME } from 'yunzai';
3
3
  import Config from '../../utils/config.js';
4
4
  import { createRequire } from 'react-puppeteer';
5
5
 
6
+ // Footer.tsx
6
7
  const botVersion = ConfigController.package?.version;
7
8
  const require = createRequire(import.meta.url);
8
9
  const bilibililogo = require('./../../../resources/img/icon/dynamic/bilibili.svg');
@@ -3,6 +3,8 @@ import Account from './Account.js';
3
3
  import Content from './Content.js';
4
4
  import { createRequire } from 'react-puppeteer';
5
5
 
6
+ // ForwardContent
7
+ // 转发动态内容组件
6
8
  const require = createRequire(import.meta.url);
7
9
  const ForwardContent = ({ data }) => (React.createElement(React.Fragment, null,
8
10
  React.createElement("link", { rel: "stylesheet", href: require("./../../../resources/css/dynamic/ForwardContent.css") }),
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { createRequire } from 'react-puppeteer';
3
3
 
4
+ // LogoText
5
+ // Logo 文本组件
4
6
  const require = createRequire(import.meta.url);
5
7
  const LogoText = ({ data }) => (React.createElement(React.Fragment, null,
6
8
  React.createElement("link", { rel: "stylesheet", href: require('./../../../resources/css/dynamic/LogoText.css') }),
@@ -5,6 +5,7 @@ import ForwardContent from './ForwardContent.js';
5
5
  import Footer from './Footer.js';
6
6
  import { createRequire } from 'react-puppeteer';
7
7
 
8
+ // MainPage.tsx
8
9
  const require = createRequire(import.meta.url);
9
10
  function App({ data }) {
10
11
  return (React.createElement(React.Fragment, null,
@@ -3,6 +3,7 @@ import { BOT_NAME, ConfigController } from 'yunzai';
3
3
  import Config from '../../utils/config.js';
4
4
  import { createRequire } from 'react-puppeteer';
5
5
 
6
+ //help.tsx
6
7
  const botVersion = ConfigController.package?.version;
7
8
  const require = createRequire(import.meta.url);
8
9
  function App({ data }) {
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { createRequire } from 'react-puppeteer';
3
3
 
4
+ // QrcodeLoginPage.tsx
4
5
  const require = createRequire(import.meta.url);
5
6
  function App({ data }) {
6
7
  return (React.createElement(React.Fragment, null,