koishi-plugin-bilibili-notify 3.3.1-alpha.0 → 3.3.1-rc.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.
package/lib/index.mjs CHANGED
@@ -45,7 +45,7 @@ const BAConfigSchema = Schema.object({
45
45
  "satori",
46
46
  "chronocat",
47
47
  "lark"
48
- ]).description("请选择您的私人机器人平台,目前支持QQ、QQ群、OneBot、Discord、RedBot、Telegram、Satori、ChronoCat、Lark。从2.0版本开始,只能在一个平台下使用本插件"),
48
+ ]).description("请选择您的私人机器人平台"),
49
49
  masterAccount: Schema.string().role("secret").required().description("主人账号,在Q群使用可直接使用QQ号,若在其他平台使用,请使用inspect插件获取自身ID"),
50
50
  masterAccountGuildId: Schema.string().role("secret").description("主人账号所在的群组ID,只有在QQ频道、Discord这样的环境才需要填写,请使用inspect插件获取群组ID")
51
51
  }), Schema.object({})])]),
@@ -62,6 +62,7 @@ const BAConfigSchema = Schema.object({
62
62
  liveAtAll: Schema.boolean().default(true).description("直播At全体"),
63
63
  liveGuardBuy: Schema.boolean().default(false).description("上舰消息"),
64
64
  wordcloud: Schema.boolean().default(true).description("弹幕词云"),
65
+ liveSummary: Schema.boolean().default(true).description("直播总结"),
65
66
  platform: Schema.string().required().description("平台名"),
66
67
  target: Schema.string().required().description("群号/频道号")
67
68
  })).role("table").description("输入订阅信息,自定义订阅内容; 群号/频道号格式:频道号,频道号 使用英文逗号分隔,例如 1234567,2345678"),
@@ -172,7 +173,7 @@ let PushType = /* @__PURE__ */ function(PushType$1) {
172
173
  PushType$1[PushType$1["DynamicAtAll"] = 2] = "DynamicAtAll";
173
174
  PushType$1[PushType$1["StartBroadcasting"] = 3] = "StartBroadcasting";
174
175
  PushType$1[PushType$1["LiveGuardBuy"] = 4] = "LiveGuardBuy";
175
- PushType$1[PushType$1["WordCloud"] = 5] = "WordCloud";
176
+ PushType$1[PushType$1["WordCloudAndLiveSummary"] = 5] = "WordCloudAndLiveSummary";
176
177
  return PushType$1;
177
178
  }({});
178
179
  const PushTypeMsg = {
@@ -181,7 +182,7 @@ const PushTypeMsg = {
181
182
  [PushType.DynamicAtAll]: "动态推送+At全体",
182
183
  [PushType.StartBroadcasting]: "开播推送",
183
184
  [PushType.LiveGuardBuy]: "上舰推送",
184
- [PushType.WordCloud]: "弹幕词云推送"
185
+ [PushType.WordCloudAndLiveSummary]: "弹幕词云和直播总结推送"
185
186
  };
186
187
 
187
188
  //#endregion
@@ -344,17 +345,18 @@ var ComRegister = class {
344
345
  rebootCount = 0;
345
346
  subNotifier;
346
347
  ctx;
347
- subManager = [];
348
- dynamicTimelineManager = new Map();
349
- liveStatusManager = new Map();
350
- liveMsgManager = new Map();
351
- pushArrMap = new Map();
348
+ subManager;
349
+ dynamicTimelineManager;
350
+ liveStatusManager;
351
+ liveMsgManager;
352
+ pushArrMap;
352
353
  loginDBData;
353
354
  privateBot;
354
355
  dynamicJob;
355
356
  liveJob;
356
357
  _jieba = Jieba.withDict(dict);
357
358
  stopwords;
359
+ reciveSubTimes = 0;
358
360
  constructor(ctx, config) {
359
361
  this.ctx = ctx;
360
362
  this.init(config);
@@ -454,16 +456,16 @@ var ComRegister = class {
454
456
  biliCom.subcommand(".ll").usage("展示当前正在直播的订阅对象").example("bili ll").action(async () => {
455
457
  const { data: { live_users } } = await ctx["bilibili-notify-api"].getTheUserWhoIsLiveStreaming();
456
458
  const subLiveUsers = [];
457
- for (const sub of this.subManager) {
459
+ for (const [uid, sub] of this.subManager) {
458
460
  let onLive = false;
459
461
  if (live_users.items) {
460
- for (const user of live_users.items) if (user.mid.toString() === sub.uid && sub.live) {
462
+ for (const user of live_users.items) if (user.mid.toString() === uid && sub.live) {
461
463
  onLive = true;
462
464
  break;
463
465
  }
464
466
  }
465
467
  subLiveUsers.push({
466
- uid: Number.parseInt(sub.uid),
468
+ uid: Number.parseInt(uid),
467
469
  uname: sub.uname,
468
470
  onLive
469
471
  });
@@ -592,7 +594,7 @@ var ComRegister = class {
592
594
  ["初中", 4],
593
595
  ["毕业", 4]
594
596
  ];
595
- await session.send(/* @__PURE__ */ jsx("message", { children: h.image(await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(words, "词云测试"), "image/jpg") }));
597
+ const img = h.image(await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(words, "词云测试"), "image/jpg");
596
598
  const top5DanmakuMaker = [
597
599
  ["张三", 60],
598
600
  ["李四", 48],
@@ -600,8 +602,8 @@ var ComRegister = class {
600
602
  ["赵六", 27],
601
603
  ["田七", 25]
602
604
  ];
603
- const danmakerRankMsg = this.config.liveSummary.join("\n").replace("-dmc", "114").replace("-mdn", "特工").replace("-dca", "514").replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
604
- await session.send(danmakerRankMsg);
605
+ const summary = this.config.liveSummary.join("\n").replace("-dmc", "114").replace("-mdn", "特工").replace("-dca", "514").replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
606
+ await session.send(/* @__PURE__ */ jsxs("message", { children: [img, summary] }));
605
607
  });
606
608
  biliCom.subcommand(".cap").action(async ({ session }) => {
607
609
  const { code: userInfoCode, data: userInfoData } = await withRetry(async () => {
@@ -623,7 +625,10 @@ var ComRegister = class {
623
625
  const seccode = `${validate}|jordan`;
624
626
  const { data: validateCaptchaData } = await ctx["bilibili-notify-api"].validateCaptcha(data.geetest.challenge, data.token, validate, seccode);
625
627
  if (validateCaptchaData?.is_valid !== 1) return "验证不成功!";
626
- return "验证成功!请重启插件";
628
+ await this.ctx.sleep(10 * 1e3);
629
+ const { code: validCode, data: validData } = await ctx["bilibili-notify-api"].getUserInfo("114514", validateCaptchaData.grisk_id);
630
+ if (validCode === -352 && validData.v_voucher) return "验证不成功!";
631
+ await session.send("验证成功!请重启插件");
627
632
  });
628
633
  }
629
634
  async init(config) {
@@ -639,25 +644,30 @@ var ComRegister = class {
639
644
  return;
640
645
  }
641
646
  this.mergeStopWords(config.wordcloudStopWords);
642
- if (config.advancedSub) {
643
- this.ctx.on("bilibili-notify/advanced-sub", async (subs) => {
644
- await this.initAsyncPart(subs);
645
- });
646
- this.ctx.emit("bilibili-notify/ready-to-recive");
647
- } else if (config.subs && config.subs.length > 0) {
647
+ this.registeringForEvents();
648
+ if (config.advancedSub) this.ctx.emit("bilibili-notify/ready-to-recive");
649
+ else if (config.subs && config.subs.length > 0) {
648
650
  const subs = this.configSubsToSubscription(config.subs);
649
651
  await this.initAsyncPart(subs);
650
- } else this.logger.info("插件初始化完毕!");
652
+ }
653
+ }
654
+ registeringForEvents() {
651
655
  this.ctx.on("dispose", () => {
652
656
  if (this.loginTimer) this.loginTimer();
653
657
  if (this.dynamicJob) this.dynamicJob.stop();
654
658
  if (this.liveJob) this.liveJob.stop();
655
659
  });
660
+ this.ctx.on("bilibili-notify/advanced-sub", async (subs) => {
661
+ if (this.reciveSubTimes >= 1) await this.ctx["bilibili-notify"].restartPlugin();
662
+ else await this.initAsyncPart(subs);
663
+ this.reciveSubTimes++;
664
+ });
656
665
  }
657
666
  async initAsyncPart(subs) {
658
- const { code, msg } = await this.loadSubFromConfig(subs);
667
+ this.initAllManager();
668
+ const { code, message } = await this.loadSubFromConfig(subs);
659
669
  if (code !== 0) {
660
- this.logger.error(msg);
670
+ this.logger.error(message);
661
671
  this.logger.error("订阅对象加载失败,插件初始化失败!");
662
672
  await this.sendPrivateMsg("订阅对象加载失败,插件初始化失败!");
663
673
  return;
@@ -677,9 +687,9 @@ var ComRegister = class {
677
687
  this.stopwords = new Set([...stop_words_default, ...additionalStopWords]);
678
688
  }
679
689
  initManager() {
680
- for (const sub of this.subManager) {
681
- if (sub.dynamic) this.dynamicTimelineManager.set(sub.uid, Math.floor(DateTime.now().toSeconds()));
682
- if (sub.live) this.liveStatusManager.set(sub.uid, {
690
+ for (const [uid, sub] of this.subManager) {
691
+ if (sub.dynamic) this.dynamicTimelineManager.set(uid, Math.floor(DateTime.now().toSeconds()));
692
+ if (sub.live) this.liveStatusManager.set(uid, {
683
693
  roomId: sub.roomId,
684
694
  live: false,
685
695
  liveRoomInfo: void 0,
@@ -691,6 +701,13 @@ var ComRegister = class {
691
701
  });
692
702
  }
693
703
  }
704
+ initAllManager() {
705
+ this.subManager = new Map();
706
+ this.dynamicTimelineManager = new Map();
707
+ this.liveStatusManager = new Map();
708
+ this.liveMsgManager = new Map();
709
+ this.pushArrMap = new Map();
710
+ }
694
711
  configSubsToSubscription(sub) {
695
712
  const subs = {};
696
713
  sub.forEach((s) => {
@@ -702,6 +719,7 @@ var ComRegister = class {
702
719
  liveAtAll: s.liveAtAll,
703
720
  liveGuardBuy: s.liveGuardBuy,
704
721
  wordcloud: s.wordcloud,
722
+ liveSummary: s.liveSummary,
705
723
  bot: null
706
724
  }));
707
725
  const target = [{
@@ -712,11 +730,10 @@ var ComRegister = class {
712
730
  uid: s.uid,
713
731
  dynamic: s.dynamic,
714
732
  live: s.live,
715
- wordcloud: s.wordcloud,
716
733
  target,
717
- card: { enable: false },
718
- liveMsg: { enable: false },
719
- liveSummary: { enable: false }
734
+ customCardStyle: { enable: false },
735
+ customLiveMsg: { enable: false },
736
+ customLiveSummary: { enable: false }
720
737
  };
721
738
  });
722
739
  return subs;
@@ -772,12 +789,12 @@ var ComRegister = class {
772
789
  customLiveEnd: this.config.customLiveEnd || "",
773
790
  liveSummary: this.config.liveSummary.join("\n") || ""
774
791
  };
775
- if (sub.liveMsg.enable) {
776
- liveMsg.customLiveStart = sub.liveMsg.customLiveStart || this.config.customLiveStart;
777
- liveMsg.customLive = sub.liveMsg.customLive || this.config.customLive;
778
- liveMsg.customLiveEnd = sub.liveMsg.customLiveEnd || this.config.customLiveEnd;
792
+ if (sub.customLiveMsg.enable) {
793
+ liveMsg.customLiveStart = sub.customLiveMsg.customLiveStart || this.config.customLiveStart;
794
+ liveMsg.customLive = sub.customLiveMsg.customLive || this.config.customLive;
795
+ liveMsg.customLiveEnd = sub.customLiveMsg.customLiveEnd || this.config.customLiveEnd;
779
796
  }
780
- if (sub.liveSummary.enable) liveMsg.liveSummary = sub.liveSummary.liveSummary || this.config.liveSummary.join("\n");
797
+ if (sub.customLiveSummary.enable) liveMsg.liveSummary = sub.customLiveSummary.liveSummary || this.config.liveSummary.join("\n");
781
798
  this.liveMsgManager.set(sub.uid, liveMsg);
782
799
  const dynamicArr = [];
783
800
  const dynamicAtAllArr = [];
@@ -785,6 +802,7 @@ var ComRegister = class {
785
802
  const liveAtAllArr = [];
786
803
  const liveGuardBuyArr = [];
787
804
  const wordcloudArr = [];
805
+ const liveSummaryArr = [];
788
806
  for (const platform of sub.target) for (const channel of platform.channelArr) {
789
807
  const target = `${platform.platform}:${channel.channelId}`;
790
808
  if (channel.dynamic) dynamicArr.push(target);
@@ -793,12 +811,14 @@ var ComRegister = class {
793
811
  if (channel.liveAtAll) liveAtAllArr.push(target);
794
812
  if (channel.liveGuardBuy) liveGuardBuyArr.push(target);
795
813
  if (channel.wordcloud) wordcloudArr.push(target);
814
+ if (channel.liveSummary) liveSummaryArr.push(target);
796
815
  }
797
816
  this.pushArrMap.set(sub.uid, {
798
817
  dynamicArr,
799
818
  dynamicAtAllArr,
800
819
  liveArr,
801
820
  liveAtAllArr,
821
+ liveSummaryArr,
802
822
  liveGuardBuyArr,
803
823
  wordcloudArr
804
824
  });
@@ -860,15 +880,37 @@ var ComRegister = class {
860
880
  }, 1);
861
881
  this.logger.info(`成功推送上舰消息:${success.length}条`);
862
882
  }
863
- if (type === PushType.WordCloud && record.wordcloudArr?.length >= 1) {
864
- this.logger.info(record.wordcloudArr);
883
+ if (type === PushType.WordCloudAndLiveSummary) {
865
884
  const wordcloudArr = structuredClone(record.wordcloudArr);
866
- const success = await withRetry(async () => {
867
- return await this.ctx.broadcast(wordcloudArr, /* @__PURE__ */ jsx("message", { children: content }));
868
- }, 1);
869
- this.logger.info(`成功推送词云消息:${success.length}条`);
885
+ const liveSummaryArr = structuredClone(record.liveSummaryArr);
886
+ const wordcloudAndLiveSummaryArr = wordcloudArr.filter((item) => liveSummaryArr.includes(item));
887
+ const wordcloudOnlyArr = wordcloudArr.filter((item) => !liveSummaryArr.includes(item));
888
+ const liveSummaryOnlyArr = liveSummaryArr.filter((item) => !wordcloudArr.includes(item));
889
+ if (wordcloudAndLiveSummaryArr.length > 0) {
890
+ this.logger.info("词云和直播总结");
891
+ this.logger.info(wordcloudAndLiveSummaryArr);
892
+ const success = await withRetry(async () => {
893
+ return await this.ctx.broadcast(wordcloudAndLiveSummaryArr, /* @__PURE__ */ jsxs("message", { children: [content[0], content[1]] }));
894
+ }, 1);
895
+ this.logger.info(`成功推送词云和直播总结消息:${success.length}条`);
896
+ }
897
+ if (wordcloudOnlyArr.length > 0) {
898
+ this.logger.info("词云");
899
+ this.logger.info(wordcloudOnlyArr);
900
+ const success = await withRetry(async () => {
901
+ return await this.ctx.broadcast(wordcloudOnlyArr, /* @__PURE__ */ jsx("message", { children: content[0] }));
902
+ }, 1);
903
+ this.logger.info(`成功推送词云消息:${success.length}条`);
904
+ }
905
+ if (liveSummaryOnlyArr.length > 0) {
906
+ this.logger.info("直播总结");
907
+ this.logger.info(liveSummaryOnlyArr);
908
+ const success = await withRetry(async () => {
909
+ return await this.ctx.broadcast(liveSummaryOnlyArr, /* @__PURE__ */ jsx("message", { children: content[1] }));
910
+ }, 1);
911
+ this.logger.info(`成功推送直播总结消息:${success.length}条`);
912
+ }
870
913
  }
871
- return;
872
914
  }
873
915
  dynamicDetect() {
874
916
  const handler = async () => {
@@ -912,21 +954,21 @@ var ComRegister = class {
912
954
  if (this.dynamicTimelineManager.has(uid)) {
913
955
  const timeline = this.dynamicTimelineManager.get(uid);
914
956
  if (timeline < postTime) {
915
- const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
957
+ const sub = this.subManager.get(uid);
916
958
  const buffer = await withRetry(async () => {
917
- return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.card.enable ? sub.card : void 0);
959
+ return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.customCardStyle.enable ? sub.customCardStyle : void 0);
918
960
  }, 1).catch(async (e) => {
919
961
  if (e.message === "直播开播动态,不做处理") return;
920
962
  if (e.message === "出现关键词,屏蔽该动态") {
921
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
963
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
922
964
  return;
923
965
  }
924
966
  if (e.message === "已屏蔽转发动态") {
925
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
967
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
926
968
  return;
927
969
  }
928
970
  if (e.message === "已屏蔽专栏动态") {
929
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
971
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
930
972
  return;
931
973
  }
932
974
  this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
@@ -940,7 +982,7 @@ var ComRegister = class {
940
982
  } else dUrl = `${name$2}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
941
983
  else dUrl = `${name$2}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
942
984
  this.logger.info("推送动态中...");
943
- await this.broadcastToTargets(sub.uid, /* @__PURE__ */ jsxs("message", { children: [h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
985
+ await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
944
986
  if (this.config.pushImgsInDynamic) {
945
987
  if (item.type === "DYNAMIC_TYPE_DRAW") {
946
988
  const pics = item.modules?.module_dynamic?.major?.opus?.pics;
@@ -952,7 +994,7 @@ var ComRegister = class {
952
994
  alt: "动态图片"
953
995
  }, pic.url))
954
996
  });
955
- await this.broadcastToTargets(sub.uid, picsMsg, PushType.Dynamic);
997
+ await this.broadcastToTargets(uid, picsMsg, PushType.Dynamic);
956
998
  }
957
999
  }
958
1000
  }
@@ -1016,22 +1058,22 @@ var ComRegister = class {
1016
1058
  this.logger.info(`上次推送时间线:${DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
1017
1059
  if (timeline < postTime) {
1018
1060
  this.logger.info("需要推送该条动态,开始推送...");
1019
- const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
1061
+ const sub = this.subManager.get(uid);
1020
1062
  this.logger.info("开始渲染推送卡片...");
1021
1063
  const buffer = await withRetry(async () => {
1022
- return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.card.enable ? sub.card : void 0);
1064
+ return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.customCardStyle.enable ? sub.customCardStyle : void 0);
1023
1065
  }, 1).catch(async (e) => {
1024
1066
  if (e.message === "直播开播动态,不做处理") return;
1025
1067
  if (e.message === "出现关键词,屏蔽该动态") {
1026
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
1068
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
1027
1069
  return;
1028
1070
  }
1029
1071
  if (e.message === "已屏蔽转发动态") {
1030
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
1072
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
1031
1073
  return;
1032
1074
  }
1033
1075
  if (e.message === "已屏蔽专栏动态") {
1034
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
1076
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
1035
1077
  return;
1036
1078
  }
1037
1079
  this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
@@ -1050,7 +1092,7 @@ var ComRegister = class {
1050
1092
  this.logger.info("动态链接生成成功!");
1051
1093
  }
1052
1094
  this.logger.info("推送动态中...");
1053
- await this.broadcastToTargets(sub.uid, /* @__PURE__ */ jsxs("message", { children: [h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
1095
+ await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
1054
1096
  if (this.config.pushImgsInDynamic) {
1055
1097
  this.logger.info("需要发送动态中的图片,开始发送...");
1056
1098
  if (item.type === "DYNAMIC_TYPE_DRAW") {
@@ -1063,7 +1105,7 @@ var ComRegister = class {
1063
1105
  alt: "动态图片"
1064
1106
  }, pic.url))
1065
1107
  });
1066
- await this.broadcastToTargets(sub.uid, picsMsg, PushType.Dynamic);
1108
+ await this.broadcastToTargets(uid, picsMsg, PushType.Dynamic);
1067
1109
  }
1068
1110
  }
1069
1111
  this.logger.info("动态中的图片发送完毕!");
@@ -1144,7 +1186,7 @@ var ComRegister = class {
1144
1186
  let masterInfo;
1145
1187
  let watchedNum;
1146
1188
  const liveMsgObj = this.liveMsgManager.get(sub.uid);
1147
- const sendDanmakuWordCloud = async (liveSummary) => {
1189
+ const sendDanmakuWordCloudAndLiveSummary = async (customLiveSummary) => {
1148
1190
  this.logger.info("开始制作弹幕词云");
1149
1191
  this.logger.info("正在获取前90热词");
1150
1192
  const top90Words = Object.entries(danmakuWeightRecord).sort((a, b) => b[1] - a[1]).slice(0, 90);
@@ -1152,15 +1194,13 @@ var ComRegister = class {
1152
1194
  this.logger.info(top90Words);
1153
1195
  this.logger.info("正在准备生成弹幕词云");
1154
1196
  const buffer = await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(top90Words, masterInfo.username);
1155
- this.logger.info("弹幕词云生成完成,正在准备发送词云图片");
1156
- await this.broadcastToTargets(sub.uid, h.image(buffer, "image/jpeg"), PushType.Live);
1157
- this.logger.info("词云图片发送完毕!");
1197
+ const img = h.image(buffer, "image/jpeg");
1158
1198
  this.logger.info("开始构建弹幕发送排行榜消息");
1159
1199
  const danmakuMakerCount = Object.keys(danmakuMakerRecord).length;
1160
1200
  const danmakuCount = Object.values(danmakuMakerRecord).reduce((sum, val) => sum + val, 0);
1161
1201
  const top5DanmakuMaker = Object.entries(danmakuMakerRecord).sort((a, b) => b[1] - a[1]).slice(0, 5);
1162
- const danmakuMakerMsg = liveSummary.replace("-dmc", `${danmakuMakerCount}`).replace("-mdn", `${masterInfo.medalName}`).replace("-dca", `${danmakuCount}`).replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
1163
- await this.broadcastToTargets(sub.uid, danmakuMakerMsg, PushType.WordCloud);
1202
+ const summary = customLiveSummary.replace("-dmc", `${danmakuMakerCount}`).replace("-mdn", `${masterInfo.medalName}`).replace("-dca", `${danmakuCount}`).replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
1203
+ await this.broadcastToTargets(sub.uid, [img, summary], PushType.WordCloudAndLiveSummary);
1164
1204
  Object.keys(danmakuWeightRecord).forEach((key) => delete danmakuWeightRecord[key]);
1165
1205
  Object.keys(danmakuMakerRecord).forEach((key) => delete danmakuMakerRecord[key]);
1166
1206
  };
@@ -1181,7 +1221,7 @@ var ComRegister = class {
1181
1221
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1182
1222
  liveRoomInfo,
1183
1223
  masterInfo,
1184
- cardStyle: sub.card
1224
+ cardStyle: sub.customCardStyle
1185
1225
  }, sub.uid, liveMsg);
1186
1226
  };
1187
1227
  const useMasterAndLiveRoomInfo = async (liveType) => {
@@ -1245,7 +1285,7 @@ var ComRegister = class {
1245
1285
  await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1246
1286
  liveRoomInfo,
1247
1287
  masterInfo,
1248
- cardStyle: sub.card
1288
+ cardStyle: sub.customCardStyle
1249
1289
  }, sub.uid, liveStartMsg);
1250
1290
  if (this.config.pushTime !== 0 && !pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1251
1291
  },
@@ -1265,11 +1305,11 @@ var ComRegister = class {
1265
1305
  await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1266
1306
  liveRoomInfo,
1267
1307
  masterInfo,
1268
- cardStyle: sub.card
1308
+ cardStyle: sub.customCardStyle
1269
1309
  }, sub.uid, liveEndMsg);
1270
1310
  pushAtTimeTimer();
1271
1311
  pushAtTimeTimer = null;
1272
- if (sub.wordcloud) await sendDanmakuWordCloud(liveMsgObj.liveSummary);
1312
+ await sendDanmakuWordCloudAndLiveSummary(liveMsgObj.liveSummary);
1273
1313
  }
1274
1314
  };
1275
1315
  await this.ctx["bilibili-notify-live"].startLiveRoomListener(roomId, handler);
@@ -1281,7 +1321,7 @@ var ComRegister = class {
1281
1321
  if (this.config.restartPush) await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1282
1322
  liveRoomInfo,
1283
1323
  masterInfo,
1284
- cardStyle: sub.card
1324
+ cardStyle: sub.customCardStyle
1285
1325
  }, sub.uid, liveMsg);
1286
1326
  if (this.config.pushTime !== 0 && !pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1287
1327
  liveStatus = true;
@@ -1321,7 +1361,7 @@ var ComRegister = class {
1321
1361
  const uid = item.uid.toString();
1322
1362
  const liveStatus = this.liveStatusManager.get(uid);
1323
1363
  const liveMsgObj = this.liveMsgManager.get(uid);
1324
- const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
1364
+ const sub = this.subManager.get(uid);
1325
1365
  if (item.live_status === 1) {
1326
1366
  liveStatus.live = true;
1327
1367
  await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast, liveStatus);
@@ -1333,8 +1373,8 @@ var ComRegister = class {
1333
1373
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1334
1374
  liveRoomInfo: liveStatus.liveRoomInfo,
1335
1375
  masterInfo: liveStatus.masterInfo,
1336
- cardStyle: sub.card
1337
- }, sub.uid, liveMsg);
1376
+ cardStyle: sub.customCardStyle
1377
+ }, uid, liveMsg);
1338
1378
  }
1339
1379
  }
1340
1380
  const handler = async () => {
@@ -1343,7 +1383,7 @@ var ComRegister = class {
1343
1383
  const uid = item.uid.toString();
1344
1384
  const liveStatus = this.liveStatusManager.get(uid);
1345
1385
  const liveMsgObj = this.liveMsgManager.get(uid);
1346
- const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
1386
+ const sub = this.subManager.get(uid);
1347
1387
  if (!sub) return;
1348
1388
  switch (item.live_status) {
1349
1389
  case 0:
@@ -1366,8 +1406,8 @@ var ComRegister = class {
1366
1406
  await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1367
1407
  liveRoomInfo: liveStatus.liveRoomInfo,
1368
1408
  masterInfo: liveStatus.masterInfo,
1369
- cardStyle: sub.card
1370
- }, sub.uid, liveEndMsg);
1409
+ cardStyle: sub.customCardStyle
1410
+ }, uid, liveEndMsg);
1371
1411
  liveStatus.live = false;
1372
1412
  }
1373
1413
  break;
@@ -1385,8 +1425,8 @@ var ComRegister = class {
1385
1425
  await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1386
1426
  liveRoomInfo: liveStatus.liveRoomInfo,
1387
1427
  masterInfo: liveStatus.masterInfo,
1388
- cardStyle: sub.card
1389
- }, sub.uid, liveStartMsg);
1428
+ cardStyle: sub.customCardStyle
1429
+ }, uid, liveStartMsg);
1390
1430
  liveStatus.live = true;
1391
1431
  }
1392
1432
  if (liveStatus.live === true) {
@@ -1406,8 +1446,8 @@ var ComRegister = class {
1406
1446
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1407
1447
  liveRoomInfo: liveStatus.liveRoomInfo,
1408
1448
  masterInfo: liveStatus.masterInfo,
1409
- cardStyle: sub.card
1410
- }, sub.uid, liveMsg);
1449
+ cardStyle: sub.customCardStyle
1450
+ }, uid, liveMsg);
1411
1451
  liveStatus.push = 0;
1412
1452
  }
1413
1453
  break;
@@ -1420,7 +1460,7 @@ var ComRegister = class {
1420
1460
  }
1421
1461
  subShow() {
1422
1462
  let table = "";
1423
- for (const sub of this.subManager) table += `UID:${sub.uid} ${sub.dynamic ? "已订阅动态" : ""} ${sub.live ? "已订阅直播" : ""}\n`;
1463
+ for (const [uid, sub] of this.subManager) table += `UID:${uid} ${sub.dynamic ? "已订阅动态" : ""} ${sub.live ? "已订阅直播" : ""}\n`;
1424
1464
  return table ? table : "没有订阅任何UP";
1425
1465
  }
1426
1466
  updateSubNotifier() {
@@ -1455,22 +1495,22 @@ var ComRegister = class {
1455
1495
  this.ctx.database.set("loginBili", 1, { dynamic_group_id: this.loginDBData.dynamic_group_id });
1456
1496
  return {
1457
1497
  code: 0,
1458
- msg: "分组已存在"
1498
+ message: "分组已存在"
1459
1499
  };
1460
1500
  }
1461
1501
  } else if (createGroupData.code !== 0) return {
1462
1502
  code: createGroupData.code,
1463
- msg: createGroupData.message
1503
+ message: createGroupData.message
1464
1504
  };
1465
1505
  this.ctx.database.set("loginBili", 1, { dynamic_group_id: createGroupData.data.tagid.toString() });
1466
1506
  return {
1467
1507
  code: createGroupData.code,
1468
- msg: createGroupData.message
1508
+ message: createGroupData.message
1469
1509
  };
1470
1510
  }
1471
1511
  return {
1472
1512
  code: 0,
1473
- msg: "分组已存在"
1513
+ message: "分组已存在"
1474
1514
  };
1475
1515
  };
1476
1516
  const resp = await checkGroupIsReady();
@@ -1486,93 +1526,105 @@ var ComRegister = class {
1486
1526
  }
1487
1527
  return {
1488
1528
  code: relationGroupDetailData.code,
1489
- msg: relationGroupDetailData.message,
1529
+ message: relationGroupDetailData.message,
1490
1530
  data: void 0
1491
1531
  };
1492
1532
  }
1493
1533
  return {
1494
1534
  code: 0,
1495
- msg: "获取分组明细成功",
1535
+ message: "获取分组明细成功",
1496
1536
  data: relationGroupDetailData.data
1497
1537
  };
1498
1538
  };
1499
- const { code, msg, data } = await getGroupDetailData();
1539
+ const { code, message, data } = await getGroupDetailData();
1500
1540
  if (code !== 0) return {
1501
1541
  code,
1502
- msg
1542
+ message
1503
1543
  };
1504
1544
  for (const user of data) if (user.mid === mid) return {
1505
1545
  code: 0,
1506
- msg: "订阅对象已存在于分组中"
1546
+ message: "订阅对象已存在于分组中"
1507
1547
  };
1508
1548
  const subUserData = await this.ctx["bilibili-notify-api"].follow(mid);
1509
1549
  const subUserMatchPattern = {
1510
1550
  [-101]: () => {
1511
1551
  return {
1512
1552
  code: subUserData.code,
1513
- msg: "账号未登录,请使用指令bili login登录后再进行订阅操作"
1553
+ message: "账号未登录,请使用指令bili login登录后再进行订阅操作"
1514
1554
  };
1515
1555
  },
1516
1556
  [-102]: () => {
1517
1557
  return {
1518
1558
  code: subUserData.code,
1519
- msg: "账号被封停,无法进行订阅操作"
1559
+ message: "账号被封停,无法进行订阅操作"
1520
1560
  };
1521
1561
  },
1522
1562
  22002: () => {
1523
1563
  return {
1524
1564
  code: subUserData.code,
1525
- msg: "因对方隐私设置,无法进行订阅操作"
1565
+ message: "因对方隐私设置,无法进行订阅操作"
1526
1566
  };
1527
1567
  },
1528
1568
  22003: () => {
1529
1569
  return {
1530
1570
  code: subUserData.code,
1531
- msg: "你已将对方拉黑,无法进行订阅操作"
1571
+ message: "你已将对方拉黑,无法进行订阅操作"
1532
1572
  };
1533
1573
  },
1534
1574
  22013: () => {
1535
1575
  return {
1536
1576
  code: subUserData.code,
1537
- msg: "账号已注销,无法进行订阅操作"
1577
+ message: "账号已注销,无法进行订阅操作"
1538
1578
  };
1539
1579
  },
1540
1580
  40061: () => {
1541
1581
  return {
1542
1582
  code: subUserData.code,
1543
- msg: "账号不存在,请检查uid输入是否正确或用户是否存在"
1583
+ message: "账号不存在,请检查uid输入是否正确或用户是否存在"
1544
1584
  };
1545
1585
  },
1546
1586
  22001: () => {
1547
1587
  return {
1548
1588
  code: 0,
1549
- msg: "订阅对象为自己,无需添加到分组"
1589
+ message: "订阅对象为自己,无需添加到分组"
1550
1590
  };
1551
1591
  },
1552
1592
  22014: async () => {
1553
1593
  const copyUserToGroupData = await this.ctx["bilibili-notify-api"].copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
1554
1594
  if (copyUserToGroupData.code !== 0) return {
1555
1595
  code: copyUserToGroupData.code,
1556
- msg: "添加订阅对象到分组失败,请稍后重试"
1596
+ message: "添加订阅对象到分组失败,请稍后重试"
1557
1597
  };
1558
1598
  return {
1559
1599
  code: 0,
1560
- msg: "订阅对象添加成功"
1600
+ message: "订阅对象添加成功"
1601
+ };
1602
+ },
1603
+ 22015: async () => {
1604
+ return {
1605
+ code: subUserData.code,
1606
+ message: subUserData.message
1561
1607
  };
1562
1608
  },
1563
1609
  0: async () => {
1564
1610
  const copyUserToGroupData = await this.ctx["bilibili-notify-api"].copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
1565
1611
  if (copyUserToGroupData.code !== 0) return {
1566
1612
  code: copyUserToGroupData.code,
1567
- msg: "添加订阅对象到分组失败,请稍后重试"
1613
+ message: "添加订阅对象到分组失败,请稍后重试"
1568
1614
  };
1569
1615
  return {
1570
1616
  code: 0,
1571
- msg: "订阅对象添加成功"
1617
+ message: "订阅对象添加成功"
1572
1618
  };
1573
1619
  }
1574
1620
  };
1575
- return await subUserMatchPattern[subUserData.code]();
1621
+ const subUserExecute = subUserMatchPattern[subUserData.code] || (() => {
1622
+ return {
1623
+ code: subUserData.code,
1624
+ message: subUserData.message
1625
+ };
1626
+ });
1627
+ return await subUserExecute();
1576
1628
  }
1577
1629
  async loadSubFromConfig(subs) {
1578
1630
  this.preInitConfig(subs);
@@ -1580,11 +1632,8 @@ var ComRegister = class {
1580
1632
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1581
1633
  const { code: userInfoCode, message: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1582
1634
  const data = await this.ctx["bilibili-notify-api"].getUserInfo(sub.uid);
1583
- return {
1584
- code: 0,
1585
- data
1586
- };
1587
- }).then((content) => content.data).catch((e) => {
1635
+ return data;
1636
+ }).catch((e) => {
1588
1637
  this.logger.error(`loadSubFromConfig() getUserInfo() 发生了错误,错误为:${e.message}`);
1589
1638
  return {
1590
1639
  code: -1,
@@ -1592,16 +1641,16 @@ var ComRegister = class {
1592
1641
  };
1593
1642
  });
1594
1643
  if (userInfoCode === -352 && userInfoData.v_voucher) {
1595
- this.logger.info("账号被风控,请使用指令 bili captcha 进行风控验证");
1644
+ this.logger.info("账号被风控,请使用指令 bili cap 进行风控验证");
1596
1645
  await this.sendPrivateMsg("账号被风控,请使用指令 bili cap 进行风控验证");
1597
1646
  return {
1598
1647
  code: userInfoCode,
1599
- msg: userInfoMsg
1648
+ message: userInfoMsg
1600
1649
  };
1601
1650
  }
1602
1651
  if (userInfoCode !== 0) return {
1603
1652
  code: userInfoCode,
1604
- msg: userInfoMsg
1653
+ message: userInfoMsg
1605
1654
  };
1606
1655
  if (this.config.liveDetectType === "WS" && sub.live) {
1607
1656
  if (!userInfoData.live_room) {
@@ -1612,17 +1661,15 @@ var ComRegister = class {
1612
1661
  }
1613
1662
  const subInfo = await this.subUserInBili(sub.uid);
1614
1663
  if (subInfo.code !== 0) return subInfo;
1615
- this.subManager.push({
1616
- id: +sub.uid,
1617
- uid: sub.uid,
1664
+ this.subManager.set(sub.uid, {
1618
1665
  uname: userInfoData.name,
1619
1666
  roomId: sub.live ? userInfoData.live_room.roomid : "",
1620
1667
  target: sub.target,
1621
- platform: "",
1622
1668
  live: sub.live,
1623
1669
  dynamic: sub.dynamic,
1624
- card: sub.card,
1625
- liveMsg: sub.liveMsg
1670
+ customCardStyle: sub.customCardStyle,
1671
+ customLiveMsg: sub.customLiveMsg,
1672
+ customLiveSummary: sub.customLiveSummary
1626
1673
  });
1627
1674
  this.logger.info(`UID:${sub.uid}订阅加载完毕!`);
1628
1675
  if (sub !== Object.values(subs).pop()) {
@@ -1633,7 +1680,7 @@ var ComRegister = class {
1633
1680
  }
1634
1681
  return {
1635
1682
  code: 0,
1636
- msg: "订阅加载完毕!"
1683
+ message: "订阅加载完毕!"
1637
1684
  };
1638
1685
  }
1639
1686
  checkIfDynamicDetectIsNeeded() {
@@ -1673,6 +1720,7 @@ var ComRegister = class {
1673
1720
  liveAtAll: Schema.boolean().default(true).description("直播At全体"),
1674
1721
  liveGuardBuy: Schema.boolean().default(false).description("上舰消息"),
1675
1722
  wordcloud: Schema.boolean().default(true).description("弹幕词云"),
1723
+ liveSummary: Schema.boolean().default(true).description("直播总结"),
1676
1724
  platform: Schema.string().required().description("平台名"),
1677
1725
  target: Schema.string().required().description("群号/频道号")
1678
1726
  })).role("table").description("输入订阅信息,自定义订阅内容; 群号/频道号格式:频道号,频道号 使用英文逗号分隔,例如 1234567,2345678"),
@@ -3601,13 +3649,15 @@ var BiliAPI = class extends Service {
3601
3649
  retries: 3
3602
3650
  });
3603
3651
  }
3604
- async getUserInfo(mid) {
3652
+ async getUserInfo(mid, grisk_id) {
3605
3653
  const run = async () => {
3606
3654
  if (mid === "11783021") {
3607
3655
  console.log("检测到番剧出差UID,跳过远程用户接口访问");
3608
3656
  return bangumiTripData;
3609
3657
  }
3610
- const wbi = await this.getWbi({ mid });
3658
+ const params = { mid };
3659
+ if (grisk_id) params.grisk_id = grisk_id;
3660
+ const wbi = await this.getWbi(params);
3611
3661
  const { data } = await this.client.get(`${GET_USER_INFO}?${wbi}`);
3612
3662
  return data;
3613
3663
  };
@@ -3973,6 +4023,7 @@ var BiliAPI = class extends Service {
3973
4023
  this.logger.info(`验证失败:错误码=${data.code},错误消息:${data.message}`);
3974
4024
  return { data: null };
3975
4025
  }
4026
+ this.addCookie(`x-bili-gaia-vtoken=${data.data.grisk_id}`);
3976
4027
  return { data: data.data };
3977
4028
  }
3978
4029
  };