koishi-plugin-bilibili-notify 3.3.0-rc.0 → 3.3.1-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.
package/lib/index.mjs CHANGED
@@ -61,6 +61,7 @@ const BAConfigSchema = Schema.object({
61
61
  live: Schema.boolean().default(true).description("直播"),
62
62
  liveAtAll: Schema.boolean().default(true).description("直播At全体"),
63
63
  liveGuardBuy: Schema.boolean().default(false).description("上舰消息"),
64
+ wordcloud: Schema.boolean().default(true).description("弹幕词云"),
64
65
  platform: Schema.string().required().description("平台名"),
65
66
  target: Schema.string().required().description("群号/频道号")
66
67
  })).role("table").description("输入订阅信息,自定义订阅内容; 群号/频道号格式:频道号,频道号 使用英文逗号分隔,例如 1234567,2345678"),
@@ -71,8 +72,19 @@ const BAConfigSchema = Schema.object({
71
72
  pushImgsInDynamic: Schema.boolean().default(false).description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
72
73
  live: Schema.object({}).description("直播推送设置"),
73
74
  liveDetectType: Schema.union([Schema.const("WS").description("使用WebSocket连接到B站消息服务器进行直播检测,推荐使用"), Schema.const("API").description("通过轮询API发送请求监测直播状态,此模式理论可无限订阅,但容易产生其他问题,功能没有WS模式全面").experimental()]).role("radio").default("WS").description("直播检测方式,WS为连接到B站消息服务器,API为通过轮询发送请求监测,默认使用WS检测"),
74
- wordcloud: Schema.boolean().default(false).description("直播结束后,是否生成本场直播弹幕词云").experimental(),
75
- liveSummary: Schema.string().default("🔍【弹幕情报站】本场直播数据如下:\\n🧍‍♂️ 总共 -dmc 位-mdn上线\\n💬 共计 -dca 条弹幕飞驰而过\\n📊 热词云图已生成,快来看看你有没有上榜!\\n\\n👑 本场顶级输出选手:\\n🥇 -un1 - 弹幕输出 -dc1 条\\n🥈 -un2 - 弹幕 -dc2 条,萌力惊人\\n🥉 -un3 - -dc3 条精准狙击\\n\\n🎖️ 特别嘉奖:-un4 & -un5\\n你们的弹幕,我们都记录在案!🕵️‍♀️").description("自定义直播总结语,开启弹幕词云自动发送。变量解释:-dmc代表总弹幕发送人数,-mdn代表主播粉丝牌子名,-dca代表总弹幕数,-un1到-un5代表弹幕发送条数前五名用户的用户名,-dc1到-dc5代表弹幕发送条数前五名的弹幕发送数量"),
75
+ wordcloudStopWords: Schema.string().description("词云生成时的停用词,多个停用词请使用英文逗号分隔,例如:哔哩哔哩,弹幕,直播,词云").experimental(),
76
+ liveSummary: Schema.array(String).default([
77
+ "🔍【弹幕情报站】本场直播数据如下:",
78
+ "🧍‍♂️ 总共 -dmc 位-mdn上线",
79
+ "💬 共计 -dca 条弹幕飞驰而过",
80
+ "📊 热词云图已生成,快来看看你有没有上榜!",
81
+ "👑 本场顶级输出选手:",
82
+ "🥇 -un1 - 弹幕输出 -dc1 条",
83
+ "🥈 -un2 - 弹幕 -dc2 条,萌力惊人",
84
+ "🥉 -un3 - -dc3 条精准狙击",
85
+ "🎖️ 特别嘉奖:-un4 & -un5",
86
+ "你们的弹幕,我们都记录在案!🕵️‍♀️"
87
+ ]).role("table").description("自定义直播总结语,开启弹幕词云自动发送。变量解释:-dmc代表总弹幕发送人数,-mdn代表主播粉丝牌子名,-dca代表总弹幕数,-un1到-un5代表弹幕发送条数前五名用户的用户名,-dc1到-dc5代表弹幕发送条数前五名的弹幕发送数量,数组每一行代表换行"),
76
88
  restartPush: Schema.boolean().default(true).description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
77
89
  pushTime: Schema.number().min(0).max(12).step(.5).default(1).description("设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时"),
78
90
  customLiveStart: Schema.string().default("-name开播啦,当前粉丝数:-follower\\n-link").description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
@@ -160,6 +172,7 @@ let PushType = /* @__PURE__ */ function(PushType$1) {
160
172
  PushType$1[PushType$1["DynamicAtAll"] = 2] = "DynamicAtAll";
161
173
  PushType$1[PushType$1["StartBroadcasting"] = 3] = "StartBroadcasting";
162
174
  PushType$1[PushType$1["LiveGuardBuy"] = 4] = "LiveGuardBuy";
175
+ PushType$1[PushType$1["WordCloud"] = 5] = "WordCloud";
163
176
  return PushType$1;
164
177
  }({});
165
178
  const PushTypeMsg = {
@@ -167,7 +180,8 @@ const PushTypeMsg = {
167
180
  [PushType.Dynamic]: "动态推送",
168
181
  [PushType.DynamicAtAll]: "动态推送+At全体",
169
182
  [PushType.StartBroadcasting]: "开播推送",
170
- [PushType.LiveGuardBuy]: "上舰推送"
183
+ [PushType.LiveGuardBuy]: "上舰推送",
184
+ [PushType.WordCloud]: "弹幕词云推送"
171
185
  };
172
186
 
173
187
  //#endregion
@@ -304,16 +318,17 @@ const stopwords = new Set([
304
318
  "之前",
305
319
  "某天"
306
320
  ]);
321
+ var stop_words_default = stopwords;
307
322
 
308
323
  //#endregion
309
324
  //#region src/command_register.tsx
310
325
  var ComRegister = class {
311
326
  static inject = [
312
- "ba",
313
- "gi",
314
- "database",
315
- "bl",
316
- "sm"
327
+ "bilibili-notify",
328
+ "bilibili-notify-api",
329
+ "bilibili-notify-live",
330
+ "bilibili-notify-generate-img",
331
+ "database"
317
332
  ];
318
333
  qqRelatedBotList = [
319
334
  "qq",
@@ -339,6 +354,7 @@ var ComRegister = class {
339
354
  dynamicJob;
340
355
  liveJob;
341
356
  _jieba = Jieba.withDict(dict);
357
+ stopwords;
342
358
  constructor(ctx, config) {
343
359
  this.ctx = ctx;
344
360
  this.init(config);
@@ -369,7 +385,7 @@ var ComRegister = class {
369
385
  this.logger.info("调用bili login指令");
370
386
  let content;
371
387
  try {
372
- content = await ctx.ba.getLoginQRCode();
388
+ content = await ctx["bilibili-notify-api"].getLoginQRCode();
373
389
  } catch (_) {
374
390
  return "bili login getLoginQRCode() 本次网络请求失败";
375
391
  }
@@ -394,7 +410,7 @@ var ComRegister = class {
394
410
  flag = false;
395
411
  let loginContent;
396
412
  try {
397
- loginContent = await ctx.ba.getLoginStatus(content.data.qrcode_key);
413
+ loginContent = await ctx["bilibili-notify-api"].getLoginStatus(content.data.qrcode_key);
398
414
  } catch (e) {
399
415
  this.logger.error(e);
400
416
  return;
@@ -408,24 +424,19 @@ var ComRegister = class {
408
424
  return await session.send("二维码已失效,请重新登录");
409
425
  }
410
426
  if (loginContent.data.code === 0) {
411
- const encryptedCookies = ctx.ba.encrypt(ctx.ba.getCookies());
412
- const encryptedRefreshToken = ctx.ba.encrypt(loginContent.data.refresh_token);
427
+ const encryptedCookies = ctx["bilibili-notify-api"].encrypt(ctx["bilibili-notify-api"].getCookies());
428
+ const encryptedRefreshToken = ctx["bilibili-notify-api"].encrypt(loginContent.data.refresh_token);
413
429
  await ctx.database.upsert("loginBili", [{
414
430
  id: 1,
415
431
  bili_cookies: encryptedCookies,
416
432
  bili_refresh_token: encryptedRefreshToken
417
433
  }]);
418
434
  this.loginDBData = (await this.ctx.database.get("loginBili", 1))[0];
419
- await this.ctx.ba.loadCookiesFromDatabase();
435
+ await this.ctx["bilibili-notify-api"].loadCookiesFromDatabase();
420
436
  await this.checkIfLoginInfoIsLoaded();
421
437
  this.loginTimer();
422
- const subs = this.configSubsToSubscription(config.subs);
423
- const { code, msg } = await this.loadSubFromConfig(subs);
424
- if (code !== 0) this.logger.error(msg);
425
- ctx.ba.disposeNotifier();
426
- await session.send("登录成功");
427
- await session.execute("bili list");
428
- ctx.ba.enableRefreshCookiesDetect();
438
+ ctx["bilibili-notify-api"].disposeNotifier();
439
+ await session.send("登录成功,请重启插件");
429
440
  }
430
441
  } finally {
431
442
  flag = true;
@@ -441,7 +452,7 @@ var ComRegister = class {
441
452
  await session.send("已发送消息,如未收到则说明您的机器人不支持发送私聊消息或您的信息填写有误");
442
453
  });
443
454
  biliCom.subcommand(".ll").usage("展示当前正在直播的订阅对象").example("bili ll").action(async () => {
444
- const { data: { live_users } } = await ctx.ba.getTheUserWhoIsLiveStreaming();
455
+ const { data: { live_users } } = await ctx["bilibili-notify-api"].getTheUserWhoIsLiveStreaming();
445
456
  const subLiveUsers = [];
446
457
  for (const sub of this.subManager) {
447
458
  let onLive = false;
@@ -463,10 +474,10 @@ var ComRegister = class {
463
474
  });
464
475
  biliCom.subcommand(".dyn <uid:string> [index:number]", "手动推送一条动态信息", { hidden: true }).usage("手动推送一条动态信息").example("bili dyn 233 1 手动推送UID为233用户空间的第一条动态信息").action(async ({ session }, uid, index) => {
465
476
  const i = index && index - 1 || 0;
466
- const content = await this.ctx.ba.getUserSpaceDynamic(uid);
477
+ const content = await this.ctx["bilibili-notify-api"].getUserSpaceDynamic(uid);
467
478
  const item = content.data.items[i];
468
479
  const buffer = await withRetry(async () => {
469
- return await this.ctx.gi.generateDynamicImg(item);
480
+ return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item);
470
481
  }, 1).catch(async (e) => {
471
482
  if (e.message === "直播开播动态,不做处理") {
472
483
  await session.send("直播开播动态,不做处理");
@@ -581,7 +592,7 @@ var ComRegister = class {
581
592
  ["初中", 4],
582
593
  ["毕业", 4]
583
594
  ];
584
- await session.send(/* @__PURE__ */ jsx("message", { children: h.image(await this.ctx.gi.generateWordCloudImg(words, "词云测试"), "image/jpg") }));
595
+ await session.send(/* @__PURE__ */ jsx("message", { children: h.image(await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(words, "词云测试"), "image/jpg") }));
585
596
  const top5DanmakuMaker = [
586
597
  ["张三", 60],
587
598
  ["李四", 48],
@@ -589,19 +600,19 @@ var ComRegister = class {
589
600
  ["赵六", 27],
590
601
  ["田七", 25]
591
602
  ];
592
- const danmakerRankMsg = this.config.liveSummary.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");
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");
593
604
  await session.send(danmakerRankMsg);
594
605
  });
595
606
  biliCom.subcommand(".cap").action(async ({ session }) => {
596
607
  const { code: userInfoCode, data: userInfoData } = await withRetry(async () => {
597
- const data$1 = await this.ctx.ba.getUserInfo("114514");
608
+ const data$1 = await this.ctx["bilibili-notify-api"].getUserInfo("114514");
598
609
  return {
599
610
  code: 0,
600
611
  data: data$1
601
612
  };
602
613
  }).then((content) => content.data);
603
614
  if (userInfoCode !== -352 || !userInfoData.v_voucher) return "不满足验证条件,不需要执行该命令,如果提示风控可以尝试重启插件";
604
- const { data } = await ctx.ba.v_voucherCaptcha(userInfoData.v_voucher);
615
+ const { data } = await ctx["bilibili-notify-api"].v_voucherCaptcha(userInfoData.v_voucher);
605
616
  if (!data.geetest) return "当前风控无法通过该验证解除,或许考虑人工申诉?";
606
617
  await session.send("请到该网站进行验证操作:https://kuresaru.github.io/geetest-validator/");
607
618
  await session.send("请手动填入 gt 和 challenge 后点击生成进行验证,验证完成后点击结果,根据提示输入对应validate");
@@ -610,19 +621,13 @@ var ComRegister = class {
610
621
  await session.send("请直接输入validate");
611
622
  const validate = await session.prompt();
612
623
  const seccode = `${validate}|jordan`;
613
- const { data: validateCaptchaData } = await ctx.ba.validateCaptcha(data.geetest.challenge, data.token, validate, seccode);
624
+ const { data: validateCaptchaData } = await ctx["bilibili-notify-api"].validateCaptcha(data.geetest.challenge, data.token, validate, seccode);
614
625
  if (validateCaptchaData?.is_valid !== 1) return "验证不成功!";
615
- ctx.ba.addCookie(`x-bili-gaia-vtoken=${validateCaptchaData.grisk_id}`);
616
- const encryptedCookies = ctx.ba.encrypt(ctx.ba.getCookies());
617
- await ctx.database.upsert("loginBili", [{
618
- id: 1,
619
- bili_cookies: encryptedCookies
620
- }]);
621
626
  return "验证成功!请重启插件";
622
627
  });
623
628
  }
624
629
  async init(config) {
625
- this.logger = this.ctx.logger("cr");
630
+ this.logger = this.ctx.logger("bilibili-notify-core");
626
631
  this.logger.info("初始化插件中...");
627
632
  this.config = config;
628
633
  this.privateBot = this.ctx.bots.find((bot) => bot.platform === config.master.platform);
@@ -633,6 +638,7 @@ var ComRegister = class {
633
638
  this.logger.info("账号未登录,请登录");
634
639
  return;
635
640
  }
641
+ this.mergeStopWords(config.wordcloudStopWords);
636
642
  if (config.advancedSub) {
637
643
  this.ctx.on("bilibili-notify/advanced-sub", async (subs) => {
638
644
  await this.initAsyncPart(subs);
@@ -662,6 +668,14 @@ var ComRegister = class {
662
668
  this.updateSubNotifier();
663
669
  this.logger.info("插件初始化完毕!");
664
670
  }
671
+ mergeStopWords(stopWordsStr) {
672
+ if (!stopWordsStr || stopWordsStr.trim() === "") {
673
+ this.stopwords = new Set(stop_words_default);
674
+ return;
675
+ }
676
+ const additionalStopWords = stopWordsStr.split(",").map((word) => word.trim()).filter((word) => word !== "");
677
+ this.stopwords = new Set([...stop_words_default, ...additionalStopWords]);
678
+ }
665
679
  initManager() {
666
680
  for (const sub of this.subManager) {
667
681
  if (sub.dynamic) this.dynamicTimelineManager.set(sub.uid, Math.floor(DateTime.now().toSeconds()));
@@ -687,6 +701,7 @@ var ComRegister = class {
687
701
  live: s.live,
688
702
  liveAtAll: s.liveAtAll,
689
703
  liveGuardBuy: s.liveGuardBuy,
704
+ wordcloud: s.wordcloud,
690
705
  bot: null
691
706
  }));
692
707
  const target = [{
@@ -697,9 +712,11 @@ var ComRegister = class {
697
712
  uid: s.uid,
698
713
  dynamic: s.dynamic,
699
714
  live: s.live,
715
+ wordcloud: s.wordcloud,
700
716
  target,
701
717
  card: { enable: false },
702
- liveMsg: { enable: false }
718
+ liveMsg: { enable: false },
719
+ liveSummary: { enable: false }
703
720
  };
704
721
  });
705
722
  return subs;
@@ -716,23 +733,23 @@ var ComRegister = class {
716
733
  if (this.rebootCount >= 3) {
717
734
  this.logger.error("已重启插件三次,请检查机器人状态后使用指令 bn start 启动插件");
718
735
  await this.sendPrivateMsg("已重启插件三次,请检查机器人状态后使用指令 bn start 启动插件");
719
- await this.ctx.sm.disposePlugin();
736
+ await this.ctx["bilibili-notify"].disposePlugin();
720
737
  return;
721
738
  }
722
739
  this.rebootCount++;
723
740
  this.logger.info("插件出现未知错误,正在重启插件");
724
- const flag = await this.ctx.sm.restartPlugin();
741
+ const flag = await this.ctx["bilibili-notify"].restartPlugin();
725
742
  if (flag) this.logger.info("重启插件成功");
726
743
  else {
727
744
  this.logger.error("重启插件失败,请检查机器人状态后使用指令 bn start 启动插件");
728
745
  await this.sendPrivateMsg("重启插件失败,请检查机器人状态后使用指令 bn start 启动插件");
729
- await this.ctx.sm.disposePlugin();
746
+ await this.ctx["bilibili-notify"].disposePlugin();
730
747
  }
731
748
  }
732
749
  async sendPrivateMsgAndStopService() {
733
750
  await this.sendPrivateMsg("插件发生未知错误,请检查机器人状态后使用指令 bn start 启动插件");
734
751
  this.logger.error("插件发生未知错误,请检查机器人状态后使用指令 bn start 启动插件");
735
- await this.ctx.sm.disposePlugin();
752
+ await this.ctx["bilibili-notify"].disposePlugin();
736
753
  return;
737
754
  }
738
755
  async sendMessageWithRetry(bot, channelId, content) {
@@ -752,19 +769,22 @@ var ComRegister = class {
752
769
  const liveMsg = {
753
770
  customLiveStart: this.config.customLiveStart || "",
754
771
  customLive: this.config.customLive || "",
755
- customLiveEnd: this.config.customLiveEnd || ""
772
+ customLiveEnd: this.config.customLiveEnd || "",
773
+ liveSummary: this.config.liveSummary.join("\n") || ""
756
774
  };
757
775
  if (sub.liveMsg.enable) {
758
776
  liveMsg.customLiveStart = sub.liveMsg.customLiveStart || this.config.customLiveStart;
759
777
  liveMsg.customLive = sub.liveMsg.customLive || this.config.customLive;
760
778
  liveMsg.customLiveEnd = sub.liveMsg.customLiveEnd || this.config.customLiveEnd;
761
779
  }
780
+ if (sub.liveSummary.enable) liveMsg.liveSummary = sub.liveSummary.liveSummary || this.config.liveSummary.join("\n");
762
781
  this.liveMsgManager.set(sub.uid, liveMsg);
763
782
  const dynamicArr = [];
764
783
  const dynamicAtAllArr = [];
765
784
  const liveArr = [];
766
785
  const liveAtAllArr = [];
767
786
  const liveGuardBuyArr = [];
787
+ const wordcloudArr = [];
768
788
  for (const platform of sub.target) for (const channel of platform.channelArr) {
769
789
  const target = `${platform.platform}:${channel.channelId}`;
770
790
  if (channel.dynamic) dynamicArr.push(target);
@@ -772,13 +792,15 @@ var ComRegister = class {
772
792
  if (channel.live) liveArr.push(target);
773
793
  if (channel.liveAtAll) liveAtAllArr.push(target);
774
794
  if (channel.liveGuardBuy) liveGuardBuyArr.push(target);
795
+ if (channel.wordcloud) wordcloudArr.push(target);
775
796
  }
776
797
  this.pushArrMap.set(sub.uid, {
777
798
  dynamicArr,
778
799
  dynamicAtAllArr,
779
800
  liveArr,
780
801
  liveAtAllArr,
781
- liveGuardBuyArr
802
+ liveGuardBuyArr,
803
+ wordcloudArr
782
804
  });
783
805
  }
784
806
  this.logger.info("初始化推送群组/频道信息:");
@@ -838,13 +860,21 @@ var ComRegister = class {
838
860
  }, 1);
839
861
  this.logger.info(`成功推送上舰消息:${success.length}条`);
840
862
  }
863
+ if (type === PushType.WordCloud && record.wordcloudArr?.length >= 1) {
864
+ this.logger.info(record.wordcloudArr);
865
+ 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}条`);
870
+ }
841
871
  return;
842
872
  }
843
873
  dynamicDetect() {
844
874
  const handler = async () => {
845
875
  const currentPushDyn = {};
846
876
  const content = await withRetry(async () => {
847
- return await this.ctx.ba.getAllDynamic();
877
+ return await this.ctx["bilibili-notify-api"].getAllDynamic();
848
878
  }, 1).catch((e) => {
849
879
  this.logger.error(`dynamicDetect getAllDynamic() 发生了错误,错误为:${e.message}`);
850
880
  });
@@ -853,13 +883,13 @@ var ComRegister = class {
853
883
  case -101: {
854
884
  this.logger.error("账号未登录,插件已停止工作,请登录后,输入指令 bn start 启动插件");
855
885
  await this.sendPrivateMsg("账号未登录,插件已停止工作,请登录后,输入指令 bn start 启动插件");
856
- await this.ctx.sm.disposePlugin();
886
+ await this.ctx["bilibili-notify"].disposePlugin();
857
887
  break;
858
888
  }
859
889
  case -352: {
860
890
  this.logger.error("账号被风控,插件已停止工作,请确认风控解除后,输入指令 bn start 启动插件");
861
891
  await this.sendPrivateMsg("账号被风控,插件已停止工作,请确认风控解除后,输入指令 bn start 启动插件");
862
- await this.ctx.sm.disposePlugin();
892
+ await this.ctx["bilibili-notify"].disposePlugin();
863
893
  break;
864
894
  }
865
895
  case 4101128:
@@ -884,7 +914,7 @@ var ComRegister = class {
884
914
  if (timeline < postTime) {
885
915
  const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
886
916
  const buffer = await withRetry(async () => {
887
- return await this.ctx.gi.generateDynamicImg(item, sub.card.enable ? sub.card : void 0);
917
+ return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.card.enable ? sub.card : void 0);
888
918
  }, 1).catch(async (e) => {
889
919
  if (e.message === "直播开播动态,不做处理") return;
890
920
  if (e.message === "出现关键词,屏蔽该动态") {
@@ -943,7 +973,7 @@ var ComRegister = class {
943
973
  const currentPushDyn = {};
944
974
  this.logger.info("开始获取动态信息...");
945
975
  const content = await withRetry(async () => {
946
- return await this.ctx.ba.getAllDynamic();
976
+ return await this.ctx["bilibili-notify-api"].getAllDynamic();
947
977
  }, 1).catch((e) => {
948
978
  this.logger.error(`dynamicDetect getAllDynamic() 发生了错误,错误为:${e.message}`);
949
979
  });
@@ -952,13 +982,13 @@ var ComRegister = class {
952
982
  case -101: {
953
983
  this.logger.error("账号未登录,插件已停止工作,请登录后,输入指令 bn start 启动插件");
954
984
  await this.sendPrivateMsg("账号未登录,插件已停止工作,请登录后,输入指令 bn start 启动插件");
955
- await this.ctx.sm.disposePlugin();
985
+ await this.ctx["bilibili-notify"].disposePlugin();
956
986
  break;
957
987
  }
958
988
  case -352: {
959
989
  this.logger.error("账号被风控,插件已停止工作,请确认风控解除后,输入指令 bn start 启动插件");
960
990
  await this.sendPrivateMsg("账号被风控,插件已停止工作,请确认风控解除后,输入指令 bn start 启动插件");
961
- await this.ctx.sm.disposePlugin();
991
+ await this.ctx["bilibili-notify"].disposePlugin();
962
992
  break;
963
993
  }
964
994
  case 4101128:
@@ -989,7 +1019,7 @@ var ComRegister = class {
989
1019
  const sub = this.subManager.find((sub$1) => sub$1.uid === uid);
990
1020
  this.logger.info("开始渲染推送卡片...");
991
1021
  const buffer = await withRetry(async () => {
992
- return await this.ctx.gi.generateDynamicImg(item, sub.card.enable ? sub.card : void 0);
1022
+ return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.card.enable ? sub.card : void 0);
993
1023
  }, 1).catch(async (e) => {
994
1024
  if (e.message === "直播开播动态,不做处理") return;
995
1025
  if (e.message === "出现关键词,屏蔽该动态") {
@@ -1054,7 +1084,7 @@ var ComRegister = class {
1054
1084
  return withLock(handler);
1055
1085
  }
1056
1086
  async useMasterInfo(uid, masterInfo, liveType) {
1057
- const { data } = await this.ctx.ba.getMasterInfo(uid);
1087
+ const { data } = await this.ctx["bilibili-notify-api"].getMasterInfo(uid);
1058
1088
  let liveOpenFollowerNum;
1059
1089
  let liveEndFollowerNum;
1060
1090
  let liveFollowerChange;
@@ -1079,7 +1109,7 @@ var ComRegister = class {
1079
1109
  };
1080
1110
  }
1081
1111
  async useLiveRoomInfo(roomId) {
1082
- const data = await withRetry(async () => await this.ctx.ba.getLiveRoomInfo(roomId)).then((content) => content.data).catch((e) => {
1112
+ const data = await withRetry(async () => await this.ctx["bilibili-notify-api"].getLiveRoomInfo(roomId)).then((content) => content.data).catch((e) => {
1083
1113
  this.logger.error(`liveDetect getLiveRoomInfo 发生了错误,错误为:${e.message}`);
1084
1114
  return false;
1085
1115
  });
@@ -1088,7 +1118,7 @@ var ComRegister = class {
1088
1118
  }
1089
1119
  async sendLiveNotifyCard(liveType, followerDisplay, liveInfo, uid, liveNotifyMsg) {
1090
1120
  const buffer = await withRetry(async () => {
1091
- return await this.ctx.gi.generateLiveImg(liveInfo.liveRoomInfo, liveInfo.masterInfo.username, liveInfo.masterInfo.userface, followerDisplay, liveType, liveInfo.cardStyle.enable ? liveInfo.cardStyle : void 0);
1121
+ return await this.ctx["bilibili-notify-generate-img"].generateLiveImg(liveInfo.liveRoomInfo, liveInfo.masterInfo.username, liveInfo.masterInfo.userface, followerDisplay, liveType, liveInfo.cardStyle.enable ? liveInfo.cardStyle : void 0);
1092
1122
  }, 1).catch((e) => {
1093
1123
  this.logger.error(`liveDetect generateLiveImg() 推送卡片生成失败,原因:${e.message}`);
1094
1124
  });
@@ -1097,14 +1127,14 @@ var ComRegister = class {
1097
1127
  return await this.broadcastToTargets(uid, msg, liveType === LiveType.StartBroadcasting ? PushType.StartBroadcasting : PushType.Live);
1098
1128
  }
1099
1129
  async segmentDanmaku(danmaku, danmakuWeightRecord) {
1100
- this._jieba.cut(danmaku, true).filter((word) => word.length >= 2 && !stopwords.has(word)).map((w) => {
1130
+ this._jieba.cut(danmaku, true).filter((word) => word.length >= 2 && !this.stopwords.has(word)).map((w) => {
1101
1131
  danmakuWeightRecord[w] = (danmakuWeightRecord[w] || 0) + 1;
1102
1132
  });
1103
1133
  }
1104
1134
  addUserToDanmakuMaker(username, danmakuMakerRecord) {
1105
1135
  danmakuMakerRecord[username] = (danmakuMakerRecord[username] || 0) + 1;
1106
1136
  }
1107
- async liveDetectWithListener(roomId, uid, cardStyle) {
1137
+ async liveDetectWithListener(roomId, sub) {
1108
1138
  let liveTime;
1109
1139
  let pushAtTimeTimer;
1110
1140
  const danmakuWeightRecord = {};
@@ -1113,24 +1143,24 @@ var ComRegister = class {
1113
1143
  let liveRoomInfo;
1114
1144
  let masterInfo;
1115
1145
  let watchedNum;
1116
- const liveMsgObj = this.liveMsgManager.get(uid);
1117
- const sendDanmakuWordCloud = async () => {
1146
+ const liveMsgObj = this.liveMsgManager.get(sub.uid);
1147
+ const sendDanmakuWordCloud = async (liveSummary) => {
1118
1148
  this.logger.info("开始制作弹幕词云");
1119
1149
  this.logger.info("正在获取前90热词");
1120
1150
  const top90Words = Object.entries(danmakuWeightRecord).sort((a, b) => b[1] - a[1]).slice(0, 90);
1121
1151
  this.logger.info("弹幕词云前90词及权重:");
1122
1152
  this.logger.info(top90Words);
1123
1153
  this.logger.info("正在准备生成弹幕词云");
1124
- const buffer = await this.ctx.gi.generateWordCloudImg(top90Words, masterInfo.username);
1154
+ const buffer = await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(top90Words, masterInfo.username);
1125
1155
  this.logger.info("弹幕词云生成完成,正在准备发送词云图片");
1126
- await this.broadcastToTargets(uid, h.image(buffer, "image/jpeg"), PushType.Live);
1156
+ await this.broadcastToTargets(sub.uid, h.image(buffer, "image/jpeg"), PushType.Live);
1127
1157
  this.logger.info("词云图片发送完毕!");
1128
1158
  this.logger.info("开始构建弹幕发送排行榜消息");
1129
1159
  const danmakuMakerCount = Object.keys(danmakuMakerRecord).length;
1130
1160
  const danmakuCount = Object.values(danmakuMakerRecord).reduce((sum, val) => sum + val, 0);
1131
1161
  const top5DanmakuMaker = Object.entries(danmakuMakerRecord).sort((a, b) => b[1] - a[1]).slice(0, 5);
1132
- const danmakuMakerMsg = this.config.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");
1133
- await this.broadcastToTargets(uid, danmakuMakerMsg, PushType.Live);
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);
1134
1164
  Object.keys(danmakuWeightRecord).forEach((key) => delete danmakuWeightRecord[key]);
1135
1165
  Object.keys(danmakuMakerRecord).forEach((key) => delete danmakuMakerRecord[key]);
1136
1166
  };
@@ -1147,12 +1177,12 @@ var ComRegister = class {
1147
1177
  }
1148
1178
  liveTime = liveRoomInfo.live_time;
1149
1179
  const watched = watchedNum || "暂未获取到";
1150
- const liveMsg = liveMsgObj?.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1180
+ const liveMsg = liveMsgObj.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1151
1181
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1152
1182
  liveRoomInfo,
1153
1183
  masterInfo,
1154
- cardStyle
1155
- }, uid, liveMsg);
1184
+ cardStyle: sub.card
1185
+ }, sub.uid, liveMsg);
1156
1186
  };
1157
1187
  const useMasterAndLiveRoomInfo = async (liveType) => {
1158
1188
  let flag = true;
@@ -1174,7 +1204,7 @@ var ComRegister = class {
1174
1204
  onError: async () => {
1175
1205
  liveStatus = false;
1176
1206
  pushAtTimeTimer?.();
1177
- this.ctx.bl.closeListener(roomId);
1207
+ this.ctx["bilibili-notify-live"].closeListener(roomId);
1178
1208
  await this.sendPrivateMsg(`[${roomId}]直播间连接发生错误!`);
1179
1209
  this.logger.error(`[${roomId}]直播间连接发生错误!`);
1180
1210
  },
@@ -1199,7 +1229,7 @@ var ComRegister = class {
1199
1229
  body.gift_name,
1200
1230
  ")"
1201
1231
  ] });
1202
- this.broadcastToTargets(uid, content, PushType.LiveGuardBuy);
1232
+ this.broadcastToTargets(sub.uid, content, PushType.LiveGuardBuy);
1203
1233
  },
1204
1234
  onLiveStart: async () => {
1205
1235
  if (liveStatus) return;
@@ -1211,12 +1241,12 @@ var ComRegister = class {
1211
1241
  }
1212
1242
  liveTime = liveRoomInfo.live_time;
1213
1243
  const follower = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
1214
- const liveStartMsg = liveMsgObj?.customLiveStart.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-follower", follower).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1244
+ const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-follower", follower).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1215
1245
  await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1216
1246
  liveRoomInfo,
1217
1247
  masterInfo,
1218
- cardStyle
1219
- }, uid, liveStartMsg);
1248
+ cardStyle: sub.card
1249
+ }, sub.uid, liveStartMsg);
1220
1250
  if (this.config.pushTime !== 0 && !pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1221
1251
  },
1222
1252
  onLiveEnd: async () => {
@@ -1231,28 +1261,28 @@ var ComRegister = class {
1231
1261
  if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
1232
1262
  return liveFollowerChangeNum <= -1e4 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
1233
1263
  })();
1234
- const liveEndMsg = liveMsgObj?.customLiveEnd.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
1264
+ const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
1235
1265
  await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1236
1266
  liveRoomInfo,
1237
1267
  masterInfo,
1238
- cardStyle
1239
- }, uid, liveEndMsg);
1268
+ cardStyle: sub.card
1269
+ }, sub.uid, liveEndMsg);
1240
1270
  pushAtTimeTimer();
1241
1271
  pushAtTimeTimer = null;
1242
- if (this.config.wordcloud) await sendDanmakuWordCloud();
1272
+ if (sub.wordcloud) await sendDanmakuWordCloud(liveMsgObj.liveSummary);
1243
1273
  }
1244
1274
  };
1245
- await this.ctx.bl.startLiveRoomListener(roomId, handler);
1275
+ await this.ctx["bilibili-notify-live"].startLiveRoomListener(roomId, handler);
1246
1276
  if (!await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast)) return this.sendPrivateMsg("获取直播间信息失败,启动直播间弹幕检测失败!");
1247
1277
  if (liveRoomInfo.live_status === 1) {
1248
1278
  liveTime = liveRoomInfo.live_time;
1249
1279
  const watched = watchedNum || "暂未获取到";
1250
- const liveMsg = liveMsgObj?.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1280
+ const liveMsg = liveMsgObj.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
1251
1281
  if (this.config.restartPush) await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1252
1282
  liveRoomInfo,
1253
1283
  masterInfo,
1254
- cardStyle
1255
- }, uid, liveMsg);
1284
+ cardStyle: sub.card
1285
+ }, sub.uid, liveMsg);
1256
1286
  if (this.config.pushTime !== 0 && !pushAtTimeTimer) pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
1257
1287
  liveStatus = true;
1258
1288
  }
@@ -1277,7 +1307,7 @@ var ComRegister = class {
1277
1307
  const uids = [];
1278
1308
  for (const [uid] of this.liveStatusManager.entries()) uids.push(uid);
1279
1309
  const useLiveInfo = async () => {
1280
- const { data: data$1 } = await withRetry(async () => await this.ctx.ba.getLiveRoomInfoByUids(uids), 3).catch(async () => {
1310
+ const { data: data$1 } = await withRetry(async () => await this.ctx["bilibili-notify-api"].getLiveRoomInfoByUids(uids), 3).catch(async () => {
1281
1311
  return void 0;
1282
1312
  });
1283
1313
  if (!data$1) {
@@ -1299,7 +1329,7 @@ var ComRegister = class {
1299
1329
  liveStatus.liveStartTime = liveStatus.liveRoomInfo.live_time;
1300
1330
  liveStatus.liveStartTimeInit = true;
1301
1331
  }
1302
- const liveMsg = liveMsgObj?.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1332
+ const liveMsg = liveMsgObj.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1303
1333
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1304
1334
  liveRoomInfo: liveStatus.liveRoomInfo,
1305
1335
  masterInfo: liveStatus.masterInfo,
@@ -1332,7 +1362,7 @@ var ComRegister = class {
1332
1362
  if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
1333
1363
  return liveFollowerChangeNum <= -1e4 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
1334
1364
  })();
1335
- const liveEndMsg = liveMsgObj?.customLiveEnd.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
1365
+ const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveStatus.liveStartTime)).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
1336
1366
  await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1337
1367
  liveRoomInfo: liveStatus.liveRoomInfo,
1338
1368
  masterInfo: liveStatus.masterInfo,
@@ -1351,7 +1381,7 @@ var ComRegister = class {
1351
1381
  liveStatus.liveStartTime = liveStatus.liveRoomInfo.live_time;
1352
1382
  liveStatus.liveStartTimeInit = true;
1353
1383
  const follower = liveStatus.masterInfo.liveOpenFollowerNum >= 1e4 ? `${(liveStatus.masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : liveStatus.masterInfo.liveOpenFollowerNum.toString();
1354
- const liveStartMsg = liveMsgObj?.customLiveStart.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-follower", follower).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1384
+ const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveStatus.liveStartTime)).replace("-follower", follower).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1355
1385
  await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1356
1386
  liveRoomInfo: liveStatus.liveRoomInfo,
1357
1387
  masterInfo: liveStatus.masterInfo,
@@ -1372,7 +1402,7 @@ var ComRegister = class {
1372
1402
  liveStatus.liveStartTime = liveStatus.liveRoomInfo.live_time;
1373
1403
  liveStatus.liveStartTimeInit = true;
1374
1404
  }
1375
- const liveMsg = liveMsgObj?.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx.gi.getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1405
+ const liveMsg = liveMsgObj.customLive.replace("-name", liveStatus.masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveStatus.liveStartTime)).replace("-watched", "API模式无法获取").replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`);
1376
1406
  await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1377
1407
  liveRoomInfo: liveStatus.liveRoomInfo,
1378
1408
  masterInfo: liveStatus.masterInfo,
@@ -1408,7 +1438,7 @@ var ComRegister = class {
1408
1438
  async checkIfLoginInfoIsLoaded() {
1409
1439
  return new Promise((resolve$1) => {
1410
1440
  const check = () => {
1411
- if (!this.ctx.ba.getLoginInfoIsLoaded()) this.ctx.setTimeout(check, 500);
1441
+ if (!this.ctx["bilibili-notify-api"].getLoginInfoIsLoaded()) this.ctx.setTimeout(check, 500);
1412
1442
  else resolve$1("success");
1413
1443
  };
1414
1444
  check();
@@ -1417,9 +1447,9 @@ var ComRegister = class {
1417
1447
  async subUserInBili(mid) {
1418
1448
  const checkGroupIsReady = async () => {
1419
1449
  if (!this.loginDBData?.dynamic_group_id) {
1420
- const createGroupData = await this.ctx.ba.createGroup("订阅");
1450
+ const createGroupData = await this.ctx["bilibili-notify-api"].createGroup("订阅");
1421
1451
  if (createGroupData.code === 22106) {
1422
- const allGroupData = await this.ctx.ba.getAllGroup();
1452
+ const allGroupData = await this.ctx["bilibili-notify-api"].getAllGroup();
1423
1453
  for (const group of allGroupData.data) if (group.name === "订阅") {
1424
1454
  this.loginDBData.dynamic_group_id = group.tagid.toString();
1425
1455
  this.ctx.database.set("loginBili", 1, { dynamic_group_id: this.loginDBData.dynamic_group_id });
@@ -1446,7 +1476,7 @@ var ComRegister = class {
1446
1476
  const resp = await checkGroupIsReady();
1447
1477
  if (resp.code !== 0) return resp;
1448
1478
  const getGroupDetailData = async () => {
1449
- const relationGroupDetailData = await this.ctx.ba.getRelationGroupDetail(this.loginDBData.dynamic_group_id);
1479
+ const relationGroupDetailData = await this.ctx["bilibili-notify-api"].getRelationGroupDetail(this.loginDBData.dynamic_group_id);
1450
1480
  if (relationGroupDetailData.code !== 0) {
1451
1481
  if (relationGroupDetailData.code === 22104) {
1452
1482
  this.loginDBData.dynamic_group_id = null;
@@ -1475,7 +1505,7 @@ var ComRegister = class {
1475
1505
  code: 0,
1476
1506
  msg: "订阅对象已存在于分组中"
1477
1507
  };
1478
- const subUserData = await this.ctx.ba.follow(mid);
1508
+ const subUserData = await this.ctx["bilibili-notify-api"].follow(mid);
1479
1509
  const subUserMatchPattern = {
1480
1510
  [-101]: () => {
1481
1511
  return {
@@ -1520,7 +1550,7 @@ var ComRegister = class {
1520
1550
  };
1521
1551
  },
1522
1552
  22014: async () => {
1523
- const copyUserToGroupData = await this.ctx.ba.copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
1553
+ const copyUserToGroupData = await this.ctx["bilibili-notify-api"].copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
1524
1554
  if (copyUserToGroupData.code !== 0) return {
1525
1555
  code: copyUserToGroupData.code,
1526
1556
  msg: "添加订阅对象到分组失败,请稍后重试"
@@ -1531,7 +1561,7 @@ var ComRegister = class {
1531
1561
  };
1532
1562
  },
1533
1563
  0: async () => {
1534
- const copyUserToGroupData = await this.ctx.ba.copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
1564
+ const copyUserToGroupData = await this.ctx["bilibili-notify-api"].copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
1535
1565
  if (copyUserToGroupData.code !== 0) return {
1536
1566
  code: copyUserToGroupData.code,
1537
1567
  msg: "添加订阅对象到分组失败,请稍后重试"
@@ -1549,7 +1579,7 @@ var ComRegister = class {
1549
1579
  for (const sub of Object.values(subs)) {
1550
1580
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1551
1581
  const { code: userInfoCode, message: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1552
- const data = await this.ctx.ba.getUserInfo(sub.uid);
1582
+ const data = await this.ctx["bilibili-notify-api"].getUserInfo(sub.uid);
1553
1583
  return {
1554
1584
  code: 0,
1555
1585
  data
@@ -1578,7 +1608,7 @@ var ComRegister = class {
1578
1608
  sub.live = false;
1579
1609
  this.logger.warn(`UID:${sub.uid} 用户没有开通直播间,无法订阅直播!`);
1580
1610
  }
1581
- if (sub.live) await this.liveDetectWithListener(userInfoData.live_room.roomid, sub.uid, sub.card);
1611
+ if (sub.live) await this.liveDetectWithListener(userInfoData.live_room.roomid, sub);
1582
1612
  }
1583
1613
  const subInfo = await this.subUserInBili(sub.uid);
1584
1614
  if (subInfo.code !== 0) return subInfo;
@@ -1626,7 +1656,7 @@ var ComRegister = class {
1626
1656
  }
1627
1657
  async checkIfIsLogin() {
1628
1658
  if ((await this.ctx.database.get("loginBili", 1)).length !== 0) {
1629
- if (this.ctx.ba.getCookies() !== "[]") return true;
1659
+ if (this.ctx["bilibili-notify-api"].getCookies() !== "[]") return true;
1630
1660
  }
1631
1661
  return false;
1632
1662
  }
@@ -1642,6 +1672,7 @@ var ComRegister = class {
1642
1672
  live: Schema.boolean().default(true).description("直播"),
1643
1673
  liveAtAll: Schema.boolean().default(true).description("直播At全体"),
1644
1674
  liveGuardBuy: Schema.boolean().default(false).description("上舰消息"),
1675
+ wordcloud: Schema.boolean().default(true).description("弹幕词云"),
1645
1676
  platform: Schema.string().required().description("平台名"),
1646
1677
  target: Schema.string().required().description("群号/频道号")
1647
1678
  })).role("table").description("输入订阅信息,自定义订阅内容; 群号/频道号格式:频道号,频道号 使用英文逗号分隔,例如 1234567,2345678"),
@@ -1652,8 +1683,8 @@ var ComRegister = class {
1652
1683
  masterAccountGuildId: Schema.string()
1653
1684
  }),
1654
1685
  liveDetectType: Schema.string(),
1655
- wordcloud: Schema.boolean(),
1656
- liveSummary: Schema.string(),
1686
+ wordcloudStopWords: Schema.string(),
1687
+ liveSummary: Schema.array(String),
1657
1688
  restartPush: Schema.boolean().required(),
1658
1689
  pushTime: Schema.number().required(),
1659
1690
  pushImgsInDynamic: Schema.boolean().required(),
@@ -1710,10 +1741,10 @@ const DYNAMIC_TYPE_LIVE_RCMD = "DYNAMIC_TYPE_LIVE_RCMD";
1710
1741
  const DYNAMIC_TYPE_UGC_SEASON = "DYNAMIC_TYPE_UGC_SEASON";
1711
1742
  const ADDITIONAL_TYPE_RESERVE = "ADDITIONAL_TYPE_RESERVE";
1712
1743
  var GenerateImg = class extends Service {
1713
- static inject = ["puppeteer", "ba"];
1744
+ static inject = ["puppeteer"];
1714
1745
  giConfig;
1715
1746
  constructor(ctx, config) {
1716
- super(ctx, "gi");
1747
+ super(ctx, "bilibili-notify-generate-img");
1717
1748
  this.giConfig = config;
1718
1749
  }
1719
1750
  async imgHandler(html) {
@@ -3293,7 +3324,7 @@ var BiliAPI = class extends Service {
3293
3324
  pRetry;
3294
3325
  AbortError;
3295
3326
  constructor(ctx, config) {
3296
- super(ctx, "ba");
3327
+ super(ctx, "bilibili-notify-api");
3297
3328
  this.apiConfig = config;
3298
3329
  }
3299
3330
  async start() {
@@ -3956,17 +3987,17 @@ var bili_api_default = BiliAPI;
3956
3987
  //#endregion
3957
3988
  //#region src/bili_live.ts
3958
3989
  var BLive = class extends Service {
3959
- static inject = ["ba"];
3990
+ static inject = ["bilibili-notify-api"];
3960
3991
  listenerRecord = {};
3961
3992
  constructor(ctx) {
3962
- super(ctx, "bl");
3993
+ super(ctx, "bilibili-notify-live");
3963
3994
  }
3964
3995
  stop() {
3965
3996
  for (const key of Object.keys(this.listenerRecord)) this.closeListener(key);
3966
3997
  }
3967
3998
  async startLiveRoomListener(roomId, handler) {
3968
- const cookiesStr = await this.ctx.ba.getCookiesForHeader();
3969
- const mySelfInfo = await this.ctx.ba.getMyselfInfo();
3999
+ const cookiesStr = await this.ctx["bilibili-notify-api"].getCookiesForHeader();
4000
+ const mySelfInfo = await this.ctx["bilibili-notify-api"].getMyselfInfo();
3970
4001
  this.listenerRecord[roomId] = startListen(Number.parseInt(roomId), handler, { ws: {
3971
4002
  headers: { Cookie: cookiesStr },
3972
4003
  uid: mySelfInfo.data.mid
@@ -4002,8 +4033,8 @@ let globalConfig;
4002
4033
  var ServerManager = class extends Service {
4003
4034
  servers = [];
4004
4035
  constructor(ctx) {
4005
- super(ctx, "sm");
4006
- const sysCom = ctx.command("bn", "bili-notify插件运行相关指令", { permissions: ["authority:5"] });
4036
+ super(ctx, "bilibili-notify");
4037
+ const sysCom = ctx.command("bn", "bilibili-notify 插件运行相关指令", { permissions: ["authority:5"] });
4007
4038
  sysCom.subcommand(".restart", "重启插件").usage("重启插件").example("bn restart").action(async () => {
4008
4039
  this.logger.info("调用 bn restart 指令");
4009
4040
  if (await this.restartPlugin()) return "插件重启成功";
@@ -4046,7 +4077,7 @@ var ServerManager = class extends Service {
4046
4077
  advancedSub: globalConfig.advancedSub,
4047
4078
  subs: globalConfig.subs,
4048
4079
  master: globalConfig.master,
4049
- wordcloud: globalConfig.wordcloud,
4080
+ wordcloudStopWords: globalConfig.wordcloudStopWords,
4050
4081
  liveSummary: globalConfig.liveSummary,
4051
4082
  liveDetectType: globalConfig.liveDetectType,
4052
4083
  restartPush: globalConfig.restartPush,