yz-yuki-plugin 2.0.5-9 → 2.0.6-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.
@@ -1,7 +1,7 @@
1
1
  import moment from 'moment';
2
- import { Bot, Segment } from 'yunzaijs';
3
- import { readSyncCookie, cookieWithBiliTicket } from './bilibili.models.js';
4
- import { BiliApi } from './bilibili.api.js';
2
+ import { Segment } from 'yunzaijs';
3
+ import { readSyncCookie, cookieWithBiliTicket } from './bilibili.main.models.js';
4
+ import BiliApi from './bilibili.main.api.js';
5
5
  import axios from 'axios';
6
6
  import lodash from 'lodash';
7
7
 
@@ -26,7 +26,7 @@ class BiliQuery {
26
26
  desc = data?.modules?.module_dynamic?.major?.archive || {};
27
27
  formatData.data.title = desc?.title;
28
28
  formatData.data.content = this.parseRichTextNodes(desc?.desc);
29
- formatData.data.url = this.formatUrl(desc?.jump_url);
29
+ formatData.data.url = this.formatUrl(desc?.jump_url) || '';
30
30
  formatData.data.pubTime = author.pub_time;
31
31
  formatData.data.pubTs = moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss');
32
32
  formatData.data.category = '视频动态';
@@ -100,30 +100,36 @@ class BiliQuery {
100
100
  formatData.data.title = desc?.title;
101
101
  // 文章内容过长,则尝试获取全文
102
102
  if (desc?.summary?.text?.length >= 480) {
103
- const { readInfo, articleType } = await this.getFullArticleContent(this.formatUrl(desc?.jump_url));
104
- // 文章链接类型为 cv(旧类型) 或者 opus(新类型)
105
- if (articleType === 'cv') {
106
- formatData.data.content = this.praseFullOldTypeArticleContent(readInfo?.content);
107
- if (String(formatData.data.content).length < 100) {
108
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
109
- formatData.data.pics = pics;
103
+ const fullArticleContent = await this.getFullArticleContent(this.formatUrl(desc?.jump_url));
104
+ if (fullArticleContent) {
105
+ const { readInfo, articleType } = fullArticleContent;
106
+ // 文章链接类型为 cv(旧类型) 或者 opus(新类型)
107
+ if (articleType === 'cv') {
108
+ formatData.data.content = this.praseFullOldTypeArticleContent(readInfo?.content);
109
+ if (String(formatData.data.content).length < 100) {
110
+ formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
111
+ formatData.data.pics = pics;
112
+ }
113
+ else {
114
+ formatData.data.pics = [];
115
+ }
110
116
  }
111
- else {
112
- formatData.data.pics = [];
117
+ else if (articleType === 'opus') {
118
+ const FullNewTypeArticleContent = this.praseFullNewTypeArticleContent(readInfo?.paragraphs);
119
+ if (FullNewTypeArticleContent) {
120
+ const { content, img } = FullNewTypeArticleContent;
121
+ formatData.data.content = content;
122
+ formatData.data.pics = img && img.length > 0 ? img : pics;
123
+ if (content && content.length < 100) {
124
+ formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text);
125
+ }
126
+ }
113
127
  }
114
- }
115
- else if (articleType === 'opus') {
116
- const { content, img } = this.praseFullNewTypeArticleContent(readInfo?.paragraphs);
117
- formatData.data.content = content;
118
- formatData.data.pics = img && img.length > 0 ? img : pics;
119
- if (content && content.length < 100) {
120
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text);
128
+ else {
129
+ formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
130
+ formatData.data.pics = pics;
121
131
  }
122
132
  }
123
- else {
124
- formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
125
- formatData.data.pics = pics;
126
- }
127
133
  }
128
134
  else {
129
135
  formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || '';
@@ -146,7 +152,7 @@ class BiliQuery {
146
152
  formatData.data.pics = pics;
147
153
  formatData.data.content = '';
148
154
  }
149
- formatData.data.url = this.formatUrl(desc?.jump_url);
155
+ formatData.data.url = this.formatUrl(desc?.jump_url) || '';
150
156
  formatData.data.pubTime = author.pub_time;
151
157
  formatData.data.pubTs = moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss');
152
158
  formatData.data.category = '文章动态';
@@ -208,7 +214,7 @@ class BiliQuery {
208
214
  return `<span class="bili-rich-text-module topic" href="${jumpUrl}">${node?.text}</span>`;
209
215
  case 'RICH_TEXT_NODE_TYPE_TEXT':
210
216
  // 正文将 \n 替换为 <br> 以实现换行
211
- return node.text.replace(/\n/g, '<br>');
217
+ return node?.text?.replace(/\n/g, '<br>') || '';
212
218
  case 'RICH_TEXT_NODE_TYPE_AT':
213
219
  // 处理 @ 类型,使用官方的HTML标签写法
214
220
  return `<span data-module="desc" data-type="at" data-oid="${node?.rid}" class="bili-rich-text-module at">${node?.text}</span>`;
@@ -272,7 +278,7 @@ class BiliQuery {
272
278
  }
273
279
  catch (err) {
274
280
  logger?.error(`优纪插件:获取B站完整文章内容失败 [ ${postUrl} ] : ${err}`);
275
- return null;
281
+ return { readInfo: null, articleType: null };
276
282
  }
277
283
  }
278
284
  /**解析旧版完整文章内容 */
@@ -287,8 +293,19 @@ class BiliQuery {
287
293
  });
288
294
  return content;
289
295
  }
290
- /**解析新版完整文章内容
291
- * @param paragraphs - MODULE_TYPE_CONTENT 类型文章的段落数组
296
+ /**
297
+ * 解析新版完整文章内容,将其转换为HTML格式的正文和图片数组。
298
+ * 该方法处理的是 MODULE_TYPE_CONTENT 类型的文章,文章内容由多个段落组成。
299
+ * 每个段落可能包含不同类型的内容,如正文、图片、链接、表情等。
300
+ *
301
+ * @param paragraphs - MODULE_TYPE_CONTENT 类型文章的段落数组,每个段落是一个对象。
302
+ * 每个段落对象包含一个 para_type 属性,用于标识段落类型(1表示正文,2表示图片)。
303
+ * 正文段落中可能包含多个 nodes,每个 node 表示一段文本或一个富文本元素。
304
+ * 图片段落中包含一个 pic 对象,其中 pics 是图片信息的数组。
305
+ * @returns 返回一个对象,包含两个属性:
306
+ * - content: string 类型,解析后的HTML格式的正文字符串。
307
+ * - img: array 类型,包含图片信息的对象数组,每个对象有 url、width 和 height 属性。
308
+ * 如果输入的 paragraphs 不是数组,则返回 null。
292
309
  */
293
310
  static praseFullNewTypeArticleContent = (paragraphs) => {
294
311
  if (Array.isArray(paragraphs)) {
@@ -300,54 +317,58 @@ class BiliQuery {
300
317
  switch (item.para_type) {
301
318
  case 1:
302
319
  // 处理正文
303
- content += item.text.nodes
304
- .map((node) => {
305
- let nodeType = node.type;
306
- if (nodeType === 'TEXT_NODE_TYPE_RICH') {
307
- let richType = node?.rich?.type;
308
- switch (richType) {
309
- case 'RICH_TEXT_NODE_TYPE_TOPIC':
310
- // 确保链接以 https:// 开头
311
- let jumpUrl = node?.rich?.jump_url;
312
- if (jumpUrl && !jumpUrl.startsWith('http://') && !jumpUrl.startsWith('https://')) {
313
- jumpUrl = `https://${jumpUrl}`;
314
- }
315
- return `<span class="bili-rich-text-module topic" href="${jumpUrl}">${node?.rich?.text}</span>`;
316
- case 'RICH_TEXT_NODE_TYPE_TEXT':
317
- // 正文将 \n 替换为 <br> 以实现换行
318
- return node?.rich?.text.replace(/\n/g, '<br>');
319
- case 'RICH_TEXT_NODE_TYPE_AT':
320
- // 处理 @ 类型,使用官方的HTML标签写法
321
- return `<span data-module="desc" data-type="at" data-oid="${node?.rich?.rid}" class="bili-rich-text-module at">${node?.rich?.text}</span>`;
322
- case 'RICH_TEXT_NODE_TYPE_LOTTERY':
323
- // 处理互动抽奖类型,使用官方的HTML标签写法
324
- return `<span data-module="desc" data-type="lottery" data-oid="${node?.rich?.rid}" class="bili-rich-text-module lottery">${node?.rich?.text}</span>`;
325
- case 'RICH_TEXT_NODE_TYPE_WEB':
326
- // 处理 RICH_TEXT_NODE_TYPE_WEB 类型,直接拼接 text 属性
327
- return node?.rich?.text;
328
- case 'RICH_TEXT_NODE_TYPE_EMOJI':
329
- // 处理表情类型,使用 img 标签显示表情
330
- const emoji = node?.rich?.emoji;
331
- return `<img src="${emoji?.icon_url}" alt="${emoji?.text}" title="${emoji?.text}" style="vertical-align: middle; width: ${emoji?.size}em; height: ${emoji?.size}em;">`;
332
- case 'RICH_TEXT_NODE_TYPE_GOODS':
333
- // 处理商品推广类型,使用官方的HTML标签写法
334
- const goods_url = node?.rich?.jump_url;
335
- return `<span data-module="desc" data-type="goods" data-url="${goods_url}" data-oid="${node?.rich?.rid}" class="bili-rich-text-module goods ${node?.rich?.icon_name}">&ZeroWidthSpace;${node?.rich?.text}</span>`;
336
- default:
337
- return node;
320
+ if (item.text?.nodes) {
321
+ content += item.text.nodes
322
+ .map((node) => {
323
+ let nodeType = node.type;
324
+ if (nodeType === 'TEXT_NODE_TYPE_RICH') {
325
+ let richType = node?.rich?.type;
326
+ switch (richType) {
327
+ case 'RICH_TEXT_NODE_TYPE_TOPIC':
328
+ // 确保链接以 https:// 开头
329
+ let jumpUrl = node?.rich?.jump_url;
330
+ if (jumpUrl && !jumpUrl.startsWith('http://') && !jumpUrl.startsWith('https://')) {
331
+ jumpUrl = `https://${jumpUrl}`;
332
+ }
333
+ return `<span class="bili-rich-text-module topic" href="${jumpUrl}">${node?.rich?.text}</span>`;
334
+ case 'RICH_TEXT_NODE_TYPE_TEXT':
335
+ // 正文将 \n 替换为 <br> 以实现换行
336
+ return node?.rich?.text.replace(/\n/g, '<br>');
337
+ case 'RICH_TEXT_NODE_TYPE_AT':
338
+ // 处理 @ 类型,使用官方的HTML标签写法
339
+ return `<span data-module="desc" data-type="at" data-oid="${node?.rich?.rid}" class="bili-rich-text-module at">${node?.rich?.text}</span>`;
340
+ case 'RICH_TEXT_NODE_TYPE_LOTTERY':
341
+ // 处理互动抽奖类型,使用官方的HTML标签写法
342
+ return `<span data-module="desc" data-type="lottery" data-oid="${node?.rich?.rid}" class="bili-rich-text-module lottery">${node?.rich?.text}</span>`;
343
+ case 'RICH_TEXT_NODE_TYPE_WEB':
344
+ // 处理 RICH_TEXT_NODE_TYPE_WEB 类型,直接拼接 text 属性
345
+ return node?.rich?.text;
346
+ case 'RICH_TEXT_NODE_TYPE_EMOJI':
347
+ // 处理表情类型,使用 img 标签显示表情
348
+ const emoji = node?.rich?.emoji;
349
+ return `<img src="${emoji?.icon_url}" alt="${emoji?.text}" title="${emoji?.text}" style="vertical-align: middle; width: ${emoji?.size}em; height: ${emoji?.size}em;">`;
350
+ case 'RICH_TEXT_NODE_TYPE_GOODS':
351
+ // 处理商品推广类型,使用官方的HTML标签写法
352
+ const goods_url = node?.rich?.jump_url;
353
+ return `<span data-module="desc" data-type="goods" data-url="${goods_url}" data-oid="${node?.rich?.rid}" class="bili-rich-text-module goods ${node?.rich?.icon_name}">&ZeroWidthSpace;${node?.rich?.text}</span>`;
354
+ default:
355
+ return node;
356
+ }
338
357
  }
339
- }
340
- else if (nodeType === 'TEXT_NODE_TYPE_WORD') {
341
- return `${node?.word?.words}<br>`;
342
- }
343
- })
344
- .join('');
358
+ else if (nodeType === 'TEXT_NODE_TYPE_WORD') {
359
+ return `${node?.word?.words}<br>`;
360
+ }
361
+ })
362
+ .join('');
363
+ }
345
364
  break;
346
365
  case 2:
347
366
  // 处理图片
348
- img = img.concat(item?.pic?.pics.map((item) => {
349
- return { url: item?.url, width: item?.width, height: item?.height };
350
- }) || []);
367
+ if (item?.pic?.pics) {
368
+ img = img.concat(item?.pic?.pics.map((item) => {
369
+ return { url: item?.url, width: item?.width, height: item?.height };
370
+ }) || []);
371
+ }
351
372
  break;
352
373
  }
353
374
  });
@@ -372,7 +393,7 @@ class BiliQuery {
372
393
  */
373
394
  static async formatTextDynamicData(upName, data, isForward, setData) {
374
395
  const BiliDrawDynamicLinkUrl = 'https://m.bilibili.com/dynamic/';
375
- let desc, msg, pics, author, majorType, content, dynamicTitle;
396
+ let desc, msg = [], pics = [], author, majorType, content, dynamicTitle;
376
397
  let title = `B站【${upName}】动态推送:\n`;
377
398
  switch (data.type) {
378
399
  case 'DYNAMIC_TYPE_AV':
@@ -388,10 +409,10 @@ class BiliQuery {
388
409
  `标题:${desc.title}\n`,
389
410
  `${desc.desc}\n`,
390
411
  `链接:${this.formatUrl(desc.jump_url)}\n`,
391
- `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}\n`,
392
- Segment.image(desc?.cover)
412
+ `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`
393
413
  ];
394
- return msg;
414
+ pics = [Segment.image(desc?.cover)];
415
+ return { msg, pics };
395
416
  case 'DYNAMIC_TYPE_WORD':
396
417
  // 处理文字动态
397
418
  author = data?.modules?.module_author;
@@ -421,7 +442,7 @@ class BiliQuery {
421
442
  `链接:${BiliDrawDynamicLinkUrl}${data.id_str}\n`,
422
443
  `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`
423
444
  ];
424
- return msg;
445
+ return { msg, pics };
425
446
  case 'DYNAMIC_TYPE_DRAW':
426
447
  // 处理图文动态
427
448
  author = data?.modules?.module_author;
@@ -465,10 +486,9 @@ class BiliQuery {
465
486
  `-----------------------------\n`,
466
487
  `${this.dynamicContentLimit(content, setData)}\n`,
467
488
  `链接:${BiliDrawDynamicLinkUrl}${data.id_str}\n`,
468
- `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}\n`,
469
- ...pics
489
+ `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`
470
490
  ];
471
- return msg;
491
+ return { msg, pics };
472
492
  case 'DYNAMIC_TYPE_ARTICLE':
473
493
  // 处理文章动态
474
494
  author = data?.modules?.module_author;
@@ -509,10 +529,9 @@ class BiliQuery {
509
529
  `-----------------------------\n`,
510
530
  `标题:${dynamicTitle}\n`,
511
531
  `链接:${this.formatUrl(desc.jump_url)}\n`,
512
- `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}\n`,
513
- ...pics
532
+ `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`
514
533
  ];
515
- return msg;
534
+ return { msg, pics };
516
535
  case 'DYNAMIC_TYPE_FORWARD':
517
536
  // 处理转发动态
518
537
  author = data?.modules?.module_author;
@@ -524,11 +543,13 @@ class BiliQuery {
524
543
  return;
525
544
  isForward = true;
526
545
  let orig = await this.formatTextDynamicData(upName, data.orig, isForward, setData);
527
- if (orig && orig.length) {
528
- orig = orig.slice(2);
546
+ let origContent = [];
547
+ if (orig && typeof orig === 'object') {
548
+ origContent = orig.msg.slice(2);
549
+ pics = orig.pics;
529
550
  }
530
551
  else {
531
- return false;
552
+ return 'continue';
532
553
  }
533
554
  title = `B站【${upName}】转发动态推送:\n`;
534
555
  msg = [
@@ -538,9 +559,9 @@ class BiliQuery {
538
559
  `链接:${BiliDrawDynamicLinkUrl}${data.id_str}\n`,
539
560
  `时间:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}\n`,
540
561
  '\n---以下为转发内容---\n',
541
- ...orig
562
+ ...origContent
542
563
  ];
543
- return msg;
564
+ return { msg, pics };
544
565
  case 'DYNAMIC_TYPE_LIVE_RCMD':
545
566
  // 处理直播动态
546
567
  desc = data?.modules?.module_dynamic?.major?.live_rcmd?.content;
@@ -551,11 +572,12 @@ class BiliQuery {
551
572
  if (!desc)
552
573
  return;
553
574
  title = `B站【${upName}】直播动态推送:\n`;
554
- msg = [title, `-----------------------------\n`, `标题:${desc.title}\n`, `链接:https:${desc.link}\n`, Segment.image(desc.cover)];
555
- return msg;
575
+ msg = [title, `-----------------------------\n`, `标题:${desc.title}\n`, `链接:https:${desc.link}`];
576
+ pics = [Segment.image(desc.cover)];
577
+ return { msg, pics };
556
578
  default:
557
579
  // 处理未定义的动态类型
558
- (Bot.logger ?? logger)?.mark(`未处理的B站推送【${upName}】:${data.type}`);
580
+ global?.logger?.mark(`未处理的B站推送【${upName}】:${data.type}`);
559
581
  return 'continue';
560
582
  }
561
583
  }
@@ -1,10 +1,10 @@
1
1
  import QRCode from 'qrcode';
2
- import { Redis, Bot, Segment } from 'yunzaijs';
2
+ import { Redis, Segment, Bot } from 'yunzaijs';
3
3
  import Config from '../../utils/config.js';
4
4
  import { renderPage } from '../../utils/image.js';
5
- import { BiliGetWebData } from './bilibili.get.web.data.js';
6
- import { readSyncCookie, postGateway } from './bilibili.models.js';
7
- import { BiliQuery } from './bilibili.query.js';
5
+ import { BiliGetWebData } from './bilibili.main.get.web.data.js';
6
+ import { readSyncCookie, postGateway } from './bilibili.main.models.js';
7
+ import { BiliQuery } from './bilibili.main.query.js';
8
8
 
9
9
  class BiliTask {
10
10
  taskName;
@@ -59,6 +59,8 @@ class BiliTask {
59
59
  uidMap.set(chatType, new Map());
60
60
  }
61
61
  const chatTypeMap = uidMap.get(chatType); // 建立当前 chatType (group 或 private) 的 uid 映射
62
+ if (chatTypeMap === undefined)
63
+ continue; // 如果 chatTypeMap 未定义,跳过此次循环
62
64
  for (let chatId in biliPushData[chatType]) {
63
65
  const subUpsOfChat = Array.prototype.slice.call(biliPushData[chatType][chatId] || []);
64
66
  for (let subInfoOfup of subUpsOfChat) {
@@ -148,10 +150,18 @@ class BiliTask {
148
150
  }
149
151
  }
150
152
  }
151
- /*发送动态*/
153
+ /**
154
+ * 发送动态消息
155
+ * @param chatId 聊天 ID
156
+ * @param bot_id 机器人 ID
157
+ * @param upName 用户名
158
+ * @param pushDynamicData 推送动态数据
159
+ * @param biliConfigData 哔哩配置数据
160
+ * @param chatType 聊天类型
161
+ */
152
162
  async sendDynamic(chatId, bot_id, upName, pushDynamicData, biliConfigData, chatType) {
153
163
  const id_str = pushDynamicData.id_str;
154
- let sended, markKey;
164
+ let sended = null, markKey = '';
155
165
  if (chatType === 'group') {
156
166
  markKey = this.groupKey;
157
167
  sended = await Redis.get(`${markKey}${chatId}:${id_str}`);
@@ -191,8 +201,8 @@ class BiliTask {
191
201
  let imgs = await this.renderDynamicCard(uid, renderData, ScreenshotOptionsData);
192
202
  if (!imgs)
193
203
  return;
194
- Redis.set(`${markKey}${chatId}:${id_str}`, '1', { EX: 3600 * 10 }); // 设置已发送标记
195
- (logger ?? Bot.logger)?.mark('优纪插件:B站动态执行推送');
204
+ Redis.set(`${markKey}${chatId}:${id_str}`, '1', { EX: 3600 * 72 }); // 设置已发送标记
205
+ logger?.mark('优纪插件:B站动态执行推送');
196
206
  for (let i = 0; i < imgs.length; i++) {
197
207
  const image = imgs[i];
198
208
  await this.sendMessage(chatId, bot_id, chatType, Segment.image(image));
@@ -202,18 +212,32 @@ class BiliTask {
202
212
  }
203
213
  else {
204
214
  const dynamicMsg = await BiliQuery.formatTextDynamicData(upName, pushDynamicData, false, biliConfigData); // 构建图文动态消息
205
- Redis.set(`${markKey}${chatId}:${id_str}`, '1', { EX: 3600 * 10 }); // 设置已发送标记
206
- if (dynamicMsg == 'continue') {
215
+ Redis.set(`${markKey}${chatId}:${id_str}`, '1', { EX: 3600 * 72 }); // 设置已发送标记
216
+ if (dynamicMsg === undefined || dynamicMsg === 'continue') {
207
217
  return 'return'; // 如果动态消息构建失败,则直接返回
208
218
  }
209
219
  if (biliConfigData.banWords.length > 0) {
210
220
  const banWords = new RegExp(biliConfigData.banWords.join('|'), 'g'); // 构建屏蔽关键字正则表达式
211
- if (banWords.test(dynamicMsg.join(''))) {
221
+ if (banWords.test(dynamicMsg.msg.join(''))) {
212
222
  return 'return'; // 如果动态消息包含屏蔽关键字,则直接返回
213
223
  }
214
224
  }
215
- await this.sendMessage(chatId, bot_id, chatType, dynamicMsg);
216
- await new Promise(resolve => setTimeout(resolve, 1000));
225
+ let mergeTextPic = !!biliConfigData.mergeTextPic === false ? false : true; // 是否合并文本和图片,默认为 true
226
+ if (mergeTextPic) {
227
+ const mergeMsg = [...dynamicMsg.msg, ...dynamicMsg.pics];
228
+ await this.sendMessage(chatId, bot_id, chatType, mergeMsg);
229
+ }
230
+ else {
231
+ await this.sendMessage(chatId, bot_id, chatType, dynamicMsg.msg);
232
+ const pics = dynamicMsg.pics;
233
+ if (pics && pics.length > 0) {
234
+ for (let i = 0; i < pics.length; i++) {
235
+ await this.sendMessage(chatId, bot_id, chatType, pics[i]);
236
+ await this.randomDelay(1000, 2000); // 随机延时1-2秒
237
+ }
238
+ }
239
+ await new Promise(resolve => setTimeout(resolve, 1000));
240
+ }
217
241
  }
218
242
  }
219
243
  /**
@@ -305,7 +329,7 @@ class BiliTask {
305
329
  ?.pickGroup(String(chatId))
306
330
  .sendMsg(message) // 发送群聊
307
331
  .catch((error) => {
308
- (logger ?? Bot.logger)?.error(`群组[${chatId}]推送失败:${JSON.stringify(error)}`);
332
+ global?.logger?.error(`群组[${chatId}]推送失败:${JSON.stringify(error)}`);
309
333
  });
310
334
  }
311
335
  else if (chatType === 'private') {
@@ -313,7 +337,7 @@ class BiliTask {
313
337
  ?.pickFriend(String(chatId))
314
338
  .sendMsg(message)
315
339
  .catch((error) => {
316
- (logger ?? Bot.logger)?.error(`用户[${chatId}]推送失败:${JSON.stringify(error)}`);
340
+ global?.logger?.error(`用户[${chatId}]推送失败:${JSON.stringify(error)}`);
317
341
  }); // 发送好友私聊
318
342
  }
319
343
  }