koishi-plugin-bilibili-notify 3.2.1-alpha.1 → 3.2.1-alpha.2

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
  // 定义开播时间
@@ -1021,7 +1026,7 @@ class ComRegister {
1021
1026
  // 定义定时推送函数
1022
1027
  const pushAtTimeFunc = async () => {
1023
1028
  // 判断是否信息是否获取成功
1024
- if (!(await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast))) {
1029
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.LiveBroadcast))) {
1025
1030
  // 未获取成功,直接返回
1026
1031
  await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
1027
1032
  // 停止服务
@@ -1052,7 +1057,7 @@ class ComRegister {
1052
1057
  .replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`)
1053
1058
  : null;
1054
1059
  // 发送直播通知卡片
1055
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1060
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, watched, {
1056
1061
  liveRoomInfo,
1057
1062
  masterInfo,
1058
1063
  cardStyle,
@@ -1130,7 +1135,7 @@ class ComRegister {
1130
1135
  const content = `[${masterInfo.username}的直播间]「${body.user.uname}」加入了大航海(${body.gift_name})`;
1131
1136
  // 直接发送消息
1132
1137
  channelArrLen > 0 &&
1133
- this.broadcastToTargets(liveGuardBuyPushTargetArr, content, PushType.LiveGuardBuy);
1138
+ this.broadcastToTargets(liveGuardBuyPushTargetArr, content, type_1.PushType.LiveGuardBuy);
1134
1139
  },
1135
1140
  onLiveStart: async () => {
1136
1141
  // 判断是否已经开播
@@ -1139,7 +1144,7 @@ class ComRegister {
1139
1144
  // 设置开播状态为true
1140
1145
  liveStatus = true;
1141
1146
  // 判断是否信息是否获取成功
1142
- if (!(await useMasterAndLiveRoomInfo(LiveType.StartBroadcasting))) {
1147
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StartBroadcasting))) {
1143
1148
  // 设置开播状态为false
1144
1149
  liveStatus = false;
1145
1150
  // 未获取成功,直接返回
@@ -1163,7 +1168,7 @@ class ComRegister {
1163
1168
  .replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`)
1164
1169
  : null;
1165
1170
  // 推送开播通知
1166
- await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1171
+ await this.sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, {
1167
1172
  liveRoomInfo,
1168
1173
  masterInfo,
1169
1174
  cardStyle,
@@ -1178,7 +1183,7 @@ class ComRegister {
1178
1183
  // 将直播状态设置为false
1179
1184
  liveStatus = false;
1180
1185
  // 判断是否信息是否获取成功
1181
- if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast))) {
1186
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast))) {
1182
1187
  // 未获取成功,直接返回
1183
1188
  await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1184
1189
  // 停止服务
@@ -1211,7 +1216,7 @@ class ComRegister {
1211
1216
  .replace("\\n", "\n")
1212
1217
  : null;
1213
1218
  // 推送通知卡片
1214
- await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1219
+ await this.sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, {
1215
1220
  liveRoomInfo,
1216
1221
  masterInfo,
1217
1222
  cardStyle,
@@ -1225,7 +1230,7 @@ class ComRegister {
1225
1230
  // 启动直播间弹幕监测
1226
1231
  await this.ctx.bl.startLiveRoomListener(roomId, handler);
1227
1232
  // 第一次启动获取信息并判信息是否获取成功
1228
- if (!(await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast))) {
1233
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.FirstLiveBroadcast))) {
1229
1234
  // 未获取成功,直接返回
1230
1235
  return this.sendPrivateMsg("获取直播间信息失败,启动直播间弹幕检测失败!");
1231
1236
  }
@@ -1246,7 +1251,7 @@ class ComRegister {
1246
1251
  : null;
1247
1252
  // 发送直播通知卡片
1248
1253
  if (this.config.restartPush) {
1249
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1254
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, watched, {
1250
1255
  liveRoomInfo,
1251
1256
  masterInfo,
1252
1257
  cardStyle,
@@ -1296,7 +1301,7 @@ class ComRegister {
1296
1301
  }
1297
1302
  const useLiveInfo = async () => {
1298
1303
  // 发送请求
1299
- const { data } = await withRetry(async () => (await this.ctx.ba.getLiveRoomInfoByUids(uids)), 3).catch(async () => {
1304
+ const { data } = await (0, utils_1.withRetry)(async () => (await this.ctx.ba.getLiveRoomInfoByUids(uids)), 3).catch(async () => {
1300
1305
  // 返回undefined
1301
1306
  return undefined;
1302
1307
  });
@@ -1323,7 +1328,7 @@ class ComRegister {
1323
1328
  // 将直播状态改为true
1324
1329
  liveStatus.live = true;
1325
1330
  // 初始化主播和直播间信息
1326
- await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast, liveStatus);
1331
+ await useMasterAndLiveRoomInfo(type_1.LiveType.FirstLiveBroadcast, liveStatus);
1327
1332
  // 判断是否需要设置开播时间
1328
1333
  if (!liveStatus.liveStartTimeInit) {
1329
1334
  // 设置开播时间
@@ -1341,7 +1346,7 @@ class ComRegister {
1341
1346
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1342
1347
  : null;
1343
1348
  // 发送直播通知卡片
1344
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1349
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, "API", {
1345
1350
  liveRoomInfo: liveStatus.liveRoomInfo,
1346
1351
  masterInfo: liveStatus.masterInfo,
1347
1352
  cardStyle: sub.card,
@@ -1371,7 +1376,7 @@ class ComRegister {
1371
1376
  if (liveStatus.live === true) {
1372
1377
  // 现在下播了,发送下播通知
1373
1378
  // 判断信息是否获取成功
1374
- if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, liveStatus))) {
1379
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast, liveStatus))) {
1375
1380
  // 未获取成功,直接返回
1376
1381
  await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1377
1382
  // 停止服务
@@ -1409,7 +1414,7 @@ class ComRegister {
1409
1414
  .replace("\\n", "\n")
1410
1415
  : null;
1411
1416
  // 推送通知卡片
1412
- await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1417
+ await this.sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, {
1413
1418
  liveRoomInfo: liveStatus.liveRoomInfo,
1414
1419
  masterInfo: liveStatus.masterInfo,
1415
1420
  cardStyle: sub.card,
@@ -1425,7 +1430,7 @@ class ComRegister {
1425
1430
  if (liveStatus.live === false) {
1426
1431
  // 开播了
1427
1432
  // 判断信息是否获取成功
1428
- if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, liveStatus))) {
1433
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast, liveStatus))) {
1429
1434
  // 未获取成功,直接返回
1430
1435
  await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
1431
1436
  // 停止服务
@@ -1449,7 +1454,7 @@ class ComRegister {
1449
1454
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1450
1455
  : null;
1451
1456
  // 推送开播通知
1452
- await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1457
+ await this.sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, {
1453
1458
  liveRoomInfo: liveStatus.liveRoomInfo,
1454
1459
  masterInfo: liveStatus.masterInfo,
1455
1460
  cardStyle: sub.card,
@@ -1466,7 +1471,7 @@ class ComRegister {
1466
1471
  break;
1467
1472
  }
1468
1473
  // 判断是否信息是否获取成功
1469
- if (!(await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast, liveStatus))) {
1474
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.LiveBroadcast, liveStatus))) {
1470
1475
  // 未获取成功,直接返回
1471
1476
  await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
1472
1477
  // 停止服务
@@ -1489,7 +1494,7 @@ class ComRegister {
1489
1494
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1490
1495
  : null;
1491
1496
  // 发送直播通知卡片
1492
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1497
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, "API", {
1493
1498
  liveRoomInfo: liveStatus.liveRoomInfo,
1494
1499
  masterInfo: liveStatus.masterInfo,
1495
1500
  cardStyle: sub.card,
@@ -1506,7 +1511,7 @@ class ComRegister {
1506
1511
  }
1507
1512
  };
1508
1513
  // 返回一个闭包函数
1509
- return withLock(handler);
1514
+ return (0, utils_1.withLock)(handler);
1510
1515
  }
1511
1516
  subShow() {
1512
1517
  // 在控制台中显示订阅对象
@@ -1532,9 +1537,9 @@ class ComRegister {
1532
1537
  const subTableArray = subInfo.split("\n");
1533
1538
  subTableArray.splice(subTableArray.length - 1, 1);
1534
1539
  // 定义Table
1535
- table = (_jsxs(_Fragment, { children: [_jsx("p", { children: "\u5F53\u524D\u8BA2\u9605\u5BF9\u8C61\uFF1A" }), _jsx("ul", { children: subTableArray.map((str) => (
1540
+ 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) => (
1536
1541
  // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
1537
- _jsx("li", { children: str }))) })] }));
1542
+ (0, jsx_runtime_1.jsx)("li", { children: str }))) })] }));
1538
1543
  }
1539
1544
  // 设置更新后的提示
1540
1545
  this.subNotifier = this.ctx.notifier.create(table);
@@ -1724,7 +1729,7 @@ class ComRegister {
1724
1729
  // logger
1725
1730
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1726
1731
  // 定义Data
1727
- const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await withRetry(async () => {
1732
+ const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await (0, utils_1.withRetry)(async () => {
1728
1733
  // 获取用户信息
1729
1734
  const data = await this.ctx.ba.getUserInfo(sub.uid);
1730
1735
  // 返回用户信息
@@ -1801,7 +1806,7 @@ class ComRegister {
1801
1806
  }
1802
1807
  enableDynamicDetect() {
1803
1808
  // 定义Job
1804
- this.dynamicJob = new CronJob("*/2 * * * *", this.config.dynamicDebugMode
1809
+ this.dynamicJob = new cron_1.CronJob("*/2 * * * *", this.config.dynamicDebugMode
1805
1810
  ? this.debug_dynamicDetect()
1806
1811
  : this.dynamicDetect());
1807
1812
  // logger
@@ -1811,7 +1816,7 @@ class ComRegister {
1811
1816
  }
1812
1817
  async enableLiveDetect() {
1813
1818
  // 定义Job
1814
- this.liveJob = new CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
1819
+ this.liveJob = new cron_1.CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
1815
1820
  // logger
1816
1821
  this.logger.info("直播监测已开启");
1817
1822
  // 开始直播监测
@@ -1830,54 +1835,54 @@ class ComRegister {
1830
1835
  }
1831
1836
  }
1832
1837
  (function (ComRegister) {
1833
- ComRegister.Config = Schema.object({
1834
- sub: Schema.array(Schema.object({
1835
- uid: Schema.string().description("订阅用户UID"),
1836
- dynamic: Schema.boolean().description("是否订阅用户动态"),
1837
- live: Schema.boolean().description("是否订阅用户直播"),
1838
- target: Schema.array(Schema.object({
1839
- channelArr: Schema.array(Schema.object({
1840
- channelId: Schema.string().description("频道/群组号"),
1841
- dynamic: Schema.boolean().description("该频道/群组是否推送动态信息"),
1842
- live: Schema.boolean().description("该频道/群组是否推送直播通知"),
1843
- liveGuardBuy: Schema.boolean().description("该频道/群组是否推送弹幕消息"),
1844
- atAll: Schema.boolean().description("推送开播通知时是否艾特全体成员"),
1845
- bot: Schema.string().description("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个"),
1838
+ ComRegister.Config = koishi_1.Schema.object({
1839
+ sub: koishi_1.Schema.array(koishi_1.Schema.object({
1840
+ uid: koishi_1.Schema.string().description("订阅用户UID"),
1841
+ dynamic: koishi_1.Schema.boolean().description("是否订阅用户动态"),
1842
+ live: koishi_1.Schema.boolean().description("是否订阅用户直播"),
1843
+ target: koishi_1.Schema.array(koishi_1.Schema.object({
1844
+ channelArr: koishi_1.Schema.array(koishi_1.Schema.object({
1845
+ channelId: koishi_1.Schema.string().description("频道/群组号"),
1846
+ dynamic: koishi_1.Schema.boolean().description("该频道/群组是否推送动态信息"),
1847
+ live: koishi_1.Schema.boolean().description("该频道/群组是否推送直播通知"),
1848
+ liveGuardBuy: koishi_1.Schema.boolean().description("该频道/群组是否推送弹幕消息"),
1849
+ atAll: koishi_1.Schema.boolean().description("推送开播通知时是否艾特全体成员"),
1850
+ bot: koishi_1.Schema.string().description("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个"),
1846
1851
  })).description("频道/群组信息"),
1847
- platform: Schema.string().description("推送平台"),
1852
+ platform: koishi_1.Schema.string().description("推送平台"),
1848
1853
  })).description("订阅用户需要发送的频道/群组信息"),
1849
- card: Schema.object({
1850
- enable: Schema.boolean(),
1851
- cardColorStart: Schema.string(),
1852
- cardColorEnd: Schema.string(),
1853
- cardBasePlateColor: Schema.string(),
1854
- cardBasePlateBorder: Schema.string(),
1854
+ card: koishi_1.Schema.object({
1855
+ enable: koishi_1.Schema.boolean(),
1856
+ cardColorStart: koishi_1.Schema.string(),
1857
+ cardColorEnd: koishi_1.Schema.string(),
1858
+ cardBasePlateColor: koishi_1.Schema.string(),
1859
+ cardBasePlateBorder: koishi_1.Schema.string(),
1855
1860
  }).description("自定义推送卡片颜色,默认使用插件内置的颜色,设置后会覆盖插件内置的颜色"),
1856
1861
  }))
1857
1862
  .role("table")
1858
1863
  .description("手动输入订阅信息,方便自定义订阅内容,这里的订阅内容不会存入数据库。uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
1859
- master: Schema.object({
1860
- enable: Schema.boolean(),
1861
- platform: Schema.string(),
1862
- masterAccount: Schema.string(),
1863
- masterAccountGuildId: Schema.string(),
1864
+ master: koishi_1.Schema.object({
1865
+ enable: koishi_1.Schema.boolean(),
1866
+ platform: koishi_1.Schema.string(),
1867
+ masterAccount: koishi_1.Schema.string(),
1868
+ masterAccountGuildId: koishi_1.Schema.string(),
1864
1869
  }),
1865
- liveDetectType: Schema.string(),
1866
- restartPush: Schema.boolean().required(),
1867
- pushTime: Schema.number().required(),
1868
- pushImgsInDynamic: Schema.boolean().required(),
1869
- liveLoopTime: Schema.number().default(10),
1870
- customLiveStart: Schema.string().required(),
1871
- customLive: Schema.string(),
1872
- customLiveEnd: Schema.string().required(),
1873
- dynamicUrl: Schema.boolean().required(),
1874
- filter: Schema.object({
1875
- enable: Schema.boolean(),
1876
- notify: Schema.boolean(),
1877
- regex: Schema.string(),
1878
- keywords: Schema.array(String),
1870
+ liveDetectType: koishi_1.Schema.string(),
1871
+ restartPush: koishi_1.Schema.boolean().required(),
1872
+ pushTime: koishi_1.Schema.number().required(),
1873
+ pushImgsInDynamic: koishi_1.Schema.boolean().required(),
1874
+ liveLoopTime: koishi_1.Schema.number().default(10),
1875
+ customLiveStart: koishi_1.Schema.string().required(),
1876
+ customLive: koishi_1.Schema.string(),
1877
+ customLiveEnd: koishi_1.Schema.string().required(),
1878
+ dynamicUrl: koishi_1.Schema.boolean().required(),
1879
+ filter: koishi_1.Schema.object({
1880
+ enable: koishi_1.Schema.boolean(),
1881
+ notify: koishi_1.Schema.boolean(),
1882
+ regex: koishi_1.Schema.string(),
1883
+ keywords: koishi_1.Schema.array(String),
1879
1884
  }),
1880
- dynamicDebugMode: Schema.boolean().required(),
1885
+ dynamicDebugMode: koishi_1.Schema.boolean().required(),
1881
1886
  });
1882
1887
  })(ComRegister || (ComRegister = {}));
1883
- export default ComRegister;
1888
+ exports.default = ComRegister;