koishi-plugin-bilibili-notify 3.2.1-alpha.8 → 3.2.1-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,18 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@satorijs/element/jsx-runtime";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("@satorijs/element/jsx-runtime");
2
7
  // Koishi核心依赖
3
- import { Schema, h, } from "koishi";
4
- import QRCode from "qrcode";
5
- import { CronJob } from "cron";
8
+ const koishi_1 = require("koishi");
9
+ const qrcode_1 = __importDefault(require("qrcode"));
10
+ const cron_1 = require("cron");
6
11
  // Utils
7
- import { withLock, withRetry } from "./utils";
12
+ const utils_1 = require("./utils");
8
13
  // Types
9
- import { LiveType, PushType, } from "./type";
10
- import { DateTime } from "luxon";
14
+ const type_1 = require("./type");
15
+ const luxon_1 = require("luxon");
11
16
  class ComRegister {
12
17
  // 必须服务
13
18
  static inject = ["ba", "gi", "database", "bl", "sm"];
@@ -118,7 +123,7 @@ class ComRegister {
118
123
  if (content.code !== 0)
119
124
  return await session.send("出问题咯,请联系管理员解决");
120
125
  // 生成二维码
121
- QRCode.toBuffer(content.data.url, {
126
+ qrcode_1.default.toBuffer(content.data.url, {
122
127
  errorCorrectionLevel: "H", // 错误更正水平
123
128
  type: "png", // 输出类型
124
129
  margin: 1, // 边距大小
@@ -129,7 +134,7 @@ class ComRegister {
129
134
  }, async (err, buffer) => {
130
135
  if (err)
131
136
  return await session.send("二维码生成出错,请重新尝试");
132
- await session.send(h.image(buffer, "image/jpeg"));
137
+ await session.send(koishi_1.h.image(buffer, "image/jpeg"));
133
138
  });
134
139
  // 检查之前是否存在登录定时器
135
140
  if (this.loginTimer)
@@ -267,7 +272,7 @@ class ComRegister {
267
272
  // 获取动态内容
268
273
  const item = content.data.items[i];
269
274
  // 生成图片
270
- const buffer = await withRetry(async () => {
275
+ const buffer = await (0, utils_1.withRetry)(async () => {
271
276
  // 渲染图片
272
277
  return await this.ctx.gi.generateDynamicImg(item);
273
278
  }, 1).catch(async (e) => {
@@ -292,7 +297,7 @@ class ComRegister {
292
297
  this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
293
298
  });
294
299
  // 发送图片
295
- buffer && (await session.send(h.image(buffer, "image/jpeg")));
300
+ buffer && (await session.send(koishi_1.h.image(buffer, "image/jpeg")));
296
301
  });
297
302
  }
298
303
  async init(config) {
@@ -357,7 +362,7 @@ class ComRegister {
357
362
  initManager() {
358
363
  for (const sub of this.subManager) {
359
364
  if (sub.dynamic) {
360
- this.dynamicTimelineManager.set(sub.uid, Math.floor(DateTime.now().toSeconds()));
365
+ this.dynamicTimelineManager.set(sub.uid, Math.floor(luxon_1.DateTime.now().toSeconds()));
361
366
  }
362
367
  if (sub.live) {
363
368
  this.liveStatusManager.set(sub.uid, {
@@ -439,7 +444,7 @@ class ComRegister {
439
444
  async sendMessageWithRetry(bot, channelId,
440
445
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
441
446
  content) {
442
- withRetry(async () => await bot.sendMessage(channelId, content), 1).catch(async (e) => {
447
+ (0, utils_1.withRetry)(async () => await bot.sendMessage(channelId, content), 1).catch(async (e) => {
443
448
  if (e.message === "this._request is not a function") {
444
449
  // 2S之后重新发送消息
445
450
  this.ctx.setTimeout(async () => {
@@ -457,7 +462,7 @@ class ComRegister {
457
462
  // 定义数组
458
463
  const pushArr = [];
459
464
  // 判断类型
460
- if (type === PushType.Live || type === PushType.StartBroadcasting) {
465
+ if (type === type_1.PushType.Live || type === type_1.PushType.StartBroadcasting) {
461
466
  for (const target of targets) {
462
467
  for (const channel of target.channelArr) {
463
468
  if (channel.live) {
@@ -467,7 +472,7 @@ class ComRegister {
467
472
  }
468
473
  return pushArr;
469
474
  }
470
- if (type === PushType.Dynamic) {
475
+ if (type === type_1.PushType.Dynamic) {
471
476
  for (const target of targets) {
472
477
  for (const channel of target.channelArr) {
473
478
  if (channel.dynamic) {
@@ -477,7 +482,7 @@ class ComRegister {
477
482
  }
478
483
  return pushArr;
479
484
  }
480
- if (type === PushType.LiveGuardBuy) {
485
+ if (type === type_1.PushType.LiveGuardBuy) {
481
486
  for (const target of targets) {
482
487
  for (const channel of target.channelArr) {
483
488
  if (channel.liveGuardBuy) {
@@ -497,7 +502,7 @@ class ComRegister {
497
502
  // logger
498
503
  this.logger.info(`推送消息到 ${pushArr.length} 个目标频道,目标频道为:${pushArr.join(", ")}`);
499
504
  // 推送消息
500
- await withRetry(async () => {
505
+ await (0, utils_1.withRetry)(async () => {
501
506
  await this.ctx.broadcast(pushArr, content);
502
507
  }, 1);
503
508
  // 结束
@@ -518,28 +523,28 @@ class ComRegister {
518
523
  }
519
524
  // 模式匹配
520
525
  const pushTypePatternMatching = {
521
- [PushType.Live]: async () => {
526
+ [type_1.PushType.Live]: async () => {
522
527
  if (targetChannel.live) {
523
528
  // 直接推送
524
529
  await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
525
530
  }
526
531
  },
527
- [PushType.Dynamic]: async () => {
532
+ [type_1.PushType.Dynamic]: async () => {
528
533
  if (targetChannel.dynamic) {
529
534
  await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
530
535
  }
531
536
  },
532
- [PushType.StartBroadcasting]: async () => {
537
+ [type_1.PushType.StartBroadcasting]: async () => {
533
538
  // 判断是否需要推送直播消息
534
539
  if (targetChannel.live) {
535
540
  await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
536
541
  }
537
542
  // 判断是否需要艾特全体成员
538
543
  if (targetChannel.atAll) {
539
- await this.sendMessageWithRetry(bot, targetChannel.channelId, _jsx("at", { type: "all" }));
544
+ await this.sendMessageWithRetry(bot, targetChannel.channelId, (0, jsx_runtime_1.jsx)("at", { type: "all" }));
540
545
  }
541
546
  },
542
- [PushType.LiveGuardBuy]: async () => {
547
+ [type_1.PushType.LiveGuardBuy]: async () => {
543
548
  // 判断是否需要推送直播消息
544
549
  if (targetChannel.liveGuardBuy) {
545
550
  await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
@@ -555,7 +560,7 @@ class ComRegister {
555
560
  // 定义本次请求推送的动态
556
561
  const currentPushDyn = {};
557
562
  // 使用withRetry函数进行重试
558
- const content = await withRetry(async () => {
563
+ const content = await (0, utils_1.withRetry)(async () => {
559
564
  // 获取动态内容
560
565
  return (await this.ctx.ba.getAllDynamic());
561
566
  }, 1).catch((e) => {
@@ -629,7 +634,7 @@ class ComRegister {
629
634
  // 获取订阅对象
630
635
  const sub = this.subManager.find((sub) => sub.uid === uid);
631
636
  // 推送该条动态
632
- const buffer = await withRetry(async () => {
637
+ const buffer = await (0, utils_1.withRetry)(async () => {
633
638
  // 渲染图片
634
639
  return await this.ctx.gi.generateDynamicImg(item, sub.card.enable ? sub.card : undefined);
635
640
  }, 1).catch(async (e) => {
@@ -639,19 +644,19 @@ class ComRegister {
639
644
  if (e.message === "出现关键词,屏蔽该动态") {
640
645
  // 如果需要发送才发送
641
646
  if (this.config.filter.notify) {
642
- await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, PushType.Dynamic);
647
+ await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
643
648
  }
644
649
  return;
645
650
  }
646
651
  if (e.message === "已屏蔽转发动态") {
647
652
  if (this.config.filter.notify) {
648
- await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, PushType.Dynamic);
653
+ await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
649
654
  }
650
655
  return;
651
656
  }
652
657
  if (e.message === "已屏蔽专栏动态") {
653
658
  if (this.config.filter.notify) {
654
- await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, PushType.Dynamic);
659
+ await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, type_1.PushType.Dynamic);
655
660
  }
656
661
  return;
657
662
  }
@@ -678,7 +683,7 @@ class ComRegister {
678
683
  // logger
679
684
  this.logger.info("推送动态中...");
680
685
  // 发送推送卡片
681
- await this.broadcastToTargets(sub.target, _jsxs(_Fragment, { children: [h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
686
+ await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), dUrl] }), type_1.PushType.Dynamic);
682
687
  // 判断是否需要发送动态中的图片
683
688
  if (this.config.pushImgsInDynamic) {
684
689
  // 判断是否为图文动态
@@ -688,7 +693,7 @@ class ComRegister {
688
693
  // 判断pics是否存在
689
694
  if (pics) {
690
695
  for (const pic of pics) {
691
- await this.broadcastToTargets(sub.target, _jsx("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }), PushType.Dynamic);
696
+ await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
692
697
  // 随机睡眠1-3秒
693
698
  await this.ctx.sleep(Math.floor(Math.random() * 2000) + 1000);
694
699
  }
@@ -714,7 +719,7 @@ class ComRegister {
714
719
  }
715
720
  };
716
721
  // 返回一个闭包函数
717
- return withLock(handler);
722
+ return (0, utils_1.withLock)(handler);
718
723
  }
719
724
  debug_dynamicDetect() {
720
725
  // 定义handler
@@ -724,7 +729,7 @@ class ComRegister {
724
729
  // logger
725
730
  this.logger.info("开始获取动态信息...");
726
731
  // 使用withRetry函数进行重试
727
- const content = await withRetry(async () => {
732
+ const content = await (0, utils_1.withRetry)(async () => {
728
733
  // 获取动态内容
729
734
  return (await this.ctx.ba.getAllDynamic());
730
735
  }, 1).catch((e) => {
@@ -793,7 +798,7 @@ class ComRegister {
793
798
  const uid = item.modules.module_author.mid.toString();
794
799
  const name = item.modules.module_author.name;
795
800
  // logger
796
- this.logger.info(`获取到动态信息,UP主:${name},UID:${uid},动态发布时间:${DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
801
+ this.logger.info(`获取到动态信息,UP主:${name},UID:${uid},动态发布时间:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
797
802
  // 判断是否存在时间线
798
803
  if (this.dynamicTimelineManager.has(uid)) {
799
804
  // logger
@@ -801,7 +806,7 @@ class ComRegister {
801
806
  // 寻找关注的UP主
802
807
  const timeline = this.dynamicTimelineManager.get(uid);
803
808
  // logger
804
- this.logger.info(`上次推送时间线:${DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
809
+ this.logger.info(`上次推送时间线:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
805
810
  // 判断动态发布时间是否大于时间线
806
811
  if (timeline < postTime) {
807
812
  // logger
@@ -811,7 +816,7 @@ class ComRegister {
811
816
  // logger
812
817
  this.logger.info("开始渲染推送卡片...");
813
818
  // 推送该条动态
814
- const buffer = await withRetry(async () => {
819
+ const buffer = await (0, utils_1.withRetry)(async () => {
815
820
  // 渲染图片
816
821
  return await this.ctx.gi.generateDynamicImg(item, sub.card.enable ? sub.card : undefined);
817
822
  }, 1).catch(async (e) => {
@@ -821,19 +826,19 @@ class ComRegister {
821
826
  if (e.message === "出现关键词,屏蔽该动态") {
822
827
  // 如果需要发送才发送
823
828
  if (this.config.filter.notify) {
824
- await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, PushType.Dynamic);
829
+ await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
825
830
  }
826
831
  return;
827
832
  }
828
833
  if (e.message === "已屏蔽转发动态") {
829
834
  if (this.config.filter.notify) {
830
- await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, PushType.Dynamic);
835
+ await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
831
836
  }
832
837
  return;
833
838
  }
834
839
  if (e.message === "已屏蔽专栏动态") {
835
840
  if (this.config.filter.notify) {
836
- await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, PushType.Dynamic);
841
+ await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, type_1.PushType.Dynamic);
837
842
  }
838
843
  return;
839
844
  }
@@ -867,7 +872,7 @@ class ComRegister {
867
872
  // logger
868
873
  this.logger.info("推送动态中...");
869
874
  // 发送推送卡片
870
- await this.broadcastToTargets(sub.target, _jsxs(_Fragment, { children: [h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
875
+ await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), dUrl] }), type_1.PushType.Dynamic);
871
876
  // 判断是否需要发送动态中的图片
872
877
  if (this.config.pushImgsInDynamic) {
873
878
  // logger
@@ -879,7 +884,7 @@ class ComRegister {
879
884
  // 判断pics是否存在
880
885
  if (pics) {
881
886
  for (const pic of pics) {
882
- await this.broadcastToTargets(sub.target, _jsx("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }), PushType.Dynamic);
887
+ await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
883
888
  // 随机睡眠1-3秒
884
889
  await this.ctx.sleep(Math.floor(Math.random() * 2000) + 1000);
885
890
  }
@@ -907,13 +912,13 @@ class ComRegister {
907
912
  // 更新当前时间线
908
913
  this.dynamicTimelineManager.set(uid, postTime);
909
914
  // logger
910
- this.logger.info(`更新时间线成功,UP主:${uid},时间线:${DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
915
+ this.logger.info(`更新时间线成功,UP主:${uid},时间线:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
911
916
  }
912
917
  // logger
913
918
  this.logger.info(`本次推送动态数量:${Object.keys(currentPushDyn).length}`);
914
919
  };
915
920
  // 返回一个闭包函数
916
- return withLock(handler);
921
+ return (0, utils_1.withLock)(handler);
917
922
  }
918
923
  // 定义获取主播信息方法
919
924
  async useMasterInfo(uid, masterInfo, liveType) {
@@ -924,8 +929,8 @@ class ComRegister {
924
929
  let liveEndFollowerNum;
925
930
  let liveFollowerChange;
926
931
  // 判断直播状态
927
- if (liveType === LiveType.StartBroadcasting ||
928
- liveType === LiveType.FirstLiveBroadcast) {
932
+ if (liveType === type_1.LiveType.StartBroadcasting ||
933
+ liveType === type_1.LiveType.FirstLiveBroadcast) {
929
934
  // 第一次启动或刚开播
930
935
  // 将当前粉丝数赋值给liveOpenFollowerNum、liveEndFollowerNum
931
936
  liveOpenFollowerNum = data.follower_num;
@@ -933,8 +938,8 @@ class ComRegister {
933
938
  // 将粉丝数变化赋值为0
934
939
  liveFollowerChange = 0;
935
940
  }
936
- if (liveType === LiveType.StopBroadcast ||
937
- liveType === LiveType.LiveBroadcast) {
941
+ if (liveType === type_1.LiveType.StopBroadcast ||
942
+ liveType === type_1.LiveType.LiveBroadcast) {
938
943
  // 将上一次的liveOpenFollowerNum赋值给本次的liveOpenFollowerNum
939
944
  liveOpenFollowerNum = masterInfo.liveOpenFollowerNum;
940
945
  // 将当前粉丝数赋值给liveEndFollowerNum
@@ -954,7 +959,7 @@ class ComRegister {
954
959
  }
955
960
  async useLiveRoomInfo(roomId) {
956
961
  // 发送请求获取直播间信息
957
- const data = await withRetry(async () => await this.ctx.ba.getLiveRoomInfo(roomId))
962
+ const data = await (0, utils_1.withRetry)(async () => await this.ctx.ba.getLiveRoomInfo(roomId))
958
963
  .then((content) => content.data)
959
964
  .catch((e) => {
960
965
  this.logger.error(`liveDetect getLiveRoomInfo 发生了错误,错误为:${e.message}`);
@@ -969,7 +974,7 @@ class ComRegister {
969
974
  }
970
975
  async sendLiveNotifyCard(liveType, followerDisplay, liveInfo, target, liveNotifyMsg) {
971
976
  // 生成图片
972
- const buffer = await withRetry(async () => {
977
+ const buffer = await (0, utils_1.withRetry)(async () => {
973
978
  // 获取直播通知卡片
974
979
  return await this.ctx.gi.generateLiveImg(liveInfo.liveRoomInfo, liveInfo.masterInfo.username, liveInfo.masterInfo.userface, followerDisplay, liveType, liveInfo.cardStyle.enable ? liveInfo.cardStyle : undefined);
975
980
  }, 1).catch((e) => {
@@ -979,11 +984,11 @@ class ComRegister {
979
984
  if (!buffer)
980
985
  return await this.sendPrivateMsgAndStopService();
981
986
  // 推送直播信息
982
- const msg = (_jsxs(_Fragment, { children: [h.image(buffer, "image/jpeg"), liveNotifyMsg || ""] }));
987
+ const msg = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), liveNotifyMsg || ""] }));
983
988
  // 只有在开播时才艾特全体成员
984
- return await this.broadcastToTargets(target, msg, liveType === LiveType.StartBroadcasting
985
- ? PushType.StartBroadcasting
986
- : PushType.Live);
989
+ return await this.broadcastToTargets(target, msg, liveType === type_1.LiveType.StartBroadcasting
990
+ ? type_1.PushType.StartBroadcasting
991
+ : type_1.PushType.Live);
987
992
  }
988
993
  async liveDetectWithListener(roomId, target, cardStyle) {
989
994
  // 定义开播时间
@@ -992,10 +997,6 @@ class ComRegister {
992
997
  let pushAtTimeTimer;
993
998
  // 定义弹幕存放数组
994
999
  const currentLiveDanmakuArr = [];
995
- // init flag
996
- let initFlag = false;
997
- // 连接中断flag
998
- let connFlag = false;
999
1000
  // 定义开播状态
1000
1001
  let liveStatus = false;
1001
1002
  // 定义channelIdArr总长度
@@ -1021,7 +1022,7 @@ class ComRegister {
1021
1022
  // 定义定时推送函数
1022
1023
  const pushAtTimeFunc = async () => {
1023
1024
  // 判断是否信息是否获取成功
1024
- if (!(await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast))) {
1025
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.LiveBroadcast))) {
1025
1026
  // 未获取成功,直接返回
1026
1027
  await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
1027
1028
  // 停止服务
@@ -1052,7 +1053,7 @@ class ComRegister {
1052
1053
  .replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`)
1053
1054
  : null;
1054
1055
  // 发送直播通知卡片
1055
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1056
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, watched, {
1056
1057
  liveRoomInfo,
1057
1058
  masterInfo,
1058
1059
  cardStyle,
@@ -1088,31 +1089,6 @@ class ComRegister {
1088
1089
  };
1089
1090
  // 构建消息处理函数
1090
1091
  const handler = {
1091
- onOpen: () => {
1092
- if (!initFlag) {
1093
- // init flag设置为true
1094
- initFlag = true;
1095
- // connFlag设置为false
1096
- connFlag = false;
1097
- // logger
1098
- this.logger.info(`[${roomId}]直播间连接已建立!`);
1099
- }
1100
- },
1101
- onClose: async () => {
1102
- if (!connFlag) {
1103
- // 更直播状态
1104
- liveStatus = false;
1105
- // 关闭定时推送
1106
- pushAtTimeTimer?.();
1107
- // 停止服务
1108
- this.ctx.bl.closeListener(roomId);
1109
- // 更改connFlag
1110
- connFlag = true;
1111
- // 发送消息
1112
- await this.sendPrivateMsg(`[${roomId}]直播间连接已中断!`);
1113
- this.logger.error(`[${roomId}]直播间连接已中断!`);
1114
- }
1115
- },
1116
1092
  onError: async () => {
1117
1093
  // 更直播状态
1118
1094
  liveStatus = false;
@@ -1141,7 +1117,7 @@ class ComRegister {
1141
1117
  const content = `[${masterInfo.username}的直播间]「${body.user.uname}」加入了大航海(${body.gift_name})`;
1142
1118
  // 直接发送消息
1143
1119
  channelArrLen > 0 &&
1144
- this.broadcastToTargets(liveGuardBuyPushTargetArr, content, PushType.LiveGuardBuy);
1120
+ this.broadcastToTargets(liveGuardBuyPushTargetArr, content, type_1.PushType.LiveGuardBuy);
1145
1121
  },
1146
1122
  onLiveStart: async () => {
1147
1123
  // 判断是否已经开播
@@ -1150,7 +1126,7 @@ class ComRegister {
1150
1126
  // 设置开播状态为true
1151
1127
  liveStatus = true;
1152
1128
  // 判断是否信息是否获取成功
1153
- if (!(await useMasterAndLiveRoomInfo(LiveType.StartBroadcasting))) {
1129
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StartBroadcasting))) {
1154
1130
  // 设置开播状态为false
1155
1131
  liveStatus = false;
1156
1132
  // 未获取成功,直接返回
@@ -1174,7 +1150,7 @@ class ComRegister {
1174
1150
  .replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`)
1175
1151
  : null;
1176
1152
  // 推送开播通知
1177
- await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1153
+ await this.sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, {
1178
1154
  liveRoomInfo,
1179
1155
  masterInfo,
1180
1156
  cardStyle,
@@ -1189,7 +1165,7 @@ class ComRegister {
1189
1165
  // 将直播状态设置为false
1190
1166
  liveStatus = false;
1191
1167
  // 判断是否信息是否获取成功
1192
- if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast))) {
1168
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast))) {
1193
1169
  // 未获取成功,直接返回
1194
1170
  await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1195
1171
  // 停止服务
@@ -1222,7 +1198,7 @@ class ComRegister {
1222
1198
  .replace("\\n", "\n")
1223
1199
  : null;
1224
1200
  // 推送通知卡片
1225
- await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1201
+ await this.sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, {
1226
1202
  liveRoomInfo,
1227
1203
  masterInfo,
1228
1204
  cardStyle,
@@ -1236,7 +1212,7 @@ class ComRegister {
1236
1212
  // 启动直播间弹幕监测
1237
1213
  await this.ctx.bl.startLiveRoomListener(roomId, handler);
1238
1214
  // 第一次启动获取信息并判信息是否获取成功
1239
- if (!(await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast))) {
1215
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.FirstLiveBroadcast))) {
1240
1216
  // 未获取成功,直接返回
1241
1217
  return this.sendPrivateMsg("获取直播间信息失败,启动直播间弹幕检测失败!");
1242
1218
  }
@@ -1257,7 +1233,7 @@ class ComRegister {
1257
1233
  : null;
1258
1234
  // 发送直播通知卡片
1259
1235
  if (this.config.restartPush) {
1260
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1236
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, watched, {
1261
1237
  liveRoomInfo,
1262
1238
  masterInfo,
1263
1239
  cardStyle,
@@ -1307,7 +1283,7 @@ class ComRegister {
1307
1283
  }
1308
1284
  const useLiveInfo = async () => {
1309
1285
  // 发送请求
1310
- const { data } = await withRetry(async () => (await this.ctx.ba.getLiveRoomInfoByUids(uids)), 3).catch(async () => {
1286
+ const { data } = await (0, utils_1.withRetry)(async () => (await this.ctx.ba.getLiveRoomInfoByUids(uids)), 3).catch(async () => {
1311
1287
  // 返回undefined
1312
1288
  return undefined;
1313
1289
  });
@@ -1334,7 +1310,7 @@ class ComRegister {
1334
1310
  // 将直播状态改为true
1335
1311
  liveStatus.live = true;
1336
1312
  // 初始化主播和直播间信息
1337
- await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast, liveStatus);
1313
+ await useMasterAndLiveRoomInfo(type_1.LiveType.FirstLiveBroadcast, liveStatus);
1338
1314
  // 判断是否需要设置开播时间
1339
1315
  if (!liveStatus.liveStartTimeInit) {
1340
1316
  // 设置开播时间
@@ -1352,7 +1328,7 @@ class ComRegister {
1352
1328
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1353
1329
  : null;
1354
1330
  // 发送直播通知卡片
1355
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1331
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, "API", {
1356
1332
  liveRoomInfo: liveStatus.liveRoomInfo,
1357
1333
  masterInfo: liveStatus.masterInfo,
1358
1334
  cardStyle: sub.card,
@@ -1382,7 +1358,7 @@ class ComRegister {
1382
1358
  if (liveStatus.live === true) {
1383
1359
  // 现在下播了,发送下播通知
1384
1360
  // 判断信息是否获取成功
1385
- if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, liveStatus))) {
1361
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast, liveStatus))) {
1386
1362
  // 未获取成功,直接返回
1387
1363
  await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1388
1364
  // 停止服务
@@ -1420,7 +1396,7 @@ class ComRegister {
1420
1396
  .replace("\\n", "\n")
1421
1397
  : null;
1422
1398
  // 推送通知卡片
1423
- await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1399
+ await this.sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, {
1424
1400
  liveRoomInfo: liveStatus.liveRoomInfo,
1425
1401
  masterInfo: liveStatus.masterInfo,
1426
1402
  cardStyle: sub.card,
@@ -1436,7 +1412,7 @@ class ComRegister {
1436
1412
  if (liveStatus.live === false) {
1437
1413
  // 开播了
1438
1414
  // 判断信息是否获取成功
1439
- if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, liveStatus))) {
1415
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast, liveStatus))) {
1440
1416
  // 未获取成功,直接返回
1441
1417
  await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
1442
1418
  // 停止服务
@@ -1460,7 +1436,7 @@ class ComRegister {
1460
1436
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1461
1437
  : null;
1462
1438
  // 推送开播通知
1463
- await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1439
+ await this.sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, {
1464
1440
  liveRoomInfo: liveStatus.liveRoomInfo,
1465
1441
  masterInfo: liveStatus.masterInfo,
1466
1442
  cardStyle: sub.card,
@@ -1477,7 +1453,7 @@ class ComRegister {
1477
1453
  break;
1478
1454
  }
1479
1455
  // 判断是否信息是否获取成功
1480
- if (!(await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast, liveStatus))) {
1456
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.LiveBroadcast, liveStatus))) {
1481
1457
  // 未获取成功,直接返回
1482
1458
  await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
1483
1459
  // 停止服务
@@ -1500,7 +1476,7 @@ class ComRegister {
1500
1476
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1501
1477
  : null;
1502
1478
  // 发送直播通知卡片
1503
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1479
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, "API", {
1504
1480
  liveRoomInfo: liveStatus.liveRoomInfo,
1505
1481
  masterInfo: liveStatus.masterInfo,
1506
1482
  cardStyle: sub.card,
@@ -1517,7 +1493,7 @@ class ComRegister {
1517
1493
  }
1518
1494
  };
1519
1495
  // 返回一个闭包函数
1520
- return withLock(handler);
1496
+ return (0, utils_1.withLock)(handler);
1521
1497
  }
1522
1498
  subShow() {
1523
1499
  // 在控制台中显示订阅对象
@@ -1543,9 +1519,9 @@ class ComRegister {
1543
1519
  const subTableArray = subInfo.split("\n");
1544
1520
  subTableArray.splice(subTableArray.length - 1, 1);
1545
1521
  // 定义Table
1546
- table = (_jsxs(_Fragment, { children: [_jsx("p", { children: "\u5F53\u524D\u8BA2\u9605\u5BF9\u8C61\uFF1A" }), _jsx("ul", { children: subTableArray.map((str) => (
1522
+ table = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { children: "\u5F53\u524D\u8BA2\u9605\u5BF9\u8C61\uFF1A" }), (0, jsx_runtime_1.jsx)("ul", { children: subTableArray.map((str) => (
1547
1523
  // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
1548
- _jsx("li", { children: str }))) })] }));
1524
+ (0, jsx_runtime_1.jsx)("li", { children: str }))) })] }));
1549
1525
  }
1550
1526
  // 设置更新后的提示
1551
1527
  this.subNotifier = this.ctx.notifier.create(table);
@@ -1735,7 +1711,7 @@ class ComRegister {
1735
1711
  // logger
1736
1712
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1737
1713
  // 定义Data
1738
- const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await withRetry(async () => {
1714
+ const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await (0, utils_1.withRetry)(async () => {
1739
1715
  // 获取用户信息
1740
1716
  const data = await this.ctx.ba.getUserInfo(sub.uid);
1741
1717
  // 返回用户信息
@@ -1812,7 +1788,7 @@ class ComRegister {
1812
1788
  }
1813
1789
  enableDynamicDetect() {
1814
1790
  // 定义Job
1815
- this.dynamicJob = new CronJob("*/2 * * * *", this.config.dynamicDebugMode
1791
+ this.dynamicJob = new cron_1.CronJob("*/2 * * * *", this.config.dynamicDebugMode
1816
1792
  ? this.debug_dynamicDetect()
1817
1793
  : this.dynamicDetect());
1818
1794
  // logger
@@ -1822,7 +1798,7 @@ class ComRegister {
1822
1798
  }
1823
1799
  async enableLiveDetect() {
1824
1800
  // 定义Job
1825
- this.liveJob = new CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
1801
+ this.liveJob = new cron_1.CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
1826
1802
  // logger
1827
1803
  this.logger.info("直播监测已开启");
1828
1804
  // 开始直播监测
@@ -1841,54 +1817,54 @@ class ComRegister {
1841
1817
  }
1842
1818
  }
1843
1819
  (function (ComRegister) {
1844
- ComRegister.Config = Schema.object({
1845
- sub: Schema.array(Schema.object({
1846
- uid: Schema.string().description("订阅用户UID"),
1847
- dynamic: Schema.boolean().description("是否订阅用户动态"),
1848
- live: Schema.boolean().description("是否订阅用户直播"),
1849
- target: Schema.array(Schema.object({
1850
- channelArr: Schema.array(Schema.object({
1851
- channelId: Schema.string().description("频道/群组号"),
1852
- dynamic: Schema.boolean().description("该频道/群组是否推送动态信息"),
1853
- live: Schema.boolean().description("该频道/群组是否推送直播通知"),
1854
- liveGuardBuy: Schema.boolean().description("该频道/群组是否推送弹幕消息"),
1855
- atAll: Schema.boolean().description("推送开播通知时是否艾特全体成员"),
1856
- bot: Schema.string().description("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个"),
1820
+ ComRegister.Config = koishi_1.Schema.object({
1821
+ sub: koishi_1.Schema.array(koishi_1.Schema.object({
1822
+ uid: koishi_1.Schema.string().description("订阅用户UID"),
1823
+ dynamic: koishi_1.Schema.boolean().description("是否订阅用户动态"),
1824
+ live: koishi_1.Schema.boolean().description("是否订阅用户直播"),
1825
+ target: koishi_1.Schema.array(koishi_1.Schema.object({
1826
+ channelArr: koishi_1.Schema.array(koishi_1.Schema.object({
1827
+ channelId: koishi_1.Schema.string().description("频道/群组号"),
1828
+ dynamic: koishi_1.Schema.boolean().description("该频道/群组是否推送动态信息"),
1829
+ live: koishi_1.Schema.boolean().description("该频道/群组是否推送直播通知"),
1830
+ liveGuardBuy: koishi_1.Schema.boolean().description("该频道/群组是否推送弹幕消息"),
1831
+ atAll: koishi_1.Schema.boolean().description("推送开播通知时是否艾特全体成员"),
1832
+ bot: koishi_1.Schema.string().description("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个"),
1857
1833
  })).description("频道/群组信息"),
1858
- platform: Schema.string().description("推送平台"),
1834
+ platform: koishi_1.Schema.string().description("推送平台"),
1859
1835
  })).description("订阅用户需要发送的频道/群组信息"),
1860
- card: Schema.object({
1861
- enable: Schema.boolean(),
1862
- cardColorStart: Schema.string(),
1863
- cardColorEnd: Schema.string(),
1864
- cardBasePlateColor: Schema.string(),
1865
- cardBasePlateBorder: Schema.string(),
1836
+ card: koishi_1.Schema.object({
1837
+ enable: koishi_1.Schema.boolean(),
1838
+ cardColorStart: koishi_1.Schema.string(),
1839
+ cardColorEnd: koishi_1.Schema.string(),
1840
+ cardBasePlateColor: koishi_1.Schema.string(),
1841
+ cardBasePlateBorder: koishi_1.Schema.string(),
1866
1842
  }).description("自定义推送卡片颜色,默认使用插件内置的颜色,设置后会覆盖插件内置的颜色"),
1867
1843
  }))
1868
1844
  .role("table")
1869
1845
  .description("手动输入订阅信息,方便自定义订阅内容,这里的订阅内容不会存入数据库。uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
1870
- master: Schema.object({
1871
- enable: Schema.boolean(),
1872
- platform: Schema.string(),
1873
- masterAccount: Schema.string(),
1874
- masterAccountGuildId: Schema.string(),
1846
+ master: koishi_1.Schema.object({
1847
+ enable: koishi_1.Schema.boolean(),
1848
+ platform: koishi_1.Schema.string(),
1849
+ masterAccount: koishi_1.Schema.string(),
1850
+ masterAccountGuildId: koishi_1.Schema.string(),
1875
1851
  }),
1876
- liveDetectType: Schema.string(),
1877
- restartPush: Schema.boolean().required(),
1878
- pushTime: Schema.number().required(),
1879
- pushImgsInDynamic: Schema.boolean().required(),
1880
- liveLoopTime: Schema.number().default(10),
1881
- customLiveStart: Schema.string().required(),
1882
- customLive: Schema.string(),
1883
- customLiveEnd: Schema.string().required(),
1884
- dynamicUrl: Schema.boolean().required(),
1885
- filter: Schema.object({
1886
- enable: Schema.boolean(),
1887
- notify: Schema.boolean(),
1888
- regex: Schema.string(),
1889
- keywords: Schema.array(String),
1852
+ liveDetectType: koishi_1.Schema.string(),
1853
+ restartPush: koishi_1.Schema.boolean().required(),
1854
+ pushTime: koishi_1.Schema.number().required(),
1855
+ pushImgsInDynamic: koishi_1.Schema.boolean().required(),
1856
+ liveLoopTime: koishi_1.Schema.number().default(10),
1857
+ customLiveStart: koishi_1.Schema.string().required(),
1858
+ customLive: koishi_1.Schema.string(),
1859
+ customLiveEnd: koishi_1.Schema.string().required(),
1860
+ dynamicUrl: koishi_1.Schema.boolean().required(),
1861
+ filter: koishi_1.Schema.object({
1862
+ enable: koishi_1.Schema.boolean(),
1863
+ notify: koishi_1.Schema.boolean(),
1864
+ regex: koishi_1.Schema.string(),
1865
+ keywords: koishi_1.Schema.array(String),
1890
1866
  }),
1891
- dynamicDebugMode: Schema.boolean().required(),
1867
+ dynamicDebugMode: koishi_1.Schema.boolean().required(),
1892
1868
  });
1893
1869
  })(ComRegister || (ComRegister = {}));
1894
- export default ComRegister;
1870
+ exports.default = ComRegister;