koishi-plugin-bilibili-notify 3.1.4-alpha.0 → 3.1.5-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.
@@ -1,6 +1,7 @@
1
1
  import { type Bot, type Context, type FlatPick, type Logger, Schema } from "koishi";
2
2
  import type { Notifier } from "@koishijs/plugin-notifier";
3
3
  import type { LoginBili } from "./database";
4
+ import { CronJob } from "cron";
4
5
  import { LiveType, type MasterInfo, PushType, type Result, type SubItem, type SubManager, type Target } from "./type";
5
6
  declare class ComRegister {
6
7
  static inject: string[];
@@ -13,11 +14,13 @@ declare class ComRegister {
13
14
  subNotifier: Notifier;
14
15
  ctx: Context;
15
16
  subManager: SubManager;
17
+ dynamicTimelineManager: Map<string, number>;
16
18
  loginDBData: FlatPick<LoginBili, "dynamic_group_id">;
17
19
  privateBot: Bot<Context>;
18
- dynamicDispose: () => void;
20
+ dynamicJob: CronJob;
19
21
  constructor(ctx: Context, config: ComRegister.Config);
20
22
  init(config: ComRegister.Config): Promise<void>;
23
+ initDynamicTimelineManager(): void;
21
24
  getBot(pf: string): Bot<Context, any>;
22
25
  sendPrivateMsg(content: string): Promise<void>;
23
26
  sendPrivateMsgAndRebootService(): Promise<void>;
@@ -41,7 +44,6 @@ declare class ComRegister {
41
44
  }
42
45
  declare namespace ComRegister {
43
46
  interface Config {
44
- subLoadTimeout: number;
45
47
  sub: Array<{
46
48
  uid: string;
47
49
  dynamic: boolean;
@@ -8,16 +8,15 @@ const jsx_runtime_1 = require("@satorijs/element/jsx-runtime");
8
8
  const koishi_1 = require("koishi");
9
9
  // 外部依赖:qrcode
10
10
  const qrcode_1 = __importDefault(require("qrcode"));
11
+ const cron_1 = require("cron");
11
12
  // Utils
12
13
  const utils_1 = require("./utils");
13
14
  // Types
14
15
  const type_1 = require("./type");
15
16
  const luxon_1 = require("luxon");
16
- // TODO:WorlCloud
17
- // import { Segment, useDefault } from "segmentit";
18
17
  class ComRegister {
19
18
  // 必须服务
20
- static inject = ["ba", "gi", "database", "bl", "sm", "cron"];
19
+ static inject = ["ba", "gi", "database", "bl", "sm"];
21
20
  // 定义数组:QQ相关bot
22
21
  qqRelatedBotList = [
23
22
  "qq",
@@ -42,12 +41,14 @@ class ComRegister {
42
41
  ctx;
43
42
  // 订阅管理器
44
43
  subManager = [];
44
+ // 动态时间线管理器
45
+ dynamicTimelineManager = new Map();
45
46
  // 检查登录数据库是否有数据
46
47
  loginDBData;
47
48
  // 机器人实例
48
49
  privateBot;
49
50
  // 动态检测销毁函数
50
- dynamicDispose;
51
+ dynamicJob;
51
52
  // 构造函数
52
53
  constructor(ctx, config) {
53
54
  // 将ctx赋值给类属性
@@ -63,7 +64,7 @@ class ComRegister {
63
64
  .usage("查看动态监测运行状态")
64
65
  .example("status dyn")
65
66
  .action(() => {
66
- if (this.dynamicDispose) {
67
+ if (this.dynamicJob?.isActive) {
67
68
  return "动态监测正在运行";
68
69
  }
69
70
  return "动态监测未运行";
@@ -309,6 +310,8 @@ class ComRegister {
309
310
  return;
310
311
  }
311
312
  }
313
+ // 整理dynamicTimelineManager
314
+ this.initDynamicTimelineManager();
312
315
  // 检查是否需要动态监测
313
316
  this.checkIfDynamicDetectIsNeeded();
314
317
  // 在控制台中显示订阅对象
@@ -319,12 +322,19 @@ class ComRegister {
319
322
  if (this.loginTimer)
320
323
  this.loginTimer();
321
324
  // 销毁动态监测
322
- if (this.dynamicDispose)
323
- this.dynamicDispose();
325
+ if (this.dynamicJob)
326
+ this.dynamicJob.stop();
324
327
  });
325
328
  // logger
326
329
  this.logger.info("插件初始化完毕!");
327
330
  }
331
+ initDynamicTimelineManager() {
332
+ for (const sub of this.subManager) {
333
+ if (sub.dynamic) {
334
+ this.dynamicTimelineManager[sub.uid] = Math.floor(luxon_1.DateTime.now().toSeconds());
335
+ }
336
+ }
337
+ }
328
338
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
329
339
  getBot(pf) {
330
340
  return this.ctx.bots.find((bot) => bot.platform === pf);
@@ -487,47 +497,10 @@ class ComRegister {
487
497
  await pushTypePatternMatching[type]();
488
498
  }
489
499
  dynamicDetect() {
490
- // 检测初始化变量
491
- let detectSetup = true;
492
- // 时间线
493
- let timeline;
494
- // 当前推送动态时间线
495
- let currentTimeline;
496
- // 动态ID
497
- let dynId;
498
500
  // 定义handler
499
501
  const handler = async () => {
500
- // 动态监测启动初始化
501
- if (detectSetup) {
502
- // logger
503
- this.logger.info("动态监测初始化中...");
504
- // 使用withRetry函数进行重试
505
- const content = await (0, utils_1.withRetry)(async () => {
506
- // 获取动态内容
507
- return (await this.ctx.ba.getAllDynamic());
508
- }, 1).catch((e) => {
509
- // logger
510
- this.logger.error(`dynamicDetect getAllDynamic() 发生了错误,错误为:${e.message}`);
511
- });
512
- // content不存在则直接返回
513
- if (!content)
514
- return;
515
- // 判断获取动态信息是否成功
516
- if (content.code !== 0)
517
- return;
518
- // 设置第一条动态的动态ID
519
- dynId = content.data?.items[0]?.id_str || "0";
520
- // 设置时间线
521
- timeline =
522
- content.data?.items[0]?.modules.module_author.pub_ts ||
523
- luxon_1.DateTime.now().toSeconds();
524
- // 设置初始化为false
525
- detectSetup = false;
526
- // logger
527
- this.logger.info("动态监测初始化完毕!");
528
- // 初始化完成
529
- return;
530
- }
502
+ // 定义本次请求推送的动态
503
+ const currentPushDyn = {};
531
504
  // 使用withRetry函数进行重试
532
505
  const content = await (0, utils_1.withRetry)(async () => {
533
506
  // 获取动态内容
@@ -589,23 +562,19 @@ class ComRegister {
589
562
  // 没有动态内容则直接跳过
590
563
  if (!item)
591
564
  continue;
592
- // 获取动态ID
593
- const dynamicId = item.id_str;
594
- // 动态ID如果一致则结束循环
595
- if (dynamicId === dynId)
596
- break;
597
565
  // 获取动态发布时间
598
566
  const postTime = item.modules.module_author.pub_ts;
599
- // timeline已超过或与当前动态时间戳相同,则后面的动态不需要推送
600
- if (postTime <= timeline)
601
- break;
602
567
  // 从动态数据中取出UP主名称、UID
603
- const upUID = item.modules.module_author.mid.toString();
604
- const upName = item.modules.module_author.name;
605
- // 寻找关注的UP主的动态
606
- for (const sub of this.subManager) {
607
- // 判断是否是订阅的UP主
608
- if (sub.dynamic && sub.uid === upUID) {
568
+ const uid = item.modules.module_author.mid.toString();
569
+ const name = item.modules.module_author.name;
570
+ // 判断是否存在时间线
571
+ if (this.dynamicTimelineManager.has(uid)) {
572
+ // 寻找关注的UP主
573
+ const timeline = this.dynamicTimelineManager.get(uid);
574
+ // 判断动态发布时间是否大于时间线
575
+ if (timeline < postTime) {
576
+ // 获取订阅对象
577
+ const sub = this.subManager[uid];
609
578
  // 推送该条动态
610
579
  const buffer = await (0, utils_1.withRetry)(async () => {
611
580
  // 渲染图片
@@ -617,19 +586,19 @@ class ComRegister {
617
586
  if (e.message === "出现关键词,屏蔽该动态") {
618
587
  // 如果需要发送才发送
619
588
  if (this.config.filter.notify) {
620
- await this.broadcastToTargets(sub.target, `${upName}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
589
+ await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
621
590
  }
622
591
  return;
623
592
  }
624
593
  if (e.message === "已屏蔽转发动态") {
625
594
  if (this.config.filter.notify) {
626
- await this.broadcastToTargets(sub.target, `${upName}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
595
+ await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
627
596
  }
628
597
  return;
629
598
  }
630
599
  if (e.message === "已屏蔽专栏动态") {
631
600
  if (this.config.filter.notify) {
632
- await this.broadcastToTargets(sub.target, `${upName}投稿了一条专栏,已屏蔽`, type_1.PushType.Dynamic);
601
+ await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, type_1.PushType.Dynamic);
633
602
  }
634
603
  return;
635
604
  }
@@ -646,11 +615,11 @@ class ComRegister {
646
615
  // 判断是否需要发送URL
647
616
  if (this.config.dynamicUrl) {
648
617
  if (item.type === "DYNAMIC_TYPE_AV") {
649
- dUrl = `${upName}发布了新视频:${item.modules.module_dynamic.major.archive.jump_url}`;
618
+ dUrl = `${name}发布了新视频:${item.modules.module_dynamic.major.archive.jump_url}`;
650
619
  }
651
620
  else {
652
621
  // 生成动态链接
653
- dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`;
622
+ dUrl = `${name}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
654
623
  }
655
624
  }
656
625
  // logger
@@ -668,82 +637,31 @@ class ComRegister {
668
637
  }
669
638
  }
670
639
  }
671
- // 设置timeline
672
- currentTimeline = postTime;
640
+ // 将当前动态存入currentPushDyn
641
+ currentPushDyn[uid] = item;
673
642
  // logger
674
643
  this.logger.info("动态推送完毕!");
675
644
  }
676
645
  }
677
646
  }
678
- // 更新时间线
679
- if (currentTimeline) {
680
- timeline = currentTimeline;
681
- currentTimeline = null;
682
- }
683
- // 设置动态ID
684
- if (items[0].id_str && items[0].id_str !== dynId) {
685
- dynId = items[0].id_str;
647
+ // 遍历currentPushDyn
648
+ for (const uid in currentPushDyn) {
649
+ // 获取动态发布时间
650
+ const postTime = currentPushDyn[uid].modules.module_author.pub_ts;
651
+ // 更新当前时间线
652
+ this.dynamicTimelineManager.set(uid, postTime);
686
653
  }
687
654
  };
688
655
  // 返回一个闭包函数
689
656
  return (0, utils_1.withLock)(handler);
690
657
  }
691
658
  debug_dynamicDetect() {
692
- // 检测初始化变量
693
- let detectSetup = true;
694
- // 时间线
695
- let timeline;
696
- // 当前推送动态时间线
697
- let currentTimeline;
698
- // 动态ID
699
- let dynId;
700
659
  // 定义handler
701
660
  const handler = async () => {
702
- // 动态监测启动初始化
703
- if (detectSetup) {
704
- // logger
705
- this.logger.info("动态监测初始化中...");
706
- // logger
707
- this.logger.info("正在获取动态信息...");
708
- // 使用withRetry函数进行重试
709
- const content = await (0, utils_1.withRetry)(async () => {
710
- // 获取动态内容
711
- return (await this.ctx.ba.getAllDynamic());
712
- }, 1).catch((e) => {
713
- // logger
714
- this.logger.error(`dynamicDetect getAllDynamic() 发生了错误,错误为:${e.message}`);
715
- });
716
- // content不存在则直接返回
717
- if (!content) {
718
- // logger
719
- this.logger.info("获取动态信息失败!");
720
- return;
721
- }
722
- // 判断获取动态信息是否成功
723
- if (content.code !== 0) {
724
- // logger
725
- this.logger.info("获取动态信息失败!");
726
- return;
727
- }
728
- // 设置第一条动态的动态ID
729
- dynId = content.data?.items[0]?.id_str || "0";
730
- // logger
731
- this.logger.info(`获取到第一条动态ID:${dynId}`);
732
- // 设置时间线
733
- timeline =
734
- content.data?.items[0]?.modules.module_author.pub_ts ||
735
- luxon_1.DateTime.now().toSeconds();
736
- // logger
737
- this.logger.info(`获取到时间线信息:${timeline}`);
738
- // 设置初始化为false
739
- detectSetup = false;
740
- // logger
741
- this.logger.info("动态监测初始化完毕!");
742
- // 初始化完成
743
- return;
744
- }
661
+ // 定义本次请求推送的动态
662
+ const currentPushDyn = {};
745
663
  // logger
746
- this.logger.info("正在获取动态信息...");
664
+ this.logger.info("开始获取动态信息...");
747
665
  // 使用withRetry函数进行重试
748
666
  const content = await (0, utils_1.withRetry)(async () => {
749
667
  // 获取动态内容
@@ -753,11 +671,8 @@ class ComRegister {
753
671
  this.logger.error(`dynamicDetect getAllDynamic() 发生了错误,错误为:${e.message}`);
754
672
  });
755
673
  // content不存在则直接返回
756
- if (!content) {
757
- // logger
758
- this.logger.info("获取动态信息失败!");
674
+ if (!content)
759
675
  return;
760
- }
761
676
  // 判断获取动态内容是否成功
762
677
  if (content.code !== 0) {
763
678
  switch (content.code) {
@@ -803,65 +718,37 @@ class ComRegister {
803
718
  }
804
719
  }
805
720
  // logger
806
- this.logger.info("成功获取动态信息!开始检查更新的动态...");
721
+ this.logger.info("获取动态信息成功!开始处理动态信息...");
807
722
  // 获取动态内容
808
723
  const items = content.data.items;
809
724
  // 检查更新的动态
810
725
  for (const item of items) {
811
726
  // 没有动态内容则直接跳过
812
- if (!item) {
813
- // logger
814
- this.logger.info("动态内容为空,跳过该动态");
727
+ if (!item)
815
728
  continue;
816
- }
817
- // 获取动态ID
818
- const dynamicId = item.id_str;
819
- // logger
820
- this.logger.info(`当前动态ID:${dynamicId}`);
821
- this.logger.info(`上次第一条推送的动态ID:${dynId}`);
822
- // 动态ID如果一致则结束循环
823
- if (dynamicId === dynId) {
824
- // logger
825
- this.logger.info("动态ID与上次第一条推送动态一致,结束循环");
826
- // 结束循环
827
- break;
828
- }
829
729
  // 获取动态发布时间
830
730
  const postTime = item.modules.module_author.pub_ts;
831
- // logger
832
- this.logger.info(`当前动态时间线:${postTime}`);
833
- // logger
834
- this.logger.info(`上一次获取到第一条动态时间线:${timeline}`);
835
- // logger
836
- this.logger.info(`当前动态发布时间:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
837
- // logger
838
- this.logger.info(`上一次获取到第一条动态发布时间:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
839
- // timeline已超过或与当前动态时间戳相同,则后面的动态不需要推送
840
- if (postTime <= timeline) {
841
- // logger
842
- this.logger.info("当前动态时间戳已小于等于上一次获取到第一条动态时间线,更晚发布的动态无需监测");
843
- // 结束本次监测
844
- break;
845
- }
846
- // logger
847
- this.logger.info("动态时间线大于最后推送动态时间线,开始判断是否是订阅的UP主...");
848
731
  // 从动态数据中取出UP主名称、UID
849
- const upUID = item.modules.module_author.mid.toString();
850
- const upName = item.modules.module_author.name;
732
+ const uid = item.modules.module_author.mid.toString();
733
+ const name = item.modules.module_author.name;
851
734
  // logger
852
- this.logger.info(`当前动态UP主UID:${upUID},UP主名称:${upName}`);
853
- // 定义是否是订阅的UP主flag
854
- let isSubscribed = false;
855
- // 寻找关注的UP主的动态
856
- for (const sub of this.subManager) {
857
- // 判断是否是订阅的UP主
858
- if (sub.dynamic && sub.uid === upUID) {
859
- // 将flag设置为true
860
- isSubscribed = true;
861
- // logger:订阅该UP主,推送该动态
862
- this.logger.info("订阅该UP主,开始推送该动态...");
735
+ this.logger.info(`获取到动态信息,UP主:${name},UID:${uid},动态发布时间:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
736
+ // 判断是否存在时间线
737
+ if (this.dynamicTimelineManager.has(uid)) {
738
+ // logger
739
+ this.logger.info("订阅该UP主,判断动态时间线...");
740
+ // 寻找关注的UP主
741
+ const timeline = this.dynamicTimelineManager.get(uid);
742
+ // logger
743
+ this.logger.info(`上次推送时间线:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
744
+ // 判断动态发布时间是否大于时间线
745
+ if (timeline < postTime) {
746
+ // logger
747
+ this.logger.info("需要推送该条动态,开始推送...");
748
+ // 获取订阅对象
749
+ const sub = this.subManager[uid];
863
750
  // logger
864
- this.logger.info("开始生成推送卡片...");
751
+ this.logger.info("开始渲染推送卡片...");
865
752
  // 推送该条动态
866
753
  const buffer = await (0, utils_1.withRetry)(async () => {
867
754
  // 渲染图片
@@ -873,13 +760,19 @@ class ComRegister {
873
760
  if (e.message === "出现关键词,屏蔽该动态") {
874
761
  // 如果需要发送才发送
875
762
  if (this.config.filter.notify) {
876
- await this.broadcastToTargets(sub.target, `${upName}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
763
+ await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
877
764
  }
878
765
  return;
879
766
  }
880
767
  if (e.message === "已屏蔽转发动态") {
881
768
  if (this.config.filter.notify) {
882
- await this.broadcastToTargets(sub.target, `${upName}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
769
+ await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
770
+ }
771
+ return;
772
+ }
773
+ if (e.message === "已屏蔽专栏动态") {
774
+ if (this.config.filter.notify) {
775
+ await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, type_1.PushType.Dynamic);
883
776
  }
884
777
  return;
885
778
  }
@@ -889,25 +782,26 @@ class ComRegister {
889
782
  await this.sendPrivateMsgAndStopService();
890
783
  });
891
784
  // 判断是否执行成功,未执行成功直接返回
892
- if (!buffer) {
893
- // logger
894
- this.logger.info("推送卡片生成失败,或该动态为屏蔽动态,跳过该动态!");
895
- // 结束循环
785
+ if (!buffer)
896
786
  continue;
897
- }
787
+ // logger
788
+ this.logger.info("渲染推送卡片成功!");
898
789
  // 定义动态链接
899
790
  let dUrl = "";
900
791
  // 判断是否需要发送URL
901
792
  if (this.config.dynamicUrl) {
902
793
  // logger
903
- this.logger.info("生成动态链接中...");
794
+ this.logger.info("需要发送动态链接,开始生成链接...");
795
+ // 判断动态类型
904
796
  if (item.type === "DYNAMIC_TYPE_AV") {
905
- dUrl = `${upName}发布了新视频:${item.modules.module_dynamic.major.archive.jump_url}`;
797
+ dUrl = `${name}发布了新视频:${item.modules.module_dynamic.major.archive.jump_url}`;
906
798
  }
907
799
  else {
908
800
  // 生成动态链接
909
- dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
801
+ dUrl = `${name}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
910
802
  }
803
+ // logger
804
+ this.logger.info("动态链接生成成功!");
911
805
  }
912
806
  // logger
913
807
  this.logger.info("推送动态中...");
@@ -916,7 +810,7 @@ class ComRegister {
916
810
  // 判断是否需要发送动态中的图片
917
811
  if (this.config.pushImgsInDynamic) {
918
812
  // logger
919
- this.logger.info("开始推送动态中的图片...");
813
+ this.logger.info("需要发送动态中的图片,开始发送...");
920
814
  // 判断是否为图文动态,且存在draw
921
815
  if (item.type === "DYNAMIC_TYPE_DRAW" &&
922
816
  item.modules.module_dynamic.major?.draw) {
@@ -926,39 +820,28 @@ class ComRegister {
926
820
  }
927
821
  }
928
822
  // logger
929
- this.logger.info("图片推送完毕!");
823
+ this.logger.info("动态中的图片发送完毕!");
930
824
  }
931
- // 设置timeline
932
- currentTimeline = postTime;
825
+ // 将当前动态存入currentPushDyn
826
+ currentPushDyn[uid] = item;
933
827
  // logger
934
828
  this.logger.info("动态推送完毕!");
935
829
  }
936
830
  }
937
- if (!isSubscribed) {
938
- // logger
939
- this.logger.info("不是关注的UP主,跳过该动态");
940
- }
941
831
  }
942
- // 更新时间线
943
- if (currentTimeline) {
944
- timeline = currentTimeline;
945
- currentTimeline = null;
946
- // logger
947
- this.logger.info(`更新时间线:${timeline}`);
948
- }
949
- else {
950
- this.logger.info("时间线无需更新!");
951
- }
952
- // 更新动态ID
953
- if (items[0].id_str && items[0].id_str !== dynId) {
954
- dynId = items[0].id_str;
832
+ // logger
833
+ this.logger.info("动态信息处理完毕!");
834
+ // 遍历currentPushDyn
835
+ for (const uid in currentPushDyn) {
836
+ // 获取动态发布时间
837
+ const postTime = currentPushDyn[uid].modules.module_author.pub_ts;
838
+ // 更新当前时间线
839
+ this.dynamicTimelineManager.set(uid, postTime);
955
840
  // logger
956
- this.logger.info(`更新动态ID:${dynId}`);
841
+ this.logger.info(`更新时间线成功,UP主:${uid},时间线:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
957
842
  }
958
843
  // logger
959
- this.logger.info(`时间线格式化:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
960
- // logger
961
- this.logger.info("动态监测完成,等待下一次检测...");
844
+ this.logger.info(`本次推送动态数量:${Object.keys(currentPushDyn).length}`);
962
845
  };
963
846
  // 返回一个闭包函数
964
847
  return (0, utils_1.withLock)(handler);
@@ -1529,10 +1412,12 @@ class ComRegister {
1529
1412
  this.enableDynamicDetect();
1530
1413
  }
1531
1414
  enableDynamicDetect() {
1532
- // 开始动态监测
1533
- this.dynamicDispose = this.ctx.cron("*/2 * * * *", this.config.dynamicDebugMode
1415
+ // 定义Job
1416
+ this.dynamicJob = new cron_1.CronJob("*/2 * * * *", this.config.dynamicDebugMode
1534
1417
  ? this.debug_dynamicDetect()
1535
1418
  : this.dynamicDetect());
1419
+ // 开始动态监测
1420
+ this.dynamicJob.start();
1536
1421
  }
1537
1422
  async checkIfIsLogin() {
1538
1423
  if ((await this.ctx.database.get("loginBili", 1)).length !== 0) {
@@ -1548,7 +1433,6 @@ class ComRegister {
1548
1433
  }
1549
1434
  (function (ComRegister) {
1550
1435
  ComRegister.Config = koishi_1.Schema.object({
1551
- subLoadTimeout: koishi_1.Schema.number(),
1552
1436
  sub: koishi_1.Schema.array(koishi_1.Schema.object({
1553
1437
  uid: koishi_1.Schema.string().description("订阅用户UID"),
1554
1438
  dynamic: koishi_1.Schema.boolean().description("是否订阅用户动态"),
package/lib/index.d.ts CHANGED
@@ -22,7 +22,6 @@ export interface Config {
22
22
  basicSettings: {};
23
23
  userAgent: string;
24
24
  subTitle: {};
25
- subLoadTimeout: number;
26
25
  sub: Array<{
27
26
  name: string;
28
27
  uid: string;
package/lib/index.js CHANGED
@@ -46,7 +46,7 @@ const Database = __importStar(require("./database"));
46
46
  const generateImg_1 = __importDefault(require("./generateImg"));
47
47
  const biliAPI_1 = __importDefault(require("./biliAPI"));
48
48
  const blive_1 = __importDefault(require("./blive"));
49
- exports.inject = ["puppeteer", "database", "notifier", "cron"];
49
+ exports.inject = ["puppeteer", "database", "notifier"];
50
50
  exports.name = "bilibili-notify";
51
51
  let globalConfig;
52
52
  class ServerManager extends koishi_1.Service {
@@ -124,7 +124,6 @@ class ServerManager extends koishi_1.Service {
124
124
  });
125
125
  // CR = ComRegister
126
126
  const cr = this.ctx.plugin(comRegister_1.default, {
127
- subLoadTimeout: globalConfig.subLoadTimeout,
128
127
  sub: globalConfig.sub,
129
128
  master: globalConfig.master,
130
129
  restartPush: globalConfig.restartPush,
@@ -257,9 +256,6 @@ exports.Config = koishi_1.Schema.object({
257
256
  .required()
258
257
  .description("设置请求头User-Agen,请求出现-352时可以尝试修改,UA获取方法可参考:https://blog.csdn.net/qq_44503987/article/details/104929111"),
259
258
  subTitle: koishi_1.Schema.object({}).description("订阅配置"),
260
- subLoadTimeout: koishi_1.Schema.number()
261
- .default(10)
262
- .description("订阅加载超时时间,单位为秒,默认10秒"),
263
259
  sub: koishi_1.Schema.array(koishi_1.Schema.object({
264
260
  name: koishi_1.Schema.string().description("订阅用户昵称,只是给你自己看的(相当于备注),可填可不填"),
265
261
  uid: koishi_1.Schema.string().required().description("订阅用户UID"),
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.4-alpha.0",
4
+ "version": "3.1.5-alpha.0",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -30,11 +30,11 @@
30
30
  "axios": "^1.7.9",
31
31
  "axios-cookiejar-support": "^5.0.5",
32
32
  "blive-message-listener": "^0.5.0",
33
+ "cron": "^4.3.0",
33
34
  "jsdom": "^24.1.3",
34
35
  "luxon": "^3.5.0",
35
36
  "md5": "^2.3.0",
36
37
  "qrcode": "^1.5.4",
37
- "segmentit": "^2.0.3",
38
38
  "tough-cookie": "^4.1.4"
39
39
  },
40
40
  "devDependencies": {
@@ -44,7 +44,6 @@
44
44
  "@types/qrcode": "^1.5.5",
45
45
  "@types/tough-cookie": "^4.0.5",
46
46
  "globals": "^15.14.0",
47
- "koishi-plugin-cron": "^3.1.0",
48
47
  "koishi-plugin-puppeteer": "^3.9.0"
49
48
  },
50
49
  "koishi": {
@@ -52,8 +51,7 @@
52
51
  "required": [
53
52
  "database",
54
53
  "puppeteer",
55
- "notifier",
56
- "cron"
54
+ "notifier"
57
55
  ]
58
56
  },
59
57
  "description": {
package/readme.md CHANGED
@@ -237,6 +237,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
237
237
  - ver 3.1.2-alpha.0 重构:对消息发送模块进行小型重构,多群多平台推送将不再支持艾特全体成员,仅单平台单群聊支持; 移除:群聊 `all` 选项
238
238
  - ver 3.1.3-alpha.0 移除:订阅超时; 新增:屏蔽专栏动态功能; 优化:改进了加载插件的错误提示;
239
239
  - ver 3.1.4-alpha.0 修复:动态只推送视频; 优化:动态视频链接将直接发送为视频链接;
240
+ - ver 3.1.5-alpha.0 修复:潜在动态推送bug; 优化:现在动态监测无需等待,当插件初始化完成即开始监测、移除多余依赖、移除对 `cron` 服务的依赖、移除选项 `超时订阅`
240
241
 
241
242
  ## 交流群
242
243
 
@@ -250,6 +251,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
250
251
 
251
252
  [bilibili-API-collect](https://github.com/SocialSisterYi/bilibili-API-collect) 感谢 `SocialSisterYi` 提供B站API参考
252
253
 
254
+ [bilibili-dynamic-mirai-plugin](https://github.com/Colter23/bilibili-dynamic-mirai-plugin) 感谢 `Colter23` 提供推送卡片灵感参考
255
+
253
256
  ## License
254
257
 
255
258
  MIT