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.js CHANGED
@@ -64,7 +64,7 @@ const BAConfigSchema = koishi.Schema.object({
64
64
  "satori",
65
65
  "chronocat",
66
66
  "lark"
67
- ]).description("请选择您的私人机器人平台,目前支持QQ、QQ群、OneBot、Discord、RedBot、Telegram、Satori、ChronoCat、Lark。从2.0版本开始,只能在一个平台下使用本插件"),
67
+ ]).description("请选择您的私人机器人平台"),
68
68
  masterAccount: koishi.Schema.string().role("secret").required().description("主人账号,在Q群使用可直接使用QQ号,若在其他平台使用,请使用inspect插件获取自身ID"),
69
69
  masterAccountGuildId: koishi.Schema.string().role("secret").description("主人账号所在的群组ID,只有在QQ频道、Discord这样的环境才需要填写,请使用inspect插件获取群组ID")
70
70
  }), koishi.Schema.object({})])]),
@@ -81,6 +81,7 @@ const BAConfigSchema = koishi.Schema.object({
81
81
  liveAtAll: koishi.Schema.boolean().default(true).description("直播At全体"),
82
82
  liveGuardBuy: koishi.Schema.boolean().default(false).description("上舰消息"),
83
83
  wordcloud: koishi.Schema.boolean().default(true).description("弹幕词云"),
84
+ liveSummary: koishi.Schema.boolean().default(true).description("直播总结"),
84
85
  platform: koishi.Schema.string().required().description("平台名"),
85
86
  target: koishi.Schema.string().required().description("群号/频道号")
86
87
  })).role("table").description("输入订阅信息,自定义订阅内容; 群号/频道号格式:频道号,频道号 使用英文逗号分隔,例如 1234567,2345678"),
@@ -191,7 +192,7 @@ let PushType = /* @__PURE__ */ function(PushType$1) {
191
192
  PushType$1[PushType$1["DynamicAtAll"] = 2] = "DynamicAtAll";
192
193
  PushType$1[PushType$1["StartBroadcasting"] = 3] = "StartBroadcasting";
193
194
  PushType$1[PushType$1["LiveGuardBuy"] = 4] = "LiveGuardBuy";
194
- PushType$1[PushType$1["WordCloud"] = 5] = "WordCloud";
195
+ PushType$1[PushType$1["WordCloudAndLiveSummary"] = 5] = "WordCloudAndLiveSummary";
195
196
  return PushType$1;
196
197
  }({});
197
198
  const PushTypeMsg = {
@@ -200,7 +201,7 @@ const PushTypeMsg = {
200
201
  [PushType.DynamicAtAll]: "动态推送+At全体",
201
202
  [PushType.StartBroadcasting]: "开播推送",
202
203
  [PushType.LiveGuardBuy]: "上舰推送",
203
- [PushType.WordCloud]: "弹幕词云推送"
204
+ [PushType.WordCloudAndLiveSummary]: "弹幕词云和直播总结推送"
204
205
  };
205
206
 
206
207
  //#endregion
@@ -363,17 +364,18 @@ var ComRegister = class {
363
364
  rebootCount = 0;
364
365
  subNotifier;
365
366
  ctx;
366
- subManager = [];
367
- dynamicTimelineManager = new Map();
368
- liveStatusManager = new Map();
369
- liveMsgManager = new Map();
370
- pushArrMap = new Map();
367
+ subManager;
368
+ dynamicTimelineManager;
369
+ liveStatusManager;
370
+ liveMsgManager;
371
+ pushArrMap;
371
372
  loginDBData;
372
373
  privateBot;
373
374
  dynamicJob;
374
375
  liveJob;
375
376
  _jieba = __node_rs_jieba.Jieba.withDict(__node_rs_jieba_dict.dict);
376
377
  stopwords;
378
+ reciveSubTimes = 0;
377
379
  constructor(ctx, config) {
378
380
  this.ctx = ctx;
379
381
  this.init(config);
@@ -473,16 +475,16 @@ var ComRegister = class {
473
475
  biliCom.subcommand(".ll").usage("展示当前正在直播的订阅对象").example("bili ll").action(async () => {
474
476
  const { data: { live_users } } = await ctx["bilibili-notify-api"].getTheUserWhoIsLiveStreaming();
475
477
  const subLiveUsers = [];
476
- for (const sub of this.subManager) {
478
+ for (const [uid, sub] of this.subManager) {
477
479
  let onLive = false;
478
480
  if (live_users.items) {
479
- for (const user of live_users.items) if (user.mid.toString() === sub.uid && sub.live) {
481
+ for (const user of live_users.items) if (user.mid.toString() === uid && sub.live) {
480
482
  onLive = true;
481
483
  break;
482
484
  }
483
485
  }
484
486
  subLiveUsers.push({
485
- uid: Number.parseInt(sub.uid),
487
+ uid: Number.parseInt(uid),
486
488
  uname: sub.uname,
487
489
  onLive
488
490
  });
@@ -611,7 +613,7 @@ var ComRegister = class {
611
613
  ["初中", 4],
612
614
  ["毕业", 4]
613
615
  ];
614
- await session.send(/* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: koishi.h.image(await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(words, "词云测试"), "image/jpg") }));
616
+ const img = koishi.h.image(await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(words, "词云测试"), "image/jpg");
615
617
  const top5DanmakuMaker = [
616
618
  ["张三", 60],
617
619
  ["李四", 48],
@@ -619,8 +621,8 @@ var ComRegister = class {
619
621
  ["赵六", 27],
620
622
  ["田七", 25]
621
623
  ];
622
- 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");
623
- await session.send(danmakerRankMsg);
624
+ 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");
625
+ await session.send(/* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [img, summary] }));
624
626
  });
625
627
  biliCom.subcommand(".cap").action(async ({ session }) => {
626
628
  const { code: userInfoCode, data: userInfoData } = await withRetry(async () => {
@@ -642,7 +644,10 @@ var ComRegister = class {
642
644
  const seccode = `${validate}|jordan`;
643
645
  const { data: validateCaptchaData } = await ctx["bilibili-notify-api"].validateCaptcha(data.geetest.challenge, data.token, validate, seccode);
644
646
  if (validateCaptchaData?.is_valid !== 1) return "验证不成功!";
645
- return "验证成功!请重启插件";
647
+ await this.ctx.sleep(10 * 1e3);
648
+ const { code: validCode, data: validData } = await ctx["bilibili-notify-api"].getUserInfo("114514", validateCaptchaData.grisk_id);
649
+ if (validCode === -352 && validData.v_voucher) return "验证不成功!";
650
+ await session.send("验证成功!请重启插件");
646
651
  });
647
652
  }
648
653
  async init(config) {
@@ -658,25 +663,30 @@ var ComRegister = class {
658
663
  return;
659
664
  }
660
665
  this.mergeStopWords(config.wordcloudStopWords);
661
- if (config.advancedSub) {
662
- this.ctx.on("bilibili-notify/advanced-sub", async (subs) => {
663
- await this.initAsyncPart(subs);
664
- });
665
- this.ctx.emit("bilibili-notify/ready-to-recive");
666
- } else if (config.subs && config.subs.length > 0) {
666
+ this.registeringForEvents();
667
+ if (config.advancedSub) this.ctx.emit("bilibili-notify/ready-to-recive");
668
+ else if (config.subs && config.subs.length > 0) {
667
669
  const subs = this.configSubsToSubscription(config.subs);
668
670
  await this.initAsyncPart(subs);
669
- } else this.logger.info("插件初始化完毕!");
671
+ }
672
+ }
673
+ registeringForEvents() {
670
674
  this.ctx.on("dispose", () => {
671
675
  if (this.loginTimer) this.loginTimer();
672
676
  if (this.dynamicJob) this.dynamicJob.stop();
673
677
  if (this.liveJob) this.liveJob.stop();
674
678
  });
679
+ this.ctx.on("bilibili-notify/advanced-sub", async (subs) => {
680
+ if (this.reciveSubTimes >= 1) await this.ctx["bilibili-notify"].restartPlugin();
681
+ else await this.initAsyncPart(subs);
682
+ this.reciveSubTimes++;
683
+ });
675
684
  }
676
685
  async initAsyncPart(subs) {
677
- const { code, msg } = await this.loadSubFromConfig(subs);
686
+ this.initAllManager();
687
+ const { code, message } = await this.loadSubFromConfig(subs);
678
688
  if (code !== 0) {
679
- this.logger.error(msg);
689
+ this.logger.error(message);
680
690
  this.logger.error("订阅对象加载失败,插件初始化失败!");
681
691
  await this.sendPrivateMsg("订阅对象加载失败,插件初始化失败!");
682
692
  return;
@@ -696,9 +706,9 @@ var ComRegister = class {
696
706
  this.stopwords = new Set([...stop_words_default, ...additionalStopWords]);
697
707
  }
698
708
  initManager() {
699
- for (const sub of this.subManager) {
700
- if (sub.dynamic) this.dynamicTimelineManager.set(sub.uid, Math.floor(luxon.DateTime.now().toSeconds()));
701
- if (sub.live) this.liveStatusManager.set(sub.uid, {
709
+ for (const [uid, sub] of this.subManager) {
710
+ if (sub.dynamic) this.dynamicTimelineManager.set(uid, Math.floor(luxon.DateTime.now().toSeconds()));
711
+ if (sub.live) this.liveStatusManager.set(uid, {
702
712
  roomId: sub.roomId,
703
713
  live: false,
704
714
  liveRoomInfo: void 0,
@@ -710,6 +720,13 @@ var ComRegister = class {
710
720
  });
711
721
  }
712
722
  }
723
+ initAllManager() {
724
+ this.subManager = new Map();
725
+ this.dynamicTimelineManager = new Map();
726
+ this.liveStatusManager = new Map();
727
+ this.liveMsgManager = new Map();
728
+ this.pushArrMap = new Map();
729
+ }
713
730
  configSubsToSubscription(sub) {
714
731
  const subs = {};
715
732
  sub.forEach((s) => {
@@ -721,6 +738,7 @@ var ComRegister = class {
721
738
  liveAtAll: s.liveAtAll,
722
739
  liveGuardBuy: s.liveGuardBuy,
723
740
  wordcloud: s.wordcloud,
741
+ liveSummary: s.liveSummary,
724
742
  bot: null
725
743
  }));
726
744
  const target = [{
@@ -731,11 +749,10 @@ var ComRegister = class {
731
749
  uid: s.uid,
732
750
  dynamic: s.dynamic,
733
751
  live: s.live,
734
- wordcloud: s.wordcloud,
735
752
  target,
736
- card: { enable: false },
737
- liveMsg: { enable: false },
738
- liveSummary: { enable: false }
753
+ customCardStyle: { enable: false },
754
+ customLiveMsg: { enable: false },
755
+ customLiveSummary: { enable: false }
739
756
  };
740
757
  });
741
758
  return subs;
@@ -791,12 +808,12 @@ var ComRegister = class {
791
808
  customLiveEnd: this.config.customLiveEnd || "",
792
809
  liveSummary: this.config.liveSummary.join("\n") || ""
793
810
  };
794
- if (sub.liveMsg.enable) {
795
- liveMsg.customLiveStart = sub.liveMsg.customLiveStart || this.config.customLiveStart;
796
- liveMsg.customLive = sub.liveMsg.customLive || this.config.customLive;
797
- liveMsg.customLiveEnd = sub.liveMsg.customLiveEnd || this.config.customLiveEnd;
811
+ if (sub.customLiveMsg.enable) {
812
+ liveMsg.customLiveStart = sub.customLiveMsg.customLiveStart || this.config.customLiveStart;
813
+ liveMsg.customLive = sub.customLiveMsg.customLive || this.config.customLive;
814
+ liveMsg.customLiveEnd = sub.customLiveMsg.customLiveEnd || this.config.customLiveEnd;
798
815
  }
799
- if (sub.liveSummary.enable) liveMsg.liveSummary = sub.liveSummary.liveSummary || this.config.liveSummary.join("\n");
816
+ if (sub.customLiveSummary.enable) liveMsg.liveSummary = sub.customLiveSummary.liveSummary || this.config.liveSummary.join("\n");
800
817
  this.liveMsgManager.set(sub.uid, liveMsg);
801
818
  const dynamicArr = [];
802
819
  const dynamicAtAllArr = [];
@@ -804,6 +821,7 @@ var ComRegister = class {
804
821
  const liveAtAllArr = [];
805
822
  const liveGuardBuyArr = [];
806
823
  const wordcloudArr = [];
824
+ const liveSummaryArr = [];
807
825
  for (const platform of sub.target) for (const channel of platform.channelArr) {
808
826
  const target = `${platform.platform}:${channel.channelId}`;
809
827
  if (channel.dynamic) dynamicArr.push(target);
@@ -812,12 +830,14 @@ var ComRegister = class {
812
830
  if (channel.liveAtAll) liveAtAllArr.push(target);
813
831
  if (channel.liveGuardBuy) liveGuardBuyArr.push(target);
814
832
  if (channel.wordcloud) wordcloudArr.push(target);
833
+ if (channel.liveSummary) liveSummaryArr.push(target);
815
834
  }
816
835
  this.pushArrMap.set(sub.uid, {
817
836
  dynamicArr,
818
837
  dynamicAtAllArr,
819
838
  liveArr,
820
839
  liveAtAllArr,
840
+ liveSummaryArr,
821
841
  liveGuardBuyArr,
822
842
  wordcloudArr
823
843
  });
@@ -879,15 +899,37 @@ var ComRegister = class {
879
899
  }, 1);
880
900
  this.logger.info(`成功推送上舰消息:${success.length}条`);
881
901
  }
882
- if (type === PushType.WordCloud && record.wordcloudArr?.length >= 1) {
883
- this.logger.info(record.wordcloudArr);
902
+ if (type === PushType.WordCloudAndLiveSummary) {
884
903
  const wordcloudArr = structuredClone(record.wordcloudArr);
885
- const success = await withRetry(async () => {
886
- return await this.ctx.broadcast(wordcloudArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
887
- }, 1);
888
- this.logger.info(`成功推送词云消息:${success.length}条`);
904
+ const liveSummaryArr = structuredClone(record.liveSummaryArr);
905
+ const wordcloudAndLiveSummaryArr = wordcloudArr.filter((item) => liveSummaryArr.includes(item));
906
+ const wordcloudOnlyArr = wordcloudArr.filter((item) => !liveSummaryArr.includes(item));
907
+ const liveSummaryOnlyArr = liveSummaryArr.filter((item) => !wordcloudArr.includes(item));
908
+ if (wordcloudAndLiveSummaryArr.length > 0) {
909
+ this.logger.info("词云和直播总结");
910
+ this.logger.info(wordcloudAndLiveSummaryArr);
911
+ const success = await withRetry(async () => {
912
+ return await this.ctx.broadcast(wordcloudAndLiveSummaryArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [content[0], content[1]] }));
913
+ }, 1);
914
+ this.logger.info(`成功推送词云和直播总结消息:${success.length}条`);
915
+ }
916
+ if (wordcloudOnlyArr.length > 0) {
917
+ this.logger.info("词云");
918
+ this.logger.info(wordcloudOnlyArr);
919
+ const success = await withRetry(async () => {
920
+ return await this.ctx.broadcast(wordcloudOnlyArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content[0] }));
921
+ }, 1);
922
+ this.logger.info(`成功推送词云消息:${success.length}条`);
923
+ }
924
+ if (liveSummaryOnlyArr.length > 0) {
925
+ this.logger.info("直播总结");
926
+ this.logger.info(liveSummaryOnlyArr);
927
+ const success = await withRetry(async () => {
928
+ return await this.ctx.broadcast(liveSummaryOnlyArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content[1] }));
929
+ }, 1);
930
+ this.logger.info(`成功推送直播总结消息:${success.length}条`);
931
+ }
889
932
  }
890
- return;
891
933
  }
892
934
  dynamicDetect() {
893
935
  const handler = async () => {
@@ -931,21 +973,21 @@ var ComRegister = class {
931
973
  if (this.dynamicTimelineManager.has(uid)) {
932
974
  const timeline = this.dynamicTimelineManager.get(uid);
933
975
  if (timeline < postTime) {
934
- const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
976
+ const sub = this.subManager.get(uid);
935
977
  const buffer = await withRetry(async () => {
936
- return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.card.enable ? sub.card : void 0);
978
+ return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.customCardStyle.enable ? sub.customCardStyle : void 0);
937
979
  }, 1).catch(async (e) => {
938
980
  if (e.message === "直播开播动态,不做处理") return;
939
981
  if (e.message === "出现关键词,屏蔽该动态") {
940
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
982
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
941
983
  return;
942
984
  }
943
985
  if (e.message === "已屏蔽转发动态") {
944
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
986
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
945
987
  return;
946
988
  }
947
989
  if (e.message === "已屏蔽专栏动态") {
948
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
990
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
949
991
  return;
950
992
  }
951
993
  this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
@@ -959,7 +1001,7 @@ var ComRegister = class {
959
1001
  } else dUrl = `${name$2}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
960
1002
  else dUrl = `${name$2}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
961
1003
  this.logger.info("推送动态中...");
962
- await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [koishi.h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
1004
+ await this.broadcastToTargets(uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [koishi.h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
963
1005
  if (this.config.pushImgsInDynamic) {
964
1006
  if (item.type === "DYNAMIC_TYPE_DRAW") {
965
1007
  const pics = item.modules?.module_dynamic?.major?.opus?.pics;
@@ -971,7 +1013,7 @@ var ComRegister = class {
971
1013
  alt: "动态图片"
972
1014
  }, pic.url))
973
1015
  });
974
- await this.broadcastToTargets(sub.uid, picsMsg, PushType.Dynamic);
1016
+ await this.broadcastToTargets(uid, picsMsg, PushType.Dynamic);
975
1017
  }
976
1018
  }
977
1019
  }
@@ -1035,22 +1077,22 @@ var ComRegister = class {
1035
1077
  this.logger.info(`上次推送时间线:${luxon.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
1036
1078
  if (timeline < postTime) {
1037
1079
  this.logger.info("需要推送该条动态,开始推送...");
1038
- const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
1080
+ const sub = this.subManager.get(uid);
1039
1081
  this.logger.info("开始渲染推送卡片...");
1040
1082
  const buffer = await withRetry(async () => {
1041
- return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.card.enable ? sub.card : void 0);
1083
+ return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.customCardStyle.enable ? sub.customCardStyle : void 0);
1042
1084
  }, 1).catch(async (e) => {
1043
1085
  if (e.message === "直播开播动态,不做处理") return;
1044
1086
  if (e.message === "出现关键词,屏蔽该动态") {
1045
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
1087
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
1046
1088
  return;
1047
1089
  }
1048
1090
  if (e.message === "已屏蔽转发动态") {
1049
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
1091
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
1050
1092
  return;
1051
1093
  }
1052
1094
  if (e.message === "已屏蔽专栏动态") {
1053
- if (this.config.filter.notify) await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
1095
+ if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [name$2, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
1054
1096
  return;
1055
1097
  }
1056
1098
  this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
@@ -1069,7 +1111,7 @@ var ComRegister = class {
1069
1111
  this.logger.info("动态链接生成成功!");
1070
1112
  }
1071
1113
  this.logger.info("推送动态中...");
1072
- await this.broadcastToTargets(sub.uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [koishi.h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
1114
+ await this.broadcastToTargets(uid, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [koishi.h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
1073
1115
  if (this.config.pushImgsInDynamic) {
1074
1116
  this.logger.info("需要发送动态中的图片,开始发送...");
1075
1117
  if (item.type === "DYNAMIC_TYPE_DRAW") {
@@ -1082,7 +1124,7 @@ var ComRegister = class {
1082
1124
  alt: "动态图片"
1083
1125
  }, pic.url))
1084
1126
  });
1085
- await this.broadcastToTargets(sub.uid, picsMsg, PushType.Dynamic);
1127
+ await this.broadcastToTargets(uid, picsMsg, PushType.Dynamic);
1086
1128
  }
1087
1129
  }
1088
1130
  this.logger.info("动态中的图片发送完毕!");
@@ -1163,7 +1205,7 @@ var ComRegister = class {
1163
1205
  let masterInfo;
1164
1206
  let watchedNum;
1165
1207
  const liveMsgObj = this.liveMsgManager.get(sub.uid);
1166
- const sendDanmakuWordCloud = async (liveSummary) => {
1208
+ const sendDanmakuWordCloudAndLiveSummary = async (customLiveSummary) => {
1167
1209
  this.logger.info("开始制作弹幕词云");
1168
1210
  this.logger.info("正在获取前90热词");
1169
1211
  const top90Words = Object.entries(danmakuWeightRecord).sort((a, b) => b[1] - a[1]).slice(0, 90);
@@ -1171,15 +1213,13 @@ var ComRegister = class {
1171
1213
  this.logger.info(top90Words);
1172
1214
  this.logger.info("正在准备生成弹幕词云");
1173
1215
  const buffer = await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(top90Words, masterInfo.username);
1174
- this.logger.info("弹幕词云生成完成,正在准备发送词云图片");
1175
- await this.broadcastToTargets(sub.uid, koishi.h.image(buffer, "image/jpeg"), PushType.Live);
1176
- this.logger.info("词云图片发送完毕!");
1216
+ const img = koishi.h.image(buffer, "image/jpeg");
1177
1217
  this.logger.info("开始构建弹幕发送排行榜消息");
1178
1218
  const danmakuMakerCount = Object.keys(danmakuMakerRecord).length;
1179
1219
  const danmakuCount = Object.values(danmakuMakerRecord).reduce((sum, val) => sum + val, 0);
1180
1220
  const top5DanmakuMaker = Object.entries(danmakuMakerRecord).sort((a, b) => b[1] - a[1]).slice(0, 5);
1181
- 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");
1182
- await this.broadcastToTargets(sub.uid, danmakuMakerMsg, PushType.WordCloud);
1221
+ 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");
1222
+ await this.broadcastToTargets(sub.uid, [img, summary], PushType.WordCloudAndLiveSummary);
1183
1223
  Object.keys(danmakuWeightRecord).forEach((key) => delete danmakuWeightRecord[key]);
1184
1224
  Object.keys(danmakuMakerRecord).forEach((key) => delete danmakuMakerRecord[key]);
1185
1225
  };
@@ -1200,7 +1240,7 @@ var ComRegister = class {
1200
1240
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1201
1241
  liveRoomInfo,
1202
1242
  masterInfo,
1203
- cardStyle: sub.card
1243
+ cardStyle: sub.customCardStyle
1204
1244
  }, sub.uid, liveMsg);
1205
1245
  };
1206
1246
  const useMasterAndLiveRoomInfo = async (liveType) => {
@@ -1264,7 +1304,7 @@ var ComRegister = class {
1264
1304
  await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1265
1305
  liveRoomInfo,
1266
1306
  masterInfo,
1267
- cardStyle: sub.card
1307
+ cardStyle: sub.customCardStyle
1268
1308
  }, sub.uid, liveStartMsg);
1269
1309
  if (this.config.pushTime !== 0 && !pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1270
1310
  },
@@ -1284,11 +1324,11 @@ var ComRegister = class {
1284
1324
  await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1285
1325
  liveRoomInfo,
1286
1326
  masterInfo,
1287
- cardStyle: sub.card
1327
+ cardStyle: sub.customCardStyle
1288
1328
  }, sub.uid, liveEndMsg);
1289
1329
  pushAtTimeTimer();
1290
1330
  pushAtTimeTimer = null;
1291
- if (sub.wordcloud) await sendDanmakuWordCloud(liveMsgObj.liveSummary);
1331
+ await sendDanmakuWordCloudAndLiveSummary(liveMsgObj.liveSummary);
1292
1332
  }
1293
1333
  };
1294
1334
  await this.ctx["bilibili-notify-live"].startLiveRoomListener(roomId, handler);
@@ -1300,7 +1340,7 @@ var ComRegister = class {
1300
1340
  if (this.config.restartPush) await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1301
1341
  liveRoomInfo,
1302
1342
  masterInfo,
1303
- cardStyle: sub.card
1343
+ cardStyle: sub.customCardStyle
1304
1344
  }, sub.uid, liveMsg);
1305
1345
  if (this.config.pushTime !== 0 && !pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1306
1346
  liveStatus = true;
@@ -1340,7 +1380,7 @@ var ComRegister = class {
1340
1380
  const uid = item.uid.toString();
1341
1381
  const liveStatus = this.liveStatusManager.get(uid);
1342
1382
  const liveMsgObj = this.liveMsgManager.get(uid);
1343
- const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
1383
+ const sub = this.subManager.get(uid);
1344
1384
  if (item.live_status === 1) {
1345
1385
  liveStatus.live = true;
1346
1386
  await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast, liveStatus);
@@ -1352,8 +1392,8 @@ var ComRegister = class {
1352
1392
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1353
1393
  liveRoomInfo: liveStatus.liveRoomInfo,
1354
1394
  masterInfo: liveStatus.masterInfo,
1355
- cardStyle: sub.card
1356
- }, sub.uid, liveMsg);
1395
+ cardStyle: sub.customCardStyle
1396
+ }, uid, liveMsg);
1357
1397
  }
1358
1398
  }
1359
1399
  const handler = async () => {
@@ -1362,7 +1402,7 @@ var ComRegister = class {
1362
1402
  const uid = item.uid.toString();
1363
1403
  const liveStatus = this.liveStatusManager.get(uid);
1364
1404
  const liveMsgObj = this.liveMsgManager.get(uid);
1365
- const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
1405
+ const sub = this.subManager.get(uid);
1366
1406
  if (!sub) return;
1367
1407
  switch (item.live_status) {
1368
1408
  case 0:
@@ -1385,8 +1425,8 @@ var ComRegister = class {
1385
1425
  await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1386
1426
  liveRoomInfo: liveStatus.liveRoomInfo,
1387
1427
  masterInfo: liveStatus.masterInfo,
1388
- cardStyle: sub.card
1389
- }, sub.uid, liveEndMsg);
1428
+ cardStyle: sub.customCardStyle
1429
+ }, uid, liveEndMsg);
1390
1430
  liveStatus.live = false;
1391
1431
  }
1392
1432
  break;
@@ -1404,8 +1444,8 @@ var ComRegister = class {
1404
1444
  await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1405
1445
  liveRoomInfo: liveStatus.liveRoomInfo,
1406
1446
  masterInfo: liveStatus.masterInfo,
1407
- cardStyle: sub.card
1408
- }, sub.uid, liveStartMsg);
1447
+ cardStyle: sub.customCardStyle
1448
+ }, uid, liveStartMsg);
1409
1449
  liveStatus.live = true;
1410
1450
  }
1411
1451
  if (liveStatus.live === true) {
@@ -1425,8 +1465,8 @@ var ComRegister = class {
1425
1465
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1426
1466
  liveRoomInfo: liveStatus.liveRoomInfo,
1427
1467
  masterInfo: liveStatus.masterInfo,
1428
- cardStyle: sub.card
1429
- }, sub.uid, liveMsg);
1468
+ cardStyle: sub.customCardStyle
1469
+ }, uid, liveMsg);
1430
1470
  liveStatus.push = 0;
1431
1471
  }
1432
1472
  break;
@@ -1439,7 +1479,7 @@ var ComRegister = class {
1439
1479
  }
1440
1480
  subShow() {
1441
1481
  let table = "";
1442
- for (const sub of this.subManager) table += `UID:${sub.uid} ${sub.dynamic ? "已订阅动态" : ""} ${sub.live ? "已订阅直播" : ""}\n`;
1482
+ for (const [uid, sub] of this.subManager) table += `UID:${uid} ${sub.dynamic ? "已订阅动态" : ""} ${sub.live ? "已订阅直播" : ""}\n`;
1443
1483
  return table ? table : "没有订阅任何UP";
1444
1484
  }
1445
1485
  updateSubNotifier() {
@@ -1474,22 +1514,22 @@ var ComRegister = class {
1474
1514
  this.ctx.database.set("loginBili", 1, { dynamic_group_id: this.loginDBData.dynamic_group_id });
1475
1515
  return {
1476
1516
  code: 0,
1477
- msg: "分组已存在"
1517
+ message: "分组已存在"
1478
1518
  };
1479
1519
  }
1480
1520
  } else if (createGroupData.code !== 0) return {
1481
1521
  code: createGroupData.code,
1482
- msg: createGroupData.message
1522
+ message: createGroupData.message
1483
1523
  };
1484
1524
  this.ctx.database.set("loginBili", 1, { dynamic_group_id: createGroupData.data.tagid.toString() });
1485
1525
  return {
1486
1526
  code: createGroupData.code,
1487
- msg: createGroupData.message
1527
+ message: createGroupData.message
1488
1528
  };
1489
1529
  }
1490
1530
  return {
1491
1531
  code: 0,
1492
- msg: "分组已存在"
1532
+ message: "分组已存在"
1493
1533
  };
1494
1534
  };
1495
1535
  const resp = await checkGroupIsReady();
@@ -1505,93 +1545,105 @@ var ComRegister = class {
1505
1545
  }
1506
1546
  return {
1507
1547
  code: relationGroupDetailData.code,
1508
- msg: relationGroupDetailData.message,
1548
+ message: relationGroupDetailData.message,
1509
1549
  data: void 0
1510
1550
  };
1511
1551
  }
1512
1552
  return {
1513
1553
  code: 0,
1514
- msg: "获取分组明细成功",
1554
+ message: "获取分组明细成功",
1515
1555
  data: relationGroupDetailData.data
1516
1556
  };
1517
1557
  };
1518
- const { code, msg, data } = await getGroupDetailData();
1558
+ const { code, message, data } = await getGroupDetailData();
1519
1559
  if (code !== 0) return {
1520
1560
  code,
1521
- msg
1561
+ message
1522
1562
  };
1523
1563
  for (const user of data) if (user.mid === mid) return {
1524
1564
  code: 0,
1525
- msg: "订阅对象已存在于分组中"
1565
+ message: "订阅对象已存在于分组中"
1526
1566
  };
1527
1567
  const subUserData = await this.ctx["bilibili-notify-api"].follow(mid);
1528
1568
  const subUserMatchPattern = {
1529
1569
  [-101]: () => {
1530
1570
  return {
1531
1571
  code: subUserData.code,
1532
- msg: "账号未登录,请使用指令bili login登录后再进行订阅操作"
1572
+ message: "账号未登录,请使用指令bili login登录后再进行订阅操作"
1533
1573
  };
1534
1574
  },
1535
1575
  [-102]: () => {
1536
1576
  return {
1537
1577
  code: subUserData.code,
1538
- msg: "账号被封停,无法进行订阅操作"
1578
+ message: "账号被封停,无法进行订阅操作"
1539
1579
  };
1540
1580
  },
1541
1581
  22002: () => {
1542
1582
  return {
1543
1583
  code: subUserData.code,
1544
- msg: "因对方隐私设置,无法进行订阅操作"
1584
+ message: "因对方隐私设置,无法进行订阅操作"
1545
1585
  };
1546
1586
  },
1547
1587
  22003: () => {
1548
1588
  return {
1549
1589
  code: subUserData.code,
1550
- msg: "你已将对方拉黑,无法进行订阅操作"
1590
+ message: "你已将对方拉黑,无法进行订阅操作"
1551
1591
  };
1552
1592
  },
1553
1593
  22013: () => {
1554
1594
  return {
1555
1595
  code: subUserData.code,
1556
- msg: "账号已注销,无法进行订阅操作"
1596
+ message: "账号已注销,无法进行订阅操作"
1557
1597
  };
1558
1598
  },
1559
1599
  40061: () => {
1560
1600
  return {
1561
1601
  code: subUserData.code,
1562
- msg: "账号不存在,请检查uid输入是否正确或用户是否存在"
1602
+ message: "账号不存在,请检查uid输入是否正确或用户是否存在"
1563
1603
  };
1564
1604
  },
1565
1605
  22001: () => {
1566
1606
  return {
1567
1607
  code: 0,
1568
- msg: "订阅对象为自己,无需添加到分组"
1608
+ message: "订阅对象为自己,无需添加到分组"
1569
1609
  };
1570
1610
  },
1571
1611
  22014: async () => {
1572
1612
  const copyUserToGroupData = await this.ctx["bilibili-notify-api"].copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
1573
1613
  if (copyUserToGroupData.code !== 0) return {
1574
1614
  code: copyUserToGroupData.code,
1575
- msg: "添加订阅对象到分组失败,请稍后重试"
1615
+ message: "添加订阅对象到分组失败,请稍后重试"
1576
1616
  };
1577
1617
  return {
1578
1618
  code: 0,
1579
- msg: "订阅对象添加成功"
1619
+ message: "订阅对象添加成功"
1620
+ };
1621
+ },
1622
+ 22015: async () => {
1623
+ return {
1624
+ code: subUserData.code,
1625
+ message: subUserData.message
1580
1626
  };
1581
1627
  },
1582
1628
  0: async () => {
1583
1629
  const copyUserToGroupData = await this.ctx["bilibili-notify-api"].copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
1584
1630
  if (copyUserToGroupData.code !== 0) return {
1585
1631
  code: copyUserToGroupData.code,
1586
- msg: "添加订阅对象到分组失败,请稍后重试"
1632
+ message: "添加订阅对象到分组失败,请稍后重试"
1587
1633
  };
1588
1634
  return {
1589
1635
  code: 0,
1590
- msg: "订阅对象添加成功"
1636
+ message: "订阅对象添加成功"
1591
1637
  };
1592
1638
  }
1593
1639
  };
1594
- return await subUserMatchPattern[subUserData.code]();
1640
+ const subUserExecute = subUserMatchPattern[subUserData.code] || (() => {
1641
+ return {
1642
+ code: subUserData.code,
1643
+ message: subUserData.message
1644
+ };
1645
+ });
1646
+ return await subUserExecute();
1595
1647
  }
1596
1648
  async loadSubFromConfig(subs) {
1597
1649
  this.preInitConfig(subs);
@@ -1599,11 +1651,8 @@ var ComRegister = class {
1599
1651
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1600
1652
  const { code: userInfoCode, message: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1601
1653
  const data = await this.ctx["bilibili-notify-api"].getUserInfo(sub.uid);
1602
- return {
1603
- code: 0,
1604
- data
1605
- };
1606
- }).then((content) => content.data).catch((e) => {
1654
+ return data;
1655
+ }).catch((e) => {
1607
1656
  this.logger.error(`loadSubFromConfig() getUserInfo() 发生了错误,错误为:${e.message}`);
1608
1657
  return {
1609
1658
  code: -1,
@@ -1611,16 +1660,16 @@ var ComRegister = class {
1611
1660
  };
1612
1661
  });
1613
1662
  if (userInfoCode === -352 && userInfoData.v_voucher) {
1614
- this.logger.info("账号被风控,请使用指令 bili captcha 进行风控验证");
1663
+ this.logger.info("账号被风控,请使用指令 bili cap 进行风控验证");
1615
1664
  await this.sendPrivateMsg("账号被风控,请使用指令 bili cap 进行风控验证");
1616
1665
  return {
1617
1666
  code: userInfoCode,
1618
- msg: userInfoMsg
1667
+ message: userInfoMsg
1619
1668
  };
1620
1669
  }
1621
1670
  if (userInfoCode !== 0) return {
1622
1671
  code: userInfoCode,
1623
- msg: userInfoMsg
1672
+ message: userInfoMsg
1624
1673
  };
1625
1674
  if (this.config.liveDetectType === "WS" && sub.live) {
1626
1675
  if (!userInfoData.live_room) {
@@ -1631,17 +1680,15 @@ var ComRegister = class {
1631
1680
  }
1632
1681
  const subInfo = await this.subUserInBili(sub.uid);
1633
1682
  if (subInfo.code !== 0) return subInfo;
1634
- this.subManager.push({
1635
- id: +sub.uid,
1636
- uid: sub.uid,
1683
+ this.subManager.set(sub.uid, {
1637
1684
  uname: userInfoData.name,
1638
1685
  roomId: sub.live ? userInfoData.live_room.roomid : "",
1639
1686
  target: sub.target,
1640
- platform: "",
1641
1687
  live: sub.live,
1642
1688
  dynamic: sub.dynamic,
1643
- card: sub.card,
1644
- liveMsg: sub.liveMsg
1689
+ customCardStyle: sub.customCardStyle,
1690
+ customLiveMsg: sub.customLiveMsg,
1691
+ customLiveSummary: sub.customLiveSummary
1645
1692
  });
1646
1693
  this.logger.info(`UID:${sub.uid}订阅加载完毕!`);
1647
1694
  if (sub !== Object.values(subs).pop()) {
@@ -1652,7 +1699,7 @@ var ComRegister = class {
1652
1699
  }
1653
1700
  return {
1654
1701
  code: 0,
1655
- msg: "订阅加载完毕!"
1702
+ message: "订阅加载完毕!"
1656
1703
  };
1657
1704
  }
1658
1705
  checkIfDynamicDetectIsNeeded() {
@@ -1692,6 +1739,7 @@ var ComRegister = class {
1692
1739
  liveAtAll: koishi.Schema.boolean().default(true).description("直播At全体"),
1693
1740
  liveGuardBuy: koishi.Schema.boolean().default(false).description("上舰消息"),
1694
1741
  wordcloud: koishi.Schema.boolean().default(true).description("弹幕词云"),
1742
+ liveSummary: koishi.Schema.boolean().default(true).description("直播总结"),
1695
1743
  platform: koishi.Schema.string().required().description("平台名"),
1696
1744
  target: koishi.Schema.string().required().description("群号/频道号")
1697
1745
  })).role("table").description("输入订阅信息,自定义订阅内容; 群号/频道号格式:频道号,频道号 使用英文逗号分隔,例如 1234567,2345678"),
@@ -3620,13 +3668,15 @@ var BiliAPI = class extends koishi.Service {
3620
3668
  retries: 3
3621
3669
  });
3622
3670
  }
3623
- async getUserInfo(mid) {
3671
+ async getUserInfo(mid, grisk_id) {
3624
3672
  const run = async () => {
3625
3673
  if (mid === "11783021") {
3626
3674
  console.log("检测到番剧出差UID,跳过远程用户接口访问");
3627
3675
  return bangumiTripData;
3628
3676
  }
3629
- const wbi = await this.getWbi({ mid });
3677
+ const params = { mid };
3678
+ if (grisk_id) params.grisk_id = grisk_id;
3679
+ const wbi = await this.getWbi(params);
3630
3680
  const { data } = await this.client.get(`${GET_USER_INFO}?${wbi}`);
3631
3681
  return data;
3632
3682
  };
@@ -3992,6 +4042,7 @@ var BiliAPI = class extends koishi.Service {
3992
4042
  this.logger.info(`验证失败:错误码=${data.code},错误消息:${data.message}`);
3993
4043
  return { data: null };
3994
4044
  }
4045
+ this.addCookie(`x-bili-gaia-vtoken=${data.data.grisk_id}`);
3995
4046
  return { data: data.data };
3996
4047
  }
3997
4048
  };