koishi-plugin-bilibili-notify 3.1.3-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,45 +497,10 @@ class ComRegister {
487
497
  await pushTypePatternMatching[type]();
488
498
  }
489
499
  dynamicDetect() {
490
- // 检测初始化变量
491
- let detectSetup = true;
492
- // 时间线
493
- let timeline;
494
- // 第一条动态的动态ID
495
- let dynamicIdStr1st;
496
500
  // 定义handler
497
501
  const handler = async () => {
498
- // 动态监测启动初始化
499
- if (detectSetup) {
500
- // logger
501
- this.logger.info("动态监测初始化中...");
502
- // 使用withRetry函数进行重试
503
- const content = await (0, utils_1.withRetry)(async () => {
504
- // 获取动态内容
505
- return (await this.ctx.ba.getAllDynamic());
506
- }, 1).catch((e) => {
507
- // logger
508
- this.logger.error(`dynamicDetect getAllDynamic() 发生了错误,错误为:${e.message}`);
509
- });
510
- // content不存在则直接返回
511
- if (!content)
512
- return;
513
- // 判断获取动态信息是否成功
514
- if (content.code !== 0)
515
- return;
516
- // 设置第一条动态的动态ID
517
- dynamicIdStr1st = content.data?.items[0]?.id_str || "0";
518
- // 设置时间线
519
- timeline =
520
- content.data?.items[0]?.modules.module_author.pub_ts ||
521
- luxon_1.DateTime.now().toSeconds();
522
- // 设置初始化为false
523
- detectSetup = false;
524
- // logger
525
- this.logger.info("动态监测初始化完毕!");
526
- // 初始化完成
527
- return;
528
- }
502
+ // 定义本次请求推送的动态
503
+ const currentPushDyn = {};
529
504
  // 使用withRetry函数进行重试
530
505
  const content = await (0, utils_1.withRetry)(async () => {
531
506
  // 获取动态内容
@@ -587,23 +562,19 @@ class ComRegister {
587
562
  // 没有动态内容则直接跳过
588
563
  if (!item)
589
564
  continue;
590
- // 获取动态ID
591
- const dynamicId = item.id_str;
592
- // 动态ID如果一致则结束循环
593
- if (dynamicId === dynamicIdStr1st)
594
- break;
595
565
  // 获取动态发布时间
596
566
  const postTime = item.modules.module_author.pub_ts;
597
- // timeline已超过或与当前动态时间戳相同,则后面的动态不需要推送
598
- if (postTime <= timeline)
599
- break;
600
567
  // 从动态数据中取出UP主名称、UID
601
- const upUID = item.modules.module_author.mid.toString();
602
- const upName = item.modules.module_author.name;
603
- // 寻找关注的UP主的动态
604
- for (const sub of this.subManager) {
605
- // 判断是否是订阅的UP主
606
- 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];
607
578
  // 推送该条动态
608
579
  const buffer = await (0, utils_1.withRetry)(async () => {
609
580
  // 渲染图片
@@ -615,19 +586,19 @@ class ComRegister {
615
586
  if (e.message === "出现关键词,屏蔽该动态") {
616
587
  // 如果需要发送才发送
617
588
  if (this.config.filter.notify) {
618
- await this.broadcastToTargets(sub.target, `${upName}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
589
+ await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
619
590
  }
620
591
  return;
621
592
  }
622
593
  if (e.message === "已屏蔽转发动态") {
623
594
  if (this.config.filter.notify) {
624
- await this.broadcastToTargets(sub.target, `${upName}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
595
+ await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
625
596
  }
626
597
  return;
627
598
  }
628
599
  if (e.message === "已屏蔽专栏动态") {
629
600
  if (this.config.filter.notify) {
630
- await this.broadcastToTargets(sub.target, `${upName}投稿了一条专栏,已屏蔽`, type_1.PushType.Dynamic);
601
+ await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, type_1.PushType.Dynamic);
631
602
  }
632
603
  return;
633
604
  }
@@ -643,8 +614,13 @@ class ComRegister {
643
614
  let dUrl = "";
644
615
  // 判断是否需要发送URL
645
616
  if (this.config.dynamicUrl) {
646
- // 生成动态链接
647
- dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`;
617
+ if (item.type === "DYNAMIC_TYPE_AV") {
618
+ dUrl = `${name}发布了新视频:${item.modules.module_dynamic.major.archive.jump_url}`;
619
+ }
620
+ else {
621
+ // 生成动态链接
622
+ dUrl = `${name}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
623
+ }
648
624
  }
649
625
  // logger
650
626
  this.logger.info("推送动态中...");
@@ -661,74 +637,31 @@ class ComRegister {
661
637
  }
662
638
  }
663
639
  }
640
+ // 将当前动态存入currentPushDyn
641
+ currentPushDyn[uid] = item;
664
642
  // logger
665
643
  this.logger.info("动态推送完毕!");
666
644
  }
667
645
  }
668
646
  }
669
- // 更新本次请求第一条动态的动态ID
670
- dynamicIdStr1st = items[0].id_str;
671
- // 更新时间线
672
- timeline =
673
- items[0].modules.module_author.pub_ts || luxon_1.DateTime.now().toSeconds();
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);
653
+ }
674
654
  };
675
655
  // 返回一个闭包函数
676
656
  return (0, utils_1.withLock)(handler);
677
657
  }
678
658
  debug_dynamicDetect() {
679
- // 检测初始化变量
680
- let detectSetup = true;
681
- // 时间线
682
- let timeline;
683
- // 第一条动态的动态ID
684
- let dynamicIdStr1st;
685
659
  // 定义handler
686
660
  const handler = async () => {
687
- // 动态监测启动初始化
688
- if (detectSetup) {
689
- // logger
690
- this.logger.info("动态监测初始化中...");
691
- // logger
692
- this.logger.info("正在获取动态信息...");
693
- // 使用withRetry函数进行重试
694
- const content = await (0, utils_1.withRetry)(async () => {
695
- // 获取动态内容
696
- return (await this.ctx.ba.getAllDynamic());
697
- }, 1).catch((e) => {
698
- // logger
699
- this.logger.error(`dynamicDetect getAllDynamic() 发生了错误,错误为:${e.message}`);
700
- });
701
- // content不存在则直接返回
702
- if (!content) {
703
- // logger
704
- this.logger.info("获取动态信息失败!");
705
- return;
706
- }
707
- // 判断获取动态信息是否成功
708
- if (content.code !== 0) {
709
- // logger
710
- this.logger.info("获取动态信息失败!");
711
- return;
712
- }
713
- // 设置第一条动态的动态ID
714
- dynamicIdStr1st = content.data?.items[0]?.id_str || "0";
715
- // logger
716
- this.logger.info(`获取到第一条动态ID:${dynamicIdStr1st}`);
717
- // 设置时间线
718
- timeline =
719
- content.data?.items[0]?.modules.module_author.pub_ts ||
720
- luxon_1.DateTime.now().toSeconds();
721
- // logger
722
- this.logger.info(`获取到时间线信息:${timeline}`);
723
- // 设置初始化为false
724
- detectSetup = false;
725
- // logger
726
- this.logger.info("动态监测初始化完毕!");
727
- // 初始化完成
728
- return;
729
- }
661
+ // 定义本次请求推送的动态
662
+ const currentPushDyn = {};
730
663
  // logger
731
- this.logger.info("正在获取动态信息...");
664
+ this.logger.info("开始获取动态信息...");
732
665
  // 使用withRetry函数进行重试
733
666
  const content = await (0, utils_1.withRetry)(async () => {
734
667
  // 获取动态内容
@@ -738,11 +671,8 @@ class ComRegister {
738
671
  this.logger.error(`dynamicDetect getAllDynamic() 发生了错误,错误为:${e.message}`);
739
672
  });
740
673
  // content不存在则直接返回
741
- if (!content) {
742
- // logger
743
- this.logger.info("获取动态信息失败!");
674
+ if (!content)
744
675
  return;
745
- }
746
676
  // 判断获取动态内容是否成功
747
677
  if (content.code !== 0) {
748
678
  switch (content.code) {
@@ -788,64 +718,37 @@ class ComRegister {
788
718
  }
789
719
  }
790
720
  // logger
791
- this.logger.info("成功获取动态信息!开始检查更新的动态...");
721
+ this.logger.info("获取动态信息成功!开始处理动态信息...");
792
722
  // 获取动态内容
793
723
  const items = content.data.items;
794
724
  // 检查更新的动态
795
725
  for (const item of items) {
796
726
  // 没有动态内容则直接跳过
797
- if (!item) {
798
- // logger
799
- this.logger.info("动态内容为空,跳过该动态");
727
+ if (!item)
800
728
  continue;
801
- }
802
- // 获取动态ID
803
- const dynamicId = item.id_str;
804
- // logger
805
- this.logger.info(`当前动态ID:${dynamicId}`);
806
- this.logger.info(`上一次获取到第一条动态ID:${dynamicId}`);
807
- // 动态ID如果一致则结束循环
808
- if (dynamicId === dynamicIdStr1st) {
809
- // logger
810
- this.logger.info("动态ID与上一次获取第一条一致,结束循环");
811
- break;
812
- }
813
729
  // 获取动态发布时间
814
730
  const postTime = item.modules.module_author.pub_ts;
815
- // logger
816
- this.logger.info(`当前动态时间线:${postTime}`);
817
- // logger
818
- this.logger.info(`上一次获取到第一条动态时间线:${timeline}`);
819
- // logger
820
- this.logger.info(`当前动态发布时间:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
821
- // logger
822
- this.logger.info(`上一次获取到第一条动态发布时间:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
823
- // timeline已超过或与当前动态时间戳相同,则后面的动态不需要推送
824
- if (postTime <= timeline) {
825
- // logger
826
- this.logger.info("当前动态时间戳已小于等于上一次获取到第一条动态时间线,更晚发布的动态无需监测");
827
- // 结束本次监测
828
- break;
829
- }
830
- // logger
831
- this.logger.info("动态时间线大于上一次获取到第一条动态时间线,开始判断是否是订阅的UP主...");
832
731
  // 从动态数据中取出UP主名称、UID
833
- const upUID = item.modules.module_author.mid.toString();
834
- const upName = item.modules.module_author.name;
732
+ const uid = item.modules.module_author.mid.toString();
733
+ const name = item.modules.module_author.name;
835
734
  // logger
836
- this.logger.info(`当前动态UP主UID:${upUID},UP主名称:${upName}`);
837
- // 定义是否是订阅的UP主flag
838
- let isSubscribed = false;
839
- // 寻找关注的UP主的动态
840
- for (const sub of this.subManager) {
841
- // 判断是否是订阅的UP主
842
- if (sub.dynamic && sub.uid === upUID) {
843
- // 将flag设置为true
844
- isSubscribed = true;
845
- // logger:订阅该UP主,推送该动态
846
- 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];
847
750
  // logger
848
- this.logger.info("开始生成推送卡片...");
751
+ this.logger.info("开始渲染推送卡片...");
849
752
  // 推送该条动态
850
753
  const buffer = await (0, utils_1.withRetry)(async () => {
851
754
  // 渲染图片
@@ -857,13 +760,19 @@ class ComRegister {
857
760
  if (e.message === "出现关键词,屏蔽该动态") {
858
761
  // 如果需要发送才发送
859
762
  if (this.config.filter.notify) {
860
- await this.broadcastToTargets(sub.target, `${upName}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
763
+ await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
861
764
  }
862
765
  return;
863
766
  }
864
767
  if (e.message === "已屏蔽转发动态") {
865
768
  if (this.config.filter.notify) {
866
- 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);
867
776
  }
868
777
  return;
869
778
  }
@@ -873,20 +782,26 @@ class ComRegister {
873
782
  await this.sendPrivateMsgAndStopService();
874
783
  });
875
784
  // 判断是否执行成功,未执行成功直接返回
876
- if (!buffer) {
877
- // logger
878
- this.logger.info("推送卡片生成失败,或该动态为屏蔽动态,跳过该动态!");
879
- // 结束循环
785
+ if (!buffer)
880
786
  continue;
881
- }
787
+ // logger
788
+ this.logger.info("渲染推送卡片成功!");
882
789
  // 定义动态链接
883
790
  let dUrl = "";
884
791
  // 判断是否需要发送URL
885
792
  if (this.config.dynamicUrl) {
886
793
  // logger
887
- this.logger.info("生成动态链接中...");
888
- // 生成动态链接
889
- dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`;
794
+ this.logger.info("需要发送动态链接,开始生成链接...");
795
+ // 判断动态类型
796
+ if (item.type === "DYNAMIC_TYPE_AV") {
797
+ dUrl = `${name}发布了新视频:${item.modules.module_dynamic.major.archive.jump_url}`;
798
+ }
799
+ else {
800
+ // 生成动态链接
801
+ dUrl = `${name}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
802
+ }
803
+ // logger
804
+ this.logger.info("动态链接生成成功!");
890
805
  }
891
806
  // logger
892
807
  this.logger.info("推送动态中...");
@@ -895,7 +810,7 @@ class ComRegister {
895
810
  // 判断是否需要发送动态中的图片
896
811
  if (this.config.pushImgsInDynamic) {
897
812
  // logger
898
- this.logger.info("开始推送动态中的图片...");
813
+ this.logger.info("需要发送动态中的图片,开始发送...");
899
814
  // 判断是否为图文动态,且存在draw
900
815
  if (item.type === "DYNAMIC_TYPE_DRAW" &&
901
816
  item.modules.module_dynamic.major?.draw) {
@@ -905,30 +820,28 @@ class ComRegister {
905
820
  }
906
821
  }
907
822
  // logger
908
- this.logger.info("图片推送完毕!");
823
+ this.logger.info("动态中的图片发送完毕!");
909
824
  }
825
+ // 将当前动态存入currentPushDyn
826
+ currentPushDyn[uid] = item;
910
827
  // logger
911
828
  this.logger.info("动态推送完毕!");
912
829
  }
913
830
  }
914
- if (!isSubscribed) {
915
- // logger
916
- this.logger.info("不是关注的UP主,跳过该动态");
917
- }
918
831
  }
919
- // 更新本次请求第一条动态的动态ID
920
- dynamicIdStr1st = items[0].id_str;
921
- // logger
922
- this.logger.info(`更新本次请求第一条动态的动态ID:${dynamicIdStr1st}`);
923
- // 更新时间线
924
- timeline =
925
- items[0].modules.module_author.pub_ts || luxon_1.DateTime.now().toSeconds();
926
832
  // logger
927
- this.logger.info(`更新时间线:${timeline}`);
928
- // logger
929
- this.logger.info(`时间线格式化:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
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);
840
+ // logger
841
+ this.logger.info(`更新时间线成功,UP主:${uid},时间线:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
842
+ }
930
843
  // logger
931
- this.logger.info("动态监测完成,等待下一次检测...");
844
+ this.logger.info(`本次推送动态数量:${Object.keys(currentPushDyn).length}`);
932
845
  };
933
846
  // 返回一个闭包函数
934
847
  return (0, utils_1.withLock)(handler);
@@ -1427,10 +1340,8 @@ class ComRegister {
1427
1340
  return { code: 0, msg: "订阅对象添加成功" };
1428
1341
  },
1429
1342
  };
1430
- // 获取函数
1431
- const func = subUserMatchPattern[subUserData.code];
1432
1343
  // 执行函数并返回
1433
- return await func();
1344
+ return await subUserMatchPattern[subUserData.code]();
1434
1345
  }
1435
1346
  async loadSubFromConfig(subs) {
1436
1347
  for (const sub of subs) {
@@ -1501,10 +1412,12 @@ class ComRegister {
1501
1412
  this.enableDynamicDetect();
1502
1413
  }
1503
1414
  enableDynamicDetect() {
1504
- // 开始动态监测
1505
- this.dynamicDispose = this.ctx.cron("*/2 * * * *", this.config.dynamicDebugMode
1415
+ // 定义Job
1416
+ this.dynamicJob = new cron_1.CronJob("*/2 * * * *", this.config.dynamicDebugMode
1506
1417
  ? this.debug_dynamicDetect()
1507
1418
  : this.dynamicDetect());
1419
+ // 开始动态监测
1420
+ this.dynamicJob.start();
1508
1421
  }
1509
1422
  async checkIfIsLogin() {
1510
1423
  if ((await this.ctx.database.get("loginBili", 1)).length !== 0) {
@@ -1520,7 +1433,6 @@ class ComRegister {
1520
1433
  }
1521
1434
  (function (ComRegister) {
1522
1435
  ComRegister.Config = koishi_1.Schema.object({
1523
- subLoadTimeout: koishi_1.Schema.number(),
1524
1436
  sub: koishi_1.Schema.array(koishi_1.Schema.object({
1525
1437
  uid: koishi_1.Schema.string().description("订阅用户UID"),
1526
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"),
@@ -75,12 +75,25 @@ export type AllDynamicInfo = {
75
75
  };
76
76
  module_dynamic: {
77
77
  major: {
78
- draw: {
78
+ draw?: {
79
79
  items: Array<{
80
80
  src: string;
81
81
  alt: string;
82
82
  }>;
83
83
  };
84
+ archive?: {
85
+ aid: string;
86
+ badge: Object;
87
+ bvid: string;
88
+ cover: string;
89
+ desc: string;
90
+ disable_preview: number;
91
+ duration_text: string;
92
+ jump_url: string;
93
+ stat: string;
94
+ title: string;
95
+ type: number;
96
+ };
84
97
  };
85
98
  };
86
99
  };
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.3-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
@@ -236,6 +236,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
236
236
  - ver 3.1.1-alpha.0 修复:稿件重投后,会将之前日期的动态一起推送; 优化:加强动态debug输出; 移除:不必要选项 `live.liveDetectMode`
237
237
  - ver 3.1.2-alpha.0 重构:对消息发送模块进行小型重构,多群多平台推送将不再支持艾特全体成员,仅单平台单群聊支持; 移除:群聊 `all` 选项
238
238
  - ver 3.1.3-alpha.0 移除:订阅超时; 新增:屏蔽专栏动态功能; 优化:改进了加载插件的错误提示;
239
+ - ver 3.1.4-alpha.0 修复:动态只推送视频; 优化:动态视频链接将直接发送为视频链接;
240
+ - ver 3.1.5-alpha.0 修复:潜在动态推送bug; 优化:现在动态监测无需等待,当插件初始化完成即开始监测、移除多余依赖、移除对 `cron` 服务的依赖、移除选项 `超时订阅`
239
241
 
240
242
  ## 交流群
241
243
 
@@ -249,6 +251,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
249
251
 
250
252
  [bilibili-API-collect](https://github.com/SocialSisterYi/bilibili-API-collect) 感谢 `SocialSisterYi` 提供B站API参考
251
253
 
254
+ [bilibili-dynamic-mirai-plugin](https://github.com/Colter23/bilibili-dynamic-mirai-plugin) 感谢 `Colter23` 提供推送卡片灵感参考
255
+
252
256
  ## License
253
257
 
254
258
  MIT