yz-yuki-plugin 2.0.2 → 2.0.3-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.
Files changed (45) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/README.md +6 -5
  3. package/lib/apps/bilibili.js +50 -6
  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("出了点网络问题,等会再试试吧~");
@@ -52,7 +62,7 @@ message.use(async (e) => {
52
62
  }
53
63
  const { has_more, items } = data || {};
54
64
  if ((code === 0) && (has_more === false)) {
55
- e.reply(`订阅校验失败~\nup主uid:${uid} 无效,请核对uid后再试~`);
65
+ e.reply(`校验该up的主页空间动态内容为空\nup主uid:${uid} 可能是无效的,\n请核对uid或让该up发布一条动态后再试~`);
56
66
  return;
57
67
  }
58
68
  let name;
@@ -64,8 +74,9 @@ message.use(async (e) => {
64
74
  else {
65
75
  name = uid;
66
76
  }
77
+ // 添加新的推送数据
67
78
  subData[chatType][chatId].push({
68
- bot_id: e.self_id,
79
+ bot_id: e.self_id, // 使用 bot_id, 对应 e_self_id
69
80
  uid,
70
81
  name: name,
71
82
  type: BiliQuery.typeHandle({ uid, name }, e.msg, "add"),
@@ -75,30 +86,38 @@ message.use(async (e) => {
75
86
  e.reply(`添加b站推送成功~\n${name}:${uid}`);
76
87
  }
77
88
  }, [/^(#|\/)(yuki|优纪)?(订阅|添加|add|ADD)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*.*$/]);
89
+ /** 删除B站动态订阅 */
78
90
  message.use(async (e) => {
79
91
  if (!e.isMaster) {
80
92
  e.reply("未取得bot主人身份,无权限删除B站动态订阅");
81
93
  }
82
94
  else {
95
+ // 提取用户输入的UID
83
96
  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
97
  if (!uid) {
85
98
  e.reply(`请在指令末尾指定订阅的B站up主的UID!`);
86
99
  return;
87
100
  }
101
+ // 获取或初始化B站推送数据
88
102
  let subData = Config.getConfigData("config", "bilibili", "push") || { group: {}, private: {} };
103
+ // 根据聊天类型初始化数据
89
104
  let chatType = e.isGroup ? "group" : "private";
90
105
  let chatId = e.isGroup ? e.group_id : e.user_id;
106
+ // 初始化群组或私聊数据
91
107
  if (!subData[chatType][chatId]) {
92
108
  subData[chatType][chatId] = [];
93
109
  }
110
+ // 查找指定UID的订阅数据
94
111
  const upData = subData[chatType][chatId].find((item) => item.uid == uid);
95
112
  if (!upData) {
96
113
  e.reply(`订阅列表中没有找到该UID~\n${uid}可能是无效的`);
97
114
  return;
98
115
  }
116
+ // 处理订阅类型
99
117
  const newType = BiliQuery.typeHandle(upData, e.msg, "del");
100
118
  let isDel = false;
101
119
  if (newType.length) {
120
+ // 更新订阅类型
102
121
  subData[chatType][chatId] = subData[chatType][chatId].map((item) => {
103
122
  if (item.uid == uid) {
104
123
  item.type = newType;
@@ -107,23 +126,31 @@ message.use(async (e) => {
107
126
  });
108
127
  }
109
128
  else {
129
+ // 删除订阅
110
130
  isDel = true;
111
131
  subData[chatType][chatId] = subData[chatType][chatId].filter((item) => item.uid !== uid);
112
132
  }
133
+ // 保存更新后的数据
134
+ //biliPushData = subData;
113
135
  Config.saveConfig("config", "bilibili", "push", subData);
136
+ // 回复用户操作结果
114
137
  e.reply(`${isDel ? "删除" : "修改"}b站推送成功~\n${uid}`);
115
138
  }
116
139
  }, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)推送\s*(视频\s*|图文\s*|文章\s*|转发\s*|直播\s*)*.*$/]);
140
+ /** 扫码登录B站 */
117
141
  message.use(async (e) => {
118
142
  if (e.isMaster) {
119
143
  try {
120
144
  const token = await applyLoginQRCode(e);
121
145
  let biliLoginCk = await pollLoginQRCode(e, token);
146
+ //let _uuid = readSavedCookieItems(biliLoginCk, ['_uuid'])
147
+ //const buvid_fp = await get_buvid_fp(_uuid);
148
+ //biliLoginCk = buvid_fp + biliLoginCk;
122
149
  if (lodash.trim(biliLoginCk).length != 0) {
123
150
  await saveLoginCookie(e, biliLoginCk);
124
151
  e.reply(`get bilibili LoginCk:成功!`);
125
- const result = await postGateway(biliLoginCk);
126
- const { code, data } = await result.data;
152
+ const result = await postGateway(biliLoginCk); //激活ck
153
+ const { code, data } = await result.data; // 解析校验结果
127
154
  switch (code) {
128
155
  case 0:
129
156
  (logger ?? Bot.logger)?.mark(`优纪插件:获取biliLoginCK,Gateway校验成功:${JSON.stringify(data)}`);
@@ -145,6 +172,7 @@ message.use(async (e) => {
145
172
  e.reply("未取得bot主人身份,无权限配置B站登录ck");
146
173
  }
147
174
  }, [/^(#|\/)(yuki|优纪)?(扫码|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
175
+ /** 删除登陆的B站ck */
148
176
  message.use(async (e) => {
149
177
  if (e.isMaster) {
150
178
  await exitBiliLogin(e);
@@ -155,6 +183,7 @@ message.use(async (e) => {
155
183
  e.reply("未取得bot主人身份,无权限删除B站登录ck");
156
184
  }
157
185
  }, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
186
+ /** 显示我的B站登录信息 */
158
187
  message.use(async (e) => {
159
188
  if (e.isMaster) {
160
189
  await checkBiliLogin(e);
@@ -163,6 +192,7 @@ message.use(async (e) => {
163
192
  e.reply("未取得bot主人身份,无权限查看B站登录状态");
164
193
  }
165
194
  }, [/^(#|\/)(yuki|优纪)?我的(b站|B站|bili|bilibili|哔哩|哔哩哔哩)登录$/]);
195
+ /** 手动绑定本地获取的B站cookie */
166
196
  message.use(async (e) => {
167
197
  if (e.isMaster) {
168
198
  if (e.isPrivate) {
@@ -172,6 +202,7 @@ message.use(async (e) => {
172
202
  let localBiliCookie = e.msg.replace(/^(#|\/)(yuki|优纪)?(绑定|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(ck|CK|cookie|COOKIE)(:|:)?/g, "").trim();
173
203
  let param = {};
174
204
  localBiliCookie.split(';').forEach((v) => {
205
+ // 处理分割特殊cookie_token
175
206
  let tmp = lodash.trim(v).replace('=', '$').split('$');
176
207
  param[tmp[0]] = tmp[1];
177
208
  });
@@ -195,13 +226,16 @@ message.use(async (e) => {
195
226
  }
196
227
  return;
197
228
  }
229
+ //筛选ck
198
230
  localBiliCookie = await readSavedCookieItems(localBiliCookie, ['buvid3', 'buvid4', '_uuid', 'SESSDATA', 'DedeUserID', 'DedeUserID__ckMd5', 'bili_jct', 'b_nut', 'b_lsid'], false);
231
+ //const buvid_fp = await get_buvid_fp(param._uuid)
232
+ //localBiliCookie = buvid_fp + localBiliCookie; //添加buvid_fp值
199
233
  await saveLocalBiliCk(localBiliCookie);
200
234
  logger.mark(`${e.logFnc} 保存B站cookie成功 [UID:${param.DedeUserID}]`);
201
235
  let uidMsg = [`好耶~绑定B站cookie成功:\n${param.DedeUserID}`];
202
236
  await e.reply(uidMsg);
203
- const result = await postGateway(localBiliCookie);
204
- const { code, data } = await result.data;
237
+ const result = await postGateway(localBiliCookie); //激活ck
238
+ const { code, data } = await result.data; // 解析校验结果
205
239
  switch (code) {
206
240
  case 0:
207
241
  (logger ?? Bot.logger)?.mark(`优纪插件:绑定localCK,Gateway校验成功:${JSON.stringify(data)}`);
@@ -216,6 +250,7 @@ message.use(async (e) => {
216
250
  e.reply("未取得bot主人身份,无权限配置B站登录ck");
217
251
  }
218
252
  }, [/^^(#|\/)(yuki|优纪)?(绑定|添加|ADD|add)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)(:|:)?.*$/]);
253
+ /** 删除绑定的本地B站ck */
219
254
  message.use(async (e) => {
220
255
  if (e.isMaster) {
221
256
  await saveLocalBiliCk("");
@@ -225,6 +260,7 @@ message.use(async (e) => {
225
260
  e.reply("未取得bot主人身份,无权限删除B站登录ck");
226
261
  }
227
262
  }, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)$/]);
263
+ /** 当前正在使用的B站ck */
228
264
  message.use(async (e) => {
229
265
  if (e.isGroup) {
230
266
  await e.reply('注意账号安全,请私聊查看叭');
@@ -253,6 +289,7 @@ message.use(async (e) => {
253
289
  }
254
290
  }
255
291
  }, [/^(#|\/)(yuki|优纪)?(取消|删除|del|DEL)(b站|B站|bili|bilibili|哔哩|哔哩哔哩)本地(ck|CK|cookie|COOKIE)$/]);
292
+ /** 删除并刷新redis缓存的临时B站ck */
256
293
  message.use(async (e) => {
257
294
  try {
258
295
  await getNewTempCk();
@@ -269,6 +306,7 @@ message.use(async (e) => {
269
306
  (logger ?? Bot.logger)?.mark(`优纪插件:B站临时ck刷新error:${error}`);
270
307
  }
271
308
  }, [/^(#|\/)(yuki|优纪)?刷新(b站|B站|bili|bilibili|哔哩|哔哩哔哩)临时(ck|CK|cookie|COOKIE)$/]);
309
+ /** 订阅的全部b站推送列表 */
272
310
  message.use(async (e) => {
273
311
  if (!e.isMaster) {
274
312
  e.reply("未取得bot主人身份,无权限查看Bot的全部B站订阅列表");
@@ -284,6 +322,7 @@ message.use(async (e) => {
284
322
  DYNAMIC_TYPE_FORWARD: "转发",
285
323
  DYNAMIC_TYPE_LIVE_RCMD: "直播",
286
324
  };
325
+ // 处理群组订阅
287
326
  if (subData.group && Object.keys(subData.group).length > 0) {
288
327
  messages.push("------群组B站订阅------\n");
289
328
  Object.keys(subData.group).forEach((groupId) => {
@@ -301,6 +340,7 @@ message.use(async (e) => {
301
340
  });
302
341
  });
303
342
  }
343
+ // 处理私聊订阅
304
344
  if (subData.private && Object.keys(subData.private).length > 0) {
305
345
  messages.push("\n------私聊B站订阅------");
306
346
  Object.keys(subData.private).forEach((userId) => {
@@ -321,6 +361,7 @@ message.use(async (e) => {
321
361
  e.reply(`推送列表如下:\n${messages.join("\n")}`);
322
362
  }
323
363
  }, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)全部(推送|动态|订阅)列表$/]);
364
+ /** 单独群聊或私聊的订阅的b站推送列表 */
324
365
  message.use(async (e) => {
325
366
  let subData = Config.getConfigData("config", "bilibili", "push") || { group: {}, private: {} };
326
367
  const messages = [];
@@ -332,6 +373,7 @@ message.use(async (e) => {
332
373
  DYNAMIC_TYPE_FORWARD: "转发",
333
374
  DYNAMIC_TYPE_LIVE_RCMD: "直播",
334
375
  };
376
+ // 根据聊天类型初始化数据
335
377
  let chatType = e.isGroup ? "group" : "private";
336
378
  let chatId = e.isGroup ? e.group_id : e.user_id;
337
379
  if (!subData[chatType][chatId]) {
@@ -350,6 +392,7 @@ message.use(async (e) => {
350
392
  });
351
393
  e.reply(`推送列表如下:\n${messages.join("\n")}`);
352
394
  }, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(推送|动态|订阅)列表$/]);
395
+ /**通过uid获取up主信息 */
353
396
  message.use(async (e) => {
354
397
  let uid = e.msg.replace(/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主/g, "").trim();
355
398
  const res = await new BiliGetWebData(e).getBilibiUserInfoByUid(uid);
@@ -381,6 +424,7 @@ message.use(async (e) => {
381
424
  }
382
425
  e.reply(message);
383
426
  }, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主.*$/]);
427
+ /** 根据名称搜索up的uid*/
384
428
  message.use(async (e) => {
385
429
  let keyword = e.msg.replace(/^(#|\/)(yuki|优纪)?搜索(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(up|UP)主/g, "").trim();
386
430
  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,
package/lib/index.js CHANGED
@@ -7,18 +7,26 @@ import { WeiboTask } from './models/weibo/weibo.task.js';
7
7
 
8
8
  let biliConfigData = Config.getConfigData("config", "bilibili", "config");
9
9
  let weiboConfigData = Config.getConfigData("config", "weibo", "config");
10
+ /** B站动态任务 函数 */
10
11
  async function biliNewPushTask(e) {
11
12
  await new BiliTask(e).runTask();
12
13
  }
14
+ /** 微博动态任务 函数 */
13
15
  async function weiboNewPushTask(e) {
14
16
  await new WeiboTask(e).runTask();
15
17
  }
16
18
  var index = () => {
19
+ // 预先存储
17
20
  const rules = [];
21
+ // options
18
22
  return applicationOptions({
19
23
  create() {
24
+ // created
20
25
  for (const key in index$1) {
26
+ // 推类型
21
27
  const app = new index$1[key]();
28
+ // 用 reg 和 key 连接起来。
29
+ // 也可以进行自由排序
22
30
  for (const rule of app.rule) {
23
31
  rules.push({
24
32
  reg: rule.reg,
@@ -33,6 +41,7 @@ var index = () => {
33
41
  logger.info(chalk.rgb(255, 245, 255)(`https://github.com/snowtafir/yuki-plugin`));
34
42
  logger.info(chalk.rgb(0, 190, 255)(`-----------------------------------------`));
35
43
  logger.info(chalk.rgb(0, 190, 255)(`★ 优纪插件加载完成了喵~`));
44
+ /** B站动态推送定时任务 */
36
45
  setBotTask(async (Bot) => {
37
46
  try {
38
47
  biliNewPushTask();
@@ -44,6 +53,7 @@ var index = () => {
44
53
  console.error('B站动态推送定时任务', err);
45
54
  }
46
55
  }, biliConfigData.pushStatus ? biliConfigData.pushTime : "");
56
+ /** 微博动态推送定时任务 */
47
57
  setBotTask(async (Bot) => {
48
58
  try {
49
59
  await weiboNewPushTask();
@@ -57,10 +67,16 @@ var index = () => {
57
67
  }, weiboConfigData.pushStatus ? weiboConfigData.pushTime : "");
58
68
  },
59
69
  async mounted(e) {
70
+ // 存储
60
71
  const data = [];
72
+ // 如果key不存在
61
73
  const cache = {};
74
+ // 使用event以确保得到正常类型
62
75
  await useEvent(e => {
63
76
  for (const item of rules) {
77
+ // 匹配正则
78
+ // 存在key
79
+ // 第一次new
64
80
  if (new RegExp(item.reg).test(e.msg) &&
65
81
  index$1[item.key] &&
66
82
  !cache[item.key]) {
@@ -68,7 +84,10 @@ var index = () => {
68
84
  data.push(new index$1[item.key]());
69
85
  }
70
86
  }
71
- }, [e, 'message']);
87
+ },
88
+ // 推倒为message类型的event
89
+ [e, 'message']);
90
+ // back
72
91
  return data;
73
92
  }
74
93
  });
@@ -12,6 +12,7 @@ export declare class BiliApi {
12
12
  biliLiveUserInfo: string;
13
13
  biliOpusDetail: string;
14
14
  };
15
+ /**header */
15
16
  static BILIBILI_HEADERS: {
16
17
  Accept: string;
17
18
  'Accept-Language': string;
@@ -32,6 +33,7 @@ export declare class BiliApi {
32
33
  "Upgrade-Insecure-Requests": string;
33
34
  'User-Agent': string;
34
35
  };
36
+ /**Login header */
35
37
  static BIlIBILI_LOGIN_HEADERS: {
36
38
  Accept: string;
37
39
  'Accept-Language': string;
@@ -45,6 +47,7 @@ export declare class BiliApi {
45
47
  'Sec-Fetch-User': string;
46
48
  TE: string;
47
49
  };
50
+ /**FullArticle header */
48
51
  static BILIBILI_ARTICLE_HEADERS: {
49
52
  Accept: string;
50
53
  'Accept-Language': string;