koishi-plugin-bilibili-notify 3.1.0 → 3.1.2-alpha.0

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.
@@ -24,6 +24,7 @@ declare class ComRegister {
24
24
  sendPrivateMsgAndRebootService(): Promise<void>;
25
25
  sendPrivateMsgAndStopService(): Promise<void>;
26
26
  sendMessageWithRetry(bot: Bot<Context>, channelId: string, content: any): Promise<void>;
27
+ getGroupsThatMeetCriteria(targets: Target, type: PushType): string[];
27
28
  broadcastToTargets(targets: Target, content: any, type: PushType): Promise<void>;
28
29
  dynamicDetect(): (...args: any[]) => void;
29
30
  debug_dynamicDetect(): (...args: any[]) => void;
@@ -73,7 +74,6 @@ declare namespace ComRegister {
73
74
  masterAccount: string;
74
75
  masterAccountGuildId: string;
75
76
  };
76
- liveDetectMode: "API" | "WS";
77
77
  restartPush: boolean;
78
78
  pushTime: number;
79
79
  pushImgsInDynamic: boolean;
@@ -422,82 +422,93 @@ class ComRegister {
422
422
  await this.sendPrivateMsg(`发送群组ID:${channelId}消息失败,请查看日志`);
423
423
  });
424
424
  }
425
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
426
- async broadcastToTargets(targets, content, type) {
427
- for (const target of targets) {
428
- // 获取机器人实例
429
- const bot = this.getBot(target.platform);
430
- // 定义需要发送的数组
431
- let channelArr = [];
432
- // 判断是否需要推送所有机器人加入的群
433
- if (target.channelArr[0].channelId === "all") {
434
- // 获取所有guild
435
- for (const guild of (await bot.getGuildList()).data) {
436
- channelArr.push({
437
- channelId: guild.id,
438
- dynamic: target.channelArr[0].dynamic,
439
- live: target.channelArr[0].live,
440
- liveGuardBuy: target.channelArr[0].liveGuardBuy,
441
- atAll: target.channelArr[0].atAll,
442
- });
425
+ getGroupsThatMeetCriteria(targets, type) {
426
+ // 定义数组
427
+ const pushArr = [];
428
+ // 判断类型
429
+ if (type === type_1.PushType.Live || type === type_1.PushType.StartBroadcasting) {
430
+ for (const target of targets) {
431
+ for (const channel of target.channelArr) {
432
+ if (channel.live) {
433
+ pushArr.push(`${target.platform}:${channel.channelId}`);
434
+ }
443
435
  }
444
436
  }
445
- else {
446
- channelArr = target.channelArr;
447
- }
448
- // 模式匹配
449
- const pushTypePatternMatching = {
450
- [type_1.PushType.Live]: async () => {
451
- for (const channel of channelArr) {
452
- // 判断是否需要推送动态消息
453
- if (channel.live) {
454
- await this.sendMessageWithRetry(bot, channel.channelId, content);
455
- }
456
- // 延迟发送
457
- await this.ctx.sleep(500);
458
- }
459
- },
460
- [type_1.PushType.Dynamic]: async () => {
461
- for (const channel of channelArr) {
462
- // 判断是否需要推送动态消息
463
- if (channel.live) {
464
- await this.sendMessageWithRetry(bot, channel.channelId, content);
465
- }
466
- // 延迟发送
467
- await this.ctx.sleep(500);
468
- }
469
- },
470
- [type_1.PushType.StartBroadcasting]: async () => {
471
- // 直播开播推送,判断是否需要艾特全体成员
472
- for (const channel of channelArr) {
473
- // 判断是否需要推送直播消息
474
- if (channel.live) {
475
- await this.sendMessageWithRetry(bot, channel.channelId, content);
476
- }
477
- // 判断是否需要艾特全体成员
478
- if (channel.atAll) {
479
- await this.sendMessageWithRetry(bot, channel.channelId, (0, jsx_runtime_1.jsx)("at", { type: "all" }));
480
- }
481
- // 延迟发送
482
- await this.ctx.sleep(500);
437
+ return pushArr;
438
+ }
439
+ if (type === type_1.PushType.Dynamic) {
440
+ for (const target of targets) {
441
+ for (const channel of target.channelArr) {
442
+ if (channel.dynamic) {
443
+ pushArr.push(`${target.platform}:${channel.channelId}`);
483
444
  }
484
- },
485
- [type_1.PushType.LiveGuardBuy]: async () => {
486
- // 直播守护购买推送,判断是否需要艾特全体成员
487
- for (const channel of channelArr) {
488
- // 判断是否需要推送直播消息
489
- if (channel.liveGuardBuy) {
490
- await this.sendMessageWithRetry(bot, channel.channelId, content);
491
- }
492
- // 延迟发送
493
- await this.ctx.sleep(500);
445
+ }
446
+ }
447
+ return pushArr;
448
+ }
449
+ if (type === type_1.PushType.LiveGuardBuy) {
450
+ for (const target of targets) {
451
+ for (const channel of target.channelArr) {
452
+ if (channel.liveGuardBuy) {
453
+ pushArr.push(`${target.platform}:${channel.channelId}`);
494
454
  }
495
455
  }
496
- };
497
- // 推送
498
- await pushTypePatternMatching[type]();
456
+ }
457
+ return pushArr;
499
458
  }
500
459
  }
460
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
461
+ async broadcastToTargets(targets, content, type) {
462
+ // 不止一个目标平台或一个目标频道
463
+ if (targets.length !== 1 || targets[0].channelArr.length !== 1) {
464
+ // 直接使用broadcast
465
+ const pushArr = this.getGroupsThatMeetCriteria(targets, type);
466
+ // logger
467
+ this.logger.info(`推送消息到 ${pushArr.length} 个目标频道,目标频道为:${pushArr.join(", ")}`);
468
+ // 推送消息
469
+ await (0, utils_1.withRetry)(async () => {
470
+ await this.ctx.broadcast(pushArr, content);
471
+ }, 1);
472
+ // 结束
473
+ return;
474
+ }
475
+ // 获取目标
476
+ const targetChannel = targets[0].channelArr[0];
477
+ // 获取机器人实例
478
+ const bot = this.getBot(targets[0].platform);
479
+ // 模式匹配
480
+ const pushTypePatternMatching = {
481
+ [type_1.PushType.Live]: async () => {
482
+ if (targetChannel.live) {
483
+ // 直接推送
484
+ await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
485
+ }
486
+ },
487
+ [type_1.PushType.Dynamic]: async () => {
488
+ if (targetChannel.dynamic) {
489
+ await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
490
+ }
491
+ },
492
+ [type_1.PushType.StartBroadcasting]: async () => {
493
+ // 判断是否需要推送直播消息
494
+ if (targetChannel.live) {
495
+ await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
496
+ }
497
+ // 判断是否需要艾特全体成员
498
+ if (targetChannel.atAll) {
499
+ await this.sendMessageWithRetry(bot, targetChannel.channelId, (0, jsx_runtime_1.jsx)("at", { type: "all" }));
500
+ }
501
+ },
502
+ [type_1.PushType.LiveGuardBuy]: async () => {
503
+ // 判断是否需要推送直播消息
504
+ if (targetChannel.liveGuardBuy) {
505
+ await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
506
+ }
507
+ },
508
+ };
509
+ // 推送
510
+ await pushTypePatternMatching[type]();
511
+ }
501
512
  dynamicDetect() {
502
513
  // 检测初始化变量
503
514
  let detectSetup = true;
@@ -604,67 +615,71 @@ class ComRegister {
604
615
  // 动态ID如果一致则结束循环
605
616
  if (dynamicId === dynamicIdStr1st)
606
617
  break;
607
- // 判断动态时间戳是否大于时间线
608
- if (item.modules.module_author.pub_ts > timeline) {
609
- // 从动态数据中取出UP主名称、UID
610
- const upUID = item.modules.module_author.mid.toString();
611
- const upName = item.modules.module_author.name;
612
- // 寻找关注的UP主的动态
613
- for (const sub of this.subManager) {
614
- // 判断是否是订阅的UP主
615
- if (sub.uid === upUID && sub.dynamic) {
616
- // 订阅该UP主,推送该动态
617
- // 推送该条动态
618
- const buffer = await (0, utils_1.withRetry)(async () => {
619
- // 渲染图片
620
- return await this.ctx.gi.generateDynamicImg(item, sub.card);
621
- }, 1).catch(async (e) => {
622
- // 直播开播动态,不做处理
623
- if (e.message === "直播开播动态,不做处理")
624
- return;
625
- if (e.message === "出现关键词,屏蔽该动态") {
626
- // 如果需要发送才发送
627
- if (this.config.filter.notify) {
628
- await this.broadcastToTargets(sub.target, `${upName}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
629
- }
630
- return;
618
+ // 获取动态发布时间
619
+ const postTime = item.modules.module_author.pub_ts;
620
+ // timeline已超过或与当前动态时间戳相同,则后面的动态不需要推送
621
+ if (postTime <= timeline)
622
+ break;
623
+ // 从动态数据中取出UP主名称、UID
624
+ const upUID = item.modules.module_author.mid.toString();
625
+ const upName = item.modules.module_author.name;
626
+ // 寻找关注的UP主的动态
627
+ for (const sub of this.subManager) {
628
+ // 判断是否是订阅的UP主
629
+ if (sub.dynamic && sub.uid === upUID) {
630
+ // 推送该条动态
631
+ const buffer = await (0, utils_1.withRetry)(async () => {
632
+ // 渲染图片
633
+ return await this.ctx.gi.generateDynamicImg(item, sub.card);
634
+ }, 1).catch(async (e) => {
635
+ // 直播开播动态,不做处理
636
+ if (e.message === "直播开播动态,不做处理")
637
+ return;
638
+ if (e.message === "出现关键词,屏蔽该动态") {
639
+ // 如果需要发送才发送
640
+ if (this.config.filter.notify) {
641
+ await this.broadcastToTargets(sub.target, `${upName}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
631
642
  }
632
- if (e.message === "已屏蔽转发动态") {
633
- if (this.config.filter.notify) {
634
- await this.broadcastToTargets(sub.target, `${upName}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
635
- }
636
- return;
643
+ return;
644
+ }
645
+ if (e.message === "已屏蔽转发动态") {
646
+ if (this.config.filter.notify) {
647
+ await this.broadcastToTargets(sub.target, `${upName}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
637
648
  }
638
- // 未知错误
639
- this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
640
- // 发送私聊消息并重启服务
641
- await this.sendPrivateMsgAndStopService();
642
- });
643
- // 判断是否执行成功,未执行成功直接返回
644
- if (!buffer)
645
- continue;
646
- // 判断是否需要发送URL
647
- const dUrl = this.config.dynamicUrl
648
- ? `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`
649
- : "";
650
- // logger
651
- this.logger.info("推送动态中...");
652
- // 发送推送卡片
653
- await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), dUrl] }), type_1.PushType.Dynamic);
654
- // 判断是否需要发送动态中的图片
655
- if (this.config.pushImgsInDynamic) {
656
- // 判断是否为图文动态,且存在draw
657
- if (item.type === "DYNAMIC_TYPE_DRAW" &&
658
- item.modules.module_dynamic.major?.draw) {
659
- for (const img of item.modules.module_dynamic.major.draw
660
- .items) {
661
- await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
662
- }
649
+ return;
650
+ }
651
+ // 未知错误
652
+ this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
653
+ // 发送私聊消息并重启服务
654
+ await this.sendPrivateMsgAndStopService();
655
+ });
656
+ // 判断是否执行成功,未执行成功直接返回
657
+ if (!buffer)
658
+ continue;
659
+ // 定义动态链接
660
+ let dUrl = "";
661
+ // 判断是否需要发送URL
662
+ if (this.config.dynamicUrl) {
663
+ // 生成动态链接
664
+ dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`;
665
+ }
666
+ // logger
667
+ this.logger.info("推送动态中...");
668
+ // 发送推送卡片
669
+ await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), dUrl] }), type_1.PushType.Dynamic);
670
+ // 判断是否需要发送动态中的图片
671
+ if (this.config.pushImgsInDynamic) {
672
+ // 判断是否为图文动态,且存在draw
673
+ if (item.type === "DYNAMIC_TYPE_DRAW" &&
674
+ item.modules.module_dynamic.major?.draw) {
675
+ for (const img of item.modules.module_dynamic.major.draw
676
+ .items) {
677
+ await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
663
678
  }
664
679
  }
665
- // logger
666
- this.logger.info("动态推送完毕!");
667
680
  }
681
+ // logger
682
+ this.logger.info("动态推送完毕!");
668
683
  }
669
684
  }
670
685
  }
@@ -812,93 +827,104 @@ class ComRegister {
812
827
  this.logger.info("动态ID与上一次获取第一条一致,结束循环");
813
828
  break;
814
829
  }
830
+ // 获取动态发布时间
831
+ const postTime = item.modules.module_author.pub_ts;
832
+ // logger
833
+ this.logger.info(`当前动态时间线:${postTime}`);
815
834
  // logger
816
- this.logger.info(`当前动态时间线:${item.modules.module_author.pub_ts}`);
817
835
  this.logger.info(`上一次获取到第一条动态时间线:${timeline}`);
818
- // 判断动态时间戳是否大于时间线
819
- if (item.modules.module_author.pub_ts > timeline) {
820
- // logger
821
- this.logger.info("动态时间线大于上一次获取到第一条动态时间线,开始判断是否是订阅的UP主...");
822
- // 从动态数据中取出UP主名称、UID
823
- const upUID = item.modules.module_author.mid.toString();
824
- const upName = item.modules.module_author.name;
836
+ // logger
837
+ this.logger.info(`当前动态发布时间:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
838
+ // logger
839
+ this.logger.info(`上一次获取到第一条动态发布时间:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
840
+ // timeline已超过或与当前动态时间戳相同,则后面的动态不需要推送
841
+ if (postTime <= timeline) {
825
842
  // logger
826
- this.logger.info(`当前动态UP主UID:${upUID},UP主名称:${upName}`);
827
- // 寻找关注的UP主的动态
828
- for (const sub of this.subManager) {
829
- // 判断是否是订阅的UP主
830
- if (sub.dynamic && sub.uid === upUID) {
831
- // logger:订阅该UP主,推送该动态
832
- this.logger.info("订阅该UP主,开始推送该动态...");
833
- // logger
834
- this.logger.info("开始生成推送卡片...");
835
- // 推送该条动态
836
- const buffer = await (0, utils_1.withRetry)(async () => {
837
- // 渲染图片
838
- return await this.ctx.gi.generateDynamicImg(item, sub.card);
839
- }, 1).catch(async (e) => {
840
- // 直播开播动态,不做处理
841
- if (e.message === "直播开播动态,不做处理")
842
- return;
843
- if (e.message === "出现关键词,屏蔽该动态") {
844
- // 如果需要发送才发送
845
- if (this.config.filter.notify) {
846
- await this.broadcastToTargets(sub.target, `${upName}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
847
- }
848
- return;
849
- }
850
- if (e.message === "已屏蔽转发动态") {
851
- if (this.config.filter.notify) {
852
- await this.broadcastToTargets(sub.target, `${upName}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
853
- }
854
- return;
843
+ this.logger.info("当前动态时间戳已小于等于上一次获取到第一条动态时间线,更晚发布的动态无需监测");
844
+ // 结束本次监测
845
+ break;
846
+ }
847
+ // logger
848
+ this.logger.info("动态时间线大于上一次获取到第一条动态时间线,开始判断是否是订阅的UP主...");
849
+ // 从动态数据中取出UP主名称、UID
850
+ const upUID = item.modules.module_author.mid.toString();
851
+ const upName = item.modules.module_author.name;
852
+ // logger
853
+ this.logger.info(`当前动态UP主UID:${upUID},UP主名称:${upName}`);
854
+ // 寻找关注的UP主的动态
855
+ for (const sub of this.subManager) {
856
+ // 判断是否是订阅的UP主
857
+ if (sub.dynamic && sub.uid === upUID) {
858
+ // logger:订阅该UP主,推送该动态
859
+ this.logger.info("订阅该UP主,开始推送该动态...");
860
+ // logger
861
+ this.logger.info("开始生成推送卡片...");
862
+ // 推送该条动态
863
+ const buffer = await (0, utils_1.withRetry)(async () => {
864
+ // 渲染图片
865
+ return await this.ctx.gi.generateDynamicImg(item, sub.card);
866
+ }, 1).catch(async (e) => {
867
+ // 直播开播动态,不做处理
868
+ if (e.message === "直播开播动态,不做处理")
869
+ return;
870
+ if (e.message === "出现关键词,屏蔽该动态") {
871
+ // 如果需要发送才发送
872
+ if (this.config.filter.notify) {
873
+ await this.broadcastToTargets(sub.target, `${upName}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
855
874
  }
856
- // 未知错误
857
- this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
858
- // 发送私聊消息并重启服务
859
- await this.sendPrivateMsgAndStopService();
860
- });
861
- // 判断是否执行成功,未执行成功直接返回
862
- if (!buffer) {
863
- // logger
864
- this.logger.info("推送卡片生成失败,或该动态为屏蔽动态,跳过该动态!");
865
- // 结束循环
866
- continue;
875
+ return;
867
876
  }
868
- // 定义动态链接
869
- let dUrl = "";
870
- // 判断是否需要发送URL
871
- if (this.config.dynamicUrl) {
872
- // logger
873
- this.logger.info("生成动态链接中...");
874
- // 生成动态链接
875
- dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`;
877
+ if (e.message === "已屏蔽转发动态") {
878
+ if (this.config.filter.notify) {
879
+ await this.broadcastToTargets(sub.target, `${upName}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
880
+ }
881
+ return;
876
882
  }
883
+ // 未知错误
884
+ this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
885
+ // 发送私聊消息并重启服务
886
+ await this.sendPrivateMsgAndStopService();
887
+ });
888
+ // 判断是否执行成功,未执行成功直接返回
889
+ if (!buffer) {
877
890
  // logger
878
- this.logger.info("推送动态中...");
879
- // 发送推送卡片
880
- await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), dUrl] }), type_1.PushType.Dynamic);
891
+ this.logger.info("推送卡片生成失败,或该动态为屏蔽动态,跳过该动态!");
892
+ // 结束循环
893
+ continue;
894
+ }
895
+ // 定义动态链接
896
+ let dUrl = "";
897
+ // 判断是否需要发送URL
898
+ if (this.config.dynamicUrl) {
899
+ // logger
900
+ this.logger.info("生成动态链接中...");
901
+ // 生成动态链接
902
+ dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`;
903
+ }
904
+ // logger
905
+ this.logger.info("推送动态中...");
906
+ // 发送推送卡片
907
+ await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), dUrl] }), type_1.PushType.Dynamic);
908
+ // 判断是否需要发送动态中的图片
909
+ if (this.config.pushImgsInDynamic) {
881
910
  // logger
882
- this.logger.info("动态推送完毕!");
883
- // 判断是否需要发送动态中的图片
884
- if (this.config.pushImgsInDynamic) {
885
- // logger
886
- this.logger.info("开始推送动态中的图片...");
887
- // 判断是否为图文动态,且存在draw
888
- if (item.type === "DYNAMIC_TYPE_DRAW" &&
889
- item.modules.module_dynamic.major?.draw) {
890
- for (const img of item.modules.module_dynamic.major.draw
891
- .items) {
892
- await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
893
- }
911
+ this.logger.info("开始推送动态中的图片...");
912
+ // 判断是否为图文动态,且存在draw
913
+ if (item.type === "DYNAMIC_TYPE_DRAW" &&
914
+ item.modules.module_dynamic.major?.draw) {
915
+ for (const img of item.modules.module_dynamic.major.draw
916
+ .items) {
917
+ await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
894
918
  }
895
- // logger
896
- this.logger.info("图片推送完毕!");
897
919
  }
898
920
  // logger
899
- this.logger.info("动态推送完毕!");
921
+ this.logger.info("图片推送完毕!");
900
922
  }
923
+ // logger
924
+ this.logger.info("动态推送完毕!");
901
925
  }
926
+ // logger
927
+ this.logger.info("不是关注的UP主,跳过该动态");
902
928
  }
903
929
  }
904
930
  // 更新本次请求第一条动态的动态ID
@@ -910,6 +936,10 @@ class ComRegister {
910
936
  items[0].modules.module_author.pub_ts || luxon_1.DateTime.now().toSeconds();
911
937
  // logger
912
938
  this.logger.info(`更新时间线:${timeline}`);
939
+ // logger
940
+ this.logger.info(`时间线格式化:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
941
+ // logger
942
+ this.logger.info("动态监测完成,等待下一次检测...");
913
943
  };
914
944
  // 返回一个闭包函数
915
945
  return (0, utils_1.withLock)(handler);
@@ -998,7 +1028,9 @@ class ComRegister {
998
1028
  // 推送直播信息
999
1029
  const msg = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), liveNotifyMsg || ""] }));
1000
1030
  // 只有在开播时才艾特全体成员
1001
- return await this.broadcastToTargets(target, msg, liveType === type_1.LiveType.StartBroadcasting ? type_1.PushType.StartBroadcasting : type_1.PushType.Live);
1031
+ return await this.broadcastToTargets(target, msg, liveType === type_1.LiveType.StartBroadcasting
1032
+ ? type_1.PushType.StartBroadcasting
1033
+ : type_1.PushType.Live);
1002
1034
  };
1003
1035
  // 找到频道/群组对应的
1004
1036
  const liveGuardBuyPushTargetArr = target.map((channel) => {
@@ -1552,10 +1584,6 @@ class ComRegister {
1552
1584
  masterAccount: koishi_1.Schema.string(),
1553
1585
  masterAccountGuildId: koishi_1.Schema.string(),
1554
1586
  }),
1555
- liveDetectMode: koishi_1.Schema.union([
1556
- koishi_1.Schema.const("API"),
1557
- koishi_1.Schema.const("WS"),
1558
- ]).required(),
1559
1587
  restartPush: koishi_1.Schema.boolean().required(),
1560
1588
  pushTime: koishi_1.Schema.number().required(),
1561
1589
  pushImgsInDynamic: koishi_1.Schema.boolean().required(),
package/lib/index.d.ts CHANGED
@@ -44,7 +44,6 @@ export interface Config {
44
44
  dynamicUrl: boolean;
45
45
  pushImgsInDynamic: boolean;
46
46
  live: {};
47
- liveDetectMode: "API" | "WS";
48
47
  restartPush: boolean;
49
48
  pushTime: number;
50
49
  customLiveStart: string;
package/lib/index.js CHANGED
@@ -127,7 +127,6 @@ class ServerManager extends koishi_1.Service {
127
127
  subLoadTimeout: globalConfig.subLoadTimeout,
128
128
  sub: globalConfig.sub,
129
129
  master: globalConfig.master,
130
- liveDetectMode: globalConfig.liveDetectMode,
131
130
  restartPush: globalConfig.restartPush,
132
131
  pushTime: globalConfig.pushTime,
133
132
  pushImgsInDynamic: globalConfig.pushImgsInDynamic,
@@ -325,15 +324,6 @@ exports.Config = koishi_1.Schema.object({
325
324
  .default(false)
326
325
  .description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片"),
327
326
  live: koishi_1.Schema.object({}).description("直播推送设置"),
328
- liveDetectMode: koishi_1.Schema.union([
329
- koishi_1.Schema.const("WS").description("WebSocket模式:连接到对应的直播间,可推送弹幕消息,开播下播响应最快,但对订阅数有限制"),
330
- koishi_1.Schema.const("API")
331
- .description("API模式:请求对应直播间API,无法获取弹幕消息,开播下播响应慢,理论可无限订阅")
332
- .deprecated(),
333
- ])
334
- .role("radio")
335
- .description("直播检测模式")
336
- .default("WS"),
337
327
  restartPush: koishi_1.Schema.boolean()
338
328
  .default(true)
339
329
  .description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
@@ -5,13 +5,14 @@ export declare enum LiveType {
5
5
  StopBroadcast = 3,
6
6
  FirstLiveBroadcast = 4
7
7
  }
8
- export type ChannelArr = Array<{
8
+ export type Channel = {
9
9
  channelId: string;
10
10
  dynamic: boolean;
11
11
  live: boolean;
12
12
  liveGuardBuy: boolean;
13
13
  atAll: boolean;
14
- }>;
14
+ };
15
+ export type ChannelArr = Array<Channel>;
15
16
  export type TargetItem = {
16
17
  channelArr: ChannelArr;
17
18
  platform: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-bilibili-notify",
3
3
  "description": "Koishi bilibili notify plugin",
4
- "version": "3.1.0",
4
+ "version": "3.1.2-alpha.0",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -233,6 +233,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
233
233
  - ver 3.1.0-alpha.0 修复:新插件在第一次订阅时提示 `订阅失败,错误信息:该分组已经存在`; 移除:消息重发功能; 重构:将消息发送模式改为 `broadcast`
234
234
  - ver 3.1.0-alpha.1 修复:无法发送 `@全体成员` 消息,将消息发送模式改回
235
235
  - ver 3.1.0 修复:订阅某位UP主直播和动态后,某些群聊只开启推送直播也会推送动态
236
+ - ver 3.1.1-alpha.0 修复:稿件重投后,会将之前日期的动态一起推送; 优化:加强动态debug输出; 移除:不必要选项 `live.liveDetectMode`
237
+ - ver 3.1.2-alpha.0 重构:对消息发送模块进行小型重构,多群多平台推送将不再支持艾特全体成员,仅单平台单群聊支持; 移除:群聊 `all` 选项
236
238
 
237
239
  ## 交流群
238
240