yz-yuki-plugin 2.0.6-3 → 2.0.6-5

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/CHANGELOG.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # 2.0.6
2
2
  * 优化文字动态图片资源的发送
3
3
  * 依赖升级
4
+ * 新增哔哩直播动态@全体成员功能,开启前请检查机器人管理员权限和所在聊天类型是否支持
4
5
 
5
6
  # 2.0.5
6
7
  * 优化ck
@@ -1,7 +1,7 @@
1
1
  # b站推送,1 开启 0 关闭,保留添加的相关数据,但是不再推送
2
2
  pushStatus: 1
3
3
 
4
- # 检测b站动态的周期,Cron表达式,作用域共6位,具体方法浏览器搜索 “node-schedule cron表达式”,示例:
4
+ # 检测b站动态的冷却时间 CD,Cron表达式,作用域共6位,具体方法浏览器搜索 “node-schedule cron表达式”,示例:
5
5
  # "*/15 * * * *" #每15min检测一次
6
6
  # "*/31 * * * *" #每31min检测一次
7
7
  # "0 5,35 * * * *" #每小时固定第5分0秒、第35分0秒检测一次,共2次/h
@@ -58,3 +58,9 @@ noSplitHeight: 7500
58
58
 
59
59
  # 动态卡片分页截图高度,默认8000px(仅填数字,无需填入单位),请勿设置过大或过小。启用分片截图时生效。
60
60
  splitHeight: 8000
61
+
62
+ # 直播动态是否@全体成员,默认 0 关闭,1 开启。开启前请检查 <机器人> 是否有 [管理员权限] 或 [聊天平台是否支持],某些聊天平台或类型不支持@全体成员,如qq官方机器人等。
63
+ liveAtAll: 0
64
+
65
+ # 直播动态@全体成员的共享冷却时间CD,单位秒,默认 1800 秒(30分钟),即每个群聊30分钟内不论多少条直播动态,只会@一次。注意,qq群有 @全体成员 10次/日 的限制,所以请合理设置。
66
+ liveAtAllCD: 1800
@@ -1,7 +1,7 @@
1
1
  # 微博推送,1 开启 0 关闭,保留添加的相关数据,但是不再推送
2
2
  pushStatus: 1
3
3
 
4
- # 检测微博动态的周期,Cron表达式,作用域共6位,具体方法浏览器搜索 “node-schedule cron表达式”,示例:
4
+ # 检测微博动态的冷却时间 CD,Cron表达式,作用域共6位,具体方法浏览器搜索 “node-schedule cron表达式”,示例:
5
5
  # "*/15 * * * *" #每15min检测一次
6
6
  # "*/31 * * * *" #每31min检测一次
7
7
  # "0 5,35 * * * *" #每小时固定第5分0秒、第35分0秒检测一次,共2次/h
@@ -395,6 +395,7 @@ class BiliQuery {
395
395
  const BiliDrawDynamicLinkUrl = 'https://m.bilibili.com/dynamic/';
396
396
  let desc, msg = [], pics = [], author, majorType, content, dynamicTitle;
397
397
  let title = `B站【${upName}】动态推送:\n`;
398
+ let dynamicType = data.type;
398
399
  switch (data.type) {
399
400
  case 'DYNAMIC_TYPE_AV':
400
401
  // 处理视频动态
@@ -412,7 +413,7 @@ class BiliQuery {
412
413
  `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`
413
414
  ];
414
415
  pics = [Segment.image(desc?.cover)];
415
- return { msg, pics };
416
+ return { msg, pics, dynamicType };
416
417
  case 'DYNAMIC_TYPE_WORD':
417
418
  // 处理文字动态
418
419
  author = data?.modules?.module_author;
@@ -442,7 +443,7 @@ class BiliQuery {
442
443
  `链接:${BiliDrawDynamicLinkUrl}${data.id_str}\n`,
443
444
  `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`
444
445
  ];
445
- return { msg, pics };
446
+ return { msg, pics, dynamicType };
446
447
  case 'DYNAMIC_TYPE_DRAW':
447
448
  // 处理图文动态
448
449
  author = data?.modules?.module_author;
@@ -488,7 +489,7 @@ class BiliQuery {
488
489
  `链接:${BiliDrawDynamicLinkUrl}${data.id_str}\n`,
489
490
  `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`
490
491
  ];
491
- return { msg, pics };
492
+ return { msg, pics, dynamicType };
492
493
  case 'DYNAMIC_TYPE_ARTICLE':
493
494
  // 处理文章动态
494
495
  author = data?.modules?.module_author;
@@ -531,7 +532,7 @@ class BiliQuery {
531
532
  `链接:${this.formatUrl(desc.jump_url)}\n`,
532
533
  `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`
533
534
  ];
534
- return { msg, pics };
535
+ return { msg, pics, dynamicType };
535
536
  case 'DYNAMIC_TYPE_FORWARD':
536
537
  // 处理转发动态
537
538
  author = data?.modules?.module_author;
@@ -561,7 +562,7 @@ class BiliQuery {
561
562
  '\n---以下为转发内容---\n',
562
563
  ...origContent
563
564
  ];
564
- return { msg, pics };
565
+ return { msg, pics, dynamicType };
565
566
  case 'DYNAMIC_TYPE_LIVE_RCMD':
566
567
  // 处理直播动态
567
568
  desc = data?.modules?.module_dynamic?.major?.live_rcmd?.content;
@@ -574,7 +575,7 @@ class BiliQuery {
574
575
  title = `B站【${upName}】直播动态推送:\n`;
575
576
  msg = [title, `-----------------------------\n`, `标题:${desc.title}\n`, `链接:https:${desc.link}`];
576
577
  pics = [Segment.image(desc.cover)];
577
- return { msg, pics };
578
+ return { msg, pics, dynamicType };
578
579
  default:
579
580
  // 处理未定义的动态类型
580
581
  global?.logger?.mark(`未处理的B站推送【${upName}】:${data.type}`);
@@ -172,6 +172,9 @@ class BiliTask {
172
172
  }
173
173
  if (sended)
174
174
  return; // 如果已经发送过,则直接返回
175
+ let liveAtAll = biliConfigData.liveAtAll === true ? true : false; // 直播动态是否@全体成员,默认false
176
+ let liveAtAllCD = biliConfigData.liveAtAllCD || 1800; // 直播动态@全体成员 冷却时间CD,默认 30 分钟
177
+ let liveAtAllMark = await Redis.get(`${markKey}${chatId}:liveAtAllMark`); // 直播动态@全体成员标记,默认 0
175
178
  if (!!biliConfigData.pushMsgMode) {
176
179
  const { data, uid } = await BiliQuery.formatDynamicData(pushDynamicData); // 处理动态数据
177
180
  const extentData = { ...data };
@@ -202,7 +205,17 @@ class BiliTask {
202
205
  if (!imgs)
203
206
  return;
204
207
  Redis.set(`${markKey}${chatId}:${id_str}`, '1', { EX: 3600 * 72 }); // 设置已发送标记
205
- logger?.mark('优纪插件:B站动态执行推送');
208
+ global?.logger?.mark('优纪插件:B站动态执行推送');
209
+ if (liveAtAll && liveAtAllMark && extentData?.type === 'DYNAMIC_TYPE_LIVE_RCMD') {
210
+ try {
211
+ await this.sendMessage(chatId, bot_id, chatType, Segment.at('all'));
212
+ await Redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1
213
+ }
214
+ catch (error) {
215
+ logger.error(`直播动态发送@全体成员失败,请检查 <机器人> 是否有 [管理员权限] 或 [聊天平台是否支持] :${error}`);
216
+ await this.sendMessage(chatId, bot_id, chatType, ['直播动态发送@全体成员失败,请检查权限或平台是否支持']);
217
+ }
218
+ }
206
219
  for (let i = 0; i < imgs.length; i++) {
207
220
  const image = imgs[i];
208
221
  await this.sendMessage(chatId, bot_id, chatType, Segment.image(image));
@@ -226,9 +239,29 @@ class BiliTask {
226
239
  let mergeTextPic = !!biliConfigData.mergeTextPic === false ? false : true; // 是否合并文本和图片,默认为 true
227
240
  if (mergeTextPic) {
228
241
  const mergeMsg = [...dynamicMsg.msg, ...dynamicMsg.pics];
242
+ if (liveAtAll && liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD') {
243
+ try {
244
+ await this.sendMessage(chatId, bot_id, chatType, Segment.at('all'));
245
+ await Redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1
246
+ }
247
+ catch (error) {
248
+ global?.logger.error(`直播动态发送@全体成员失败,请检查 <机器人> 是否有 [管理员权限] 或 [聊天平台是否支持] :${error}`);
249
+ await this.sendMessage(chatId, bot_id, chatType, ['直播动态发送@全体成员失败,请检查权限或平台是否支持']);
250
+ }
251
+ }
229
252
  await this.sendMessage(chatId, bot_id, chatType, mergeMsg);
230
253
  }
231
254
  else {
255
+ if (liveAtAll && liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD') {
256
+ try {
257
+ await this.sendMessage(chatId, bot_id, chatType, Segment.at('all'));
258
+ await Redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1
259
+ }
260
+ catch (error) {
261
+ global?.logger.error(`直播动态发送@全体成员失败,请检查 <机器人> 是否有 [管理员权限] 或 [聊天平台是否支持] :${error}`);
262
+ await this.sendMessage(chatId, bot_id, chatType, ['直播动态发送@全体成员失败,请检查权限或平台是否支持']);
263
+ }
264
+ }
232
265
  await this.sendMessage(chatId, bot_id, chatType, dynamicMsg.msg);
233
266
  const pics = dynamicMsg.pics;
234
267
  if (pics && pics.length > 0) {
@@ -29,9 +29,12 @@ class WeiboQuery {
29
29
  else if (raw_post?.mblog?.pics) {
30
30
  return 'DYNAMIC_TYPE_DRAW';
31
31
  }
32
- else {
32
+ else if (!raw_post?.mblog?.pics && String(raw_post?.mblog?.text).trim().length > 0) {
33
33
  return 'DYNAMIC_TYPE_ARTICLE';
34
34
  }
35
+ else {
36
+ return 'DYNAMIC_TYPE_UNKNOWN';
37
+ }
35
38
  }
36
39
  /**筛选正文 */
37
40
  static filterText(raw_text) {
@@ -77,6 +80,7 @@ class WeiboQuery {
77
80
  formatData.data.name = nick_name;
78
81
  /**头像框 */
79
82
  formatData.data.pendant = '';
83
+ /**生成日期 */
80
84
  formatData.data.created = moment().format('YYYY年MM月DD日 HH:mm:ss');
81
85
  formatData.data.type = type;
82
86
  switch (type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.6-3",
3
+ "version": "2.0.6-5",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",
@@ -60,6 +60,7 @@
60
60
  "axios": "^1.7.9",
61
61
  "chokidar": "^4.0.1",
62
62
  "husky": "^9.1.6",
63
+ "icqq": "^0.6.10",
63
64
  "jsdom": "^24.1.1",
64
65
  "json5": "^2.2.3",
65
66
  "jsxp": "^1.0.8",