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

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,18 +1,13 @@
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");
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@satorijs/element/jsx-runtime";
7
2
  // Koishi核心依赖
8
- const koishi_1 = require("koishi");
9
- const qrcode_1 = __importDefault(require("qrcode"));
10
- const cron_1 = require("cron");
3
+ import { Schema, h, } from "koishi";
4
+ import QRCode from "qrcode";
5
+ import { CronJob } from "cron";
11
6
  // Utils
12
- const utils_1 = require("./utils");
7
+ import { withLock, withRetry } from "./utils";
13
8
  // Types
14
- const type_1 = require("./type");
15
- const luxon_1 = require("luxon");
9
+ import { LiveType, PushType, } from "./type";
10
+ import { DateTime } from "luxon";
16
11
  class ComRegister {
17
12
  // 必须服务
18
13
  static inject = ["ba", "gi", "database", "bl", "sm"];
@@ -123,7 +118,7 @@ class ComRegister {
123
118
  if (content.code !== 0)
124
119
  return await session.send("出问题咯,请联系管理员解决");
125
120
  // 生成二维码
126
- qrcode_1.default.toBuffer(content.data.url, {
121
+ QRCode.toBuffer(content.data.url, {
127
122
  errorCorrectionLevel: "H", // 错误更正水平
128
123
  type: "png", // 输出类型
129
124
  margin: 1, // 边距大小
@@ -134,7 +129,7 @@ class ComRegister {
134
129
  }, async (err, buffer) => {
135
130
  if (err)
136
131
  return await session.send("二维码生成出错,请重新尝试");
137
- await session.send(koishi_1.h.image(buffer, "image/jpeg"));
132
+ await session.send(h.image(buffer, "image/jpeg"));
138
133
  });
139
134
  // 检查之前是否存在登录定时器
140
135
  if (this.loginTimer)
@@ -272,7 +267,7 @@ class ComRegister {
272
267
  // 获取动态内容
273
268
  const item = content.data.items[i];
274
269
  // 生成图片
275
- const buffer = await (0, utils_1.withRetry)(async () => {
270
+ const buffer = await withRetry(async () => {
276
271
  // 渲染图片
277
272
  return await this.ctx.gi.generateDynamicImg(item);
278
273
  }, 1).catch(async (e) => {
@@ -297,7 +292,7 @@ class ComRegister {
297
292
  this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
298
293
  });
299
294
  // 发送图片
300
- buffer && (await session.send(koishi_1.h.image(buffer, "image/jpeg")));
295
+ buffer && (await session.send(h.image(buffer, "image/jpeg")));
301
296
  });
302
297
  }
303
298
  async init(config) {
@@ -362,7 +357,7 @@ class ComRegister {
362
357
  initManager() {
363
358
  for (const sub of this.subManager) {
364
359
  if (sub.dynamic) {
365
- this.dynamicTimelineManager.set(sub.uid, Math.floor(luxon_1.DateTime.now().toSeconds()));
360
+ this.dynamicTimelineManager.set(sub.uid, Math.floor(DateTime.now().toSeconds()));
366
361
  }
367
362
  if (sub.live) {
368
363
  this.liveStatusManager.set(sub.uid, {
@@ -444,7 +439,7 @@ class ComRegister {
444
439
  async sendMessageWithRetry(bot, channelId,
445
440
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
446
441
  content) {
447
- (0, utils_1.withRetry)(async () => await bot.sendMessage(channelId, content), 1).catch(async (e) => {
442
+ withRetry(async () => await bot.sendMessage(channelId, content), 1).catch(async (e) => {
448
443
  if (e.message === "this._request is not a function") {
449
444
  // 2S之后重新发送消息
450
445
  this.ctx.setTimeout(async () => {
@@ -462,7 +457,7 @@ class ComRegister {
462
457
  // 定义数组
463
458
  const pushArr = [];
464
459
  // 判断类型
465
- if (type === type_1.PushType.Live || type === type_1.PushType.StartBroadcasting) {
460
+ if (type === PushType.Live || type === PushType.StartBroadcasting) {
466
461
  for (const target of targets) {
467
462
  for (const channel of target.channelArr) {
468
463
  if (channel.live) {
@@ -472,7 +467,7 @@ class ComRegister {
472
467
  }
473
468
  return pushArr;
474
469
  }
475
- if (type === type_1.PushType.Dynamic) {
470
+ if (type === PushType.Dynamic) {
476
471
  for (const target of targets) {
477
472
  for (const channel of target.channelArr) {
478
473
  if (channel.dynamic) {
@@ -482,7 +477,7 @@ class ComRegister {
482
477
  }
483
478
  return pushArr;
484
479
  }
485
- if (type === type_1.PushType.LiveGuardBuy) {
480
+ if (type === PushType.LiveGuardBuy) {
486
481
  for (const target of targets) {
487
482
  for (const channel of target.channelArr) {
488
483
  if (channel.liveGuardBuy) {
@@ -502,7 +497,7 @@ class ComRegister {
502
497
  // logger
503
498
  this.logger.info(`推送消息到 ${pushArr.length} 个目标频道,目标频道为:${pushArr.join(", ")}`);
504
499
  // 推送消息
505
- await (0, utils_1.withRetry)(async () => {
500
+ await withRetry(async () => {
506
501
  await this.ctx.broadcast(pushArr, content);
507
502
  }, 1);
508
503
  // 结束
@@ -523,28 +518,28 @@ class ComRegister {
523
518
  }
524
519
  // 模式匹配
525
520
  const pushTypePatternMatching = {
526
- [type_1.PushType.Live]: async () => {
521
+ [PushType.Live]: async () => {
527
522
  if (targetChannel.live) {
528
523
  // 直接推送
529
524
  await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
530
525
  }
531
526
  },
532
- [type_1.PushType.Dynamic]: async () => {
527
+ [PushType.Dynamic]: async () => {
533
528
  if (targetChannel.dynamic) {
534
529
  await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
535
530
  }
536
531
  },
537
- [type_1.PushType.StartBroadcasting]: async () => {
532
+ [PushType.StartBroadcasting]: async () => {
538
533
  // 判断是否需要推送直播消息
539
534
  if (targetChannel.live) {
540
535
  await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
541
536
  }
542
537
  // 判断是否需要艾特全体成员
543
538
  if (targetChannel.atAll) {
544
- await this.sendMessageWithRetry(bot, targetChannel.channelId, (0, jsx_runtime_1.jsx)("at", { type: "all" }));
539
+ await this.sendMessageWithRetry(bot, targetChannel.channelId, _jsx("at", { type: "all" }));
545
540
  }
546
541
  },
547
- [type_1.PushType.LiveGuardBuy]: async () => {
542
+ [PushType.LiveGuardBuy]: async () => {
548
543
  // 判断是否需要推送直播消息
549
544
  if (targetChannel.liveGuardBuy) {
550
545
  await this.sendMessageWithRetry(bot, targetChannel.channelId, content);
@@ -560,7 +555,7 @@ class ComRegister {
560
555
  // 定义本次请求推送的动态
561
556
  const currentPushDyn = {};
562
557
  // 使用withRetry函数进行重试
563
- const content = await (0, utils_1.withRetry)(async () => {
558
+ const content = await withRetry(async () => {
564
559
  // 获取动态内容
565
560
  return (await this.ctx.ba.getAllDynamic());
566
561
  }, 1).catch((e) => {
@@ -634,7 +629,7 @@ class ComRegister {
634
629
  // 获取订阅对象
635
630
  const sub = this.subManager.find((sub) => sub.uid === uid);
636
631
  // 推送该条动态
637
- const buffer = await (0, utils_1.withRetry)(async () => {
632
+ const buffer = await withRetry(async () => {
638
633
  // 渲染图片
639
634
  return await this.ctx.gi.generateDynamicImg(item, sub.card.enable ? sub.card : undefined);
640
635
  }, 1).catch(async (e) => {
@@ -644,19 +639,19 @@ class ComRegister {
644
639
  if (e.message === "出现关键词,屏蔽该动态") {
645
640
  // 如果需要发送才发送
646
641
  if (this.config.filter.notify) {
647
- await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
642
+ await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, PushType.Dynamic);
648
643
  }
649
644
  return;
650
645
  }
651
646
  if (e.message === "已屏蔽转发动态") {
652
647
  if (this.config.filter.notify) {
653
- await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
648
+ await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, PushType.Dynamic);
654
649
  }
655
650
  return;
656
651
  }
657
652
  if (e.message === "已屏蔽专栏动态") {
658
653
  if (this.config.filter.notify) {
659
- await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, type_1.PushType.Dynamic);
654
+ await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, PushType.Dynamic);
660
655
  }
661
656
  return;
662
657
  }
@@ -683,7 +678,7 @@ class ComRegister {
683
678
  // logger
684
679
  this.logger.info("推送动态中...");
685
680
  // 发送推送卡片
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);
681
+ await this.broadcastToTargets(sub.target, _jsxs(_Fragment, { children: [h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
687
682
  // 判断是否需要发送动态中的图片
688
683
  if (this.config.pushImgsInDynamic) {
689
684
  // 判断是否为图文动态
@@ -693,7 +688,7 @@ class ComRegister {
693
688
  // 判断pics是否存在
694
689
  if (pics) {
695
690
  for (const pic of pics) {
696
- await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
691
+ await this.broadcastToTargets(sub.target, _jsx("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }), PushType.Dynamic);
697
692
  // 随机睡眠1-3秒
698
693
  await this.ctx.sleep(Math.floor(Math.random() * 2000) + 1000);
699
694
  }
@@ -719,7 +714,7 @@ class ComRegister {
719
714
  }
720
715
  };
721
716
  // 返回一个闭包函数
722
- return (0, utils_1.withLock)(handler);
717
+ return withLock(handler);
723
718
  }
724
719
  debug_dynamicDetect() {
725
720
  // 定义handler
@@ -729,7 +724,7 @@ class ComRegister {
729
724
  // logger
730
725
  this.logger.info("开始获取动态信息...");
731
726
  // 使用withRetry函数进行重试
732
- const content = await (0, utils_1.withRetry)(async () => {
727
+ const content = await withRetry(async () => {
733
728
  // 获取动态内容
734
729
  return (await this.ctx.ba.getAllDynamic());
735
730
  }, 1).catch((e) => {
@@ -798,7 +793,7 @@ class ComRegister {
798
793
  const uid = item.modules.module_author.mid.toString();
799
794
  const name = item.modules.module_author.name;
800
795
  // logger
801
- this.logger.info(`获取到动态信息,UP主:${name},UID:${uid},动态发布时间:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
796
+ this.logger.info(`获取到动态信息,UP主:${name},UID:${uid},动态发布时间:${DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
802
797
  // 判断是否存在时间线
803
798
  if (this.dynamicTimelineManager.has(uid)) {
804
799
  // logger
@@ -806,7 +801,7 @@ class ComRegister {
806
801
  // 寻找关注的UP主
807
802
  const timeline = this.dynamicTimelineManager.get(uid);
808
803
  // logger
809
- this.logger.info(`上次推送时间线:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
804
+ this.logger.info(`上次推送时间线:${DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
810
805
  // 判断动态发布时间是否大于时间线
811
806
  if (timeline < postTime) {
812
807
  // logger
@@ -816,7 +811,7 @@ class ComRegister {
816
811
  // logger
817
812
  this.logger.info("开始渲染推送卡片...");
818
813
  // 推送该条动态
819
- const buffer = await (0, utils_1.withRetry)(async () => {
814
+ const buffer = await withRetry(async () => {
820
815
  // 渲染图片
821
816
  return await this.ctx.gi.generateDynamicImg(item, sub.card.enable ? sub.card : undefined);
822
817
  }, 1).catch(async (e) => {
@@ -826,19 +821,19 @@ class ComRegister {
826
821
  if (e.message === "出现关键词,屏蔽该动态") {
827
822
  // 如果需要发送才发送
828
823
  if (this.config.filter.notify) {
829
- await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, type_1.PushType.Dynamic);
824
+ await this.broadcastToTargets(sub.target, `${name}发布了一条含有屏蔽关键字的动态`, PushType.Dynamic);
830
825
  }
831
826
  return;
832
827
  }
833
828
  if (e.message === "已屏蔽转发动态") {
834
829
  if (this.config.filter.notify) {
835
- await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, type_1.PushType.Dynamic);
830
+ await this.broadcastToTargets(sub.target, `${name}转发了一条动态,已屏蔽`, PushType.Dynamic);
836
831
  }
837
832
  return;
838
833
  }
839
834
  if (e.message === "已屏蔽专栏动态") {
840
835
  if (this.config.filter.notify) {
841
- await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, type_1.PushType.Dynamic);
836
+ await this.broadcastToTargets(sub.target, `${name}投稿了一条专栏,已屏蔽`, PushType.Dynamic);
842
837
  }
843
838
  return;
844
839
  }
@@ -872,7 +867,7 @@ class ComRegister {
872
867
  // logger
873
868
  this.logger.info("推送动态中...");
874
869
  // 发送推送卡片
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);
870
+ await this.broadcastToTargets(sub.target, _jsxs(_Fragment, { children: [h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
876
871
  // 判断是否需要发送动态中的图片
877
872
  if (this.config.pushImgsInDynamic) {
878
873
  // logger
@@ -884,7 +879,7 @@ class ComRegister {
884
879
  // 判断pics是否存在
885
880
  if (pics) {
886
881
  for (const pic of pics) {
887
- await this.broadcastToTargets(sub.target, (0, jsx_runtime_1.jsx)("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }), type_1.PushType.Dynamic);
882
+ await this.broadcastToTargets(sub.target, _jsx("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }), PushType.Dynamic);
888
883
  // 随机睡眠1-3秒
889
884
  await this.ctx.sleep(Math.floor(Math.random() * 2000) + 1000);
890
885
  }
@@ -912,13 +907,13 @@ class ComRegister {
912
907
  // 更新当前时间线
913
908
  this.dynamicTimelineManager.set(uid, postTime);
914
909
  // logger
915
- this.logger.info(`更新时间线成功,UP主:${uid},时间线:${luxon_1.DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
910
+ this.logger.info(`更新时间线成功,UP主:${uid},时间线:${DateTime.fromSeconds(postTime).toFormat("yyyy-MM-dd HH:mm:ss")}`);
916
911
  }
917
912
  // logger
918
913
  this.logger.info(`本次推送动态数量:${Object.keys(currentPushDyn).length}`);
919
914
  };
920
915
  // 返回一个闭包函数
921
- return (0, utils_1.withLock)(handler);
916
+ return withLock(handler);
922
917
  }
923
918
  // 定义获取主播信息方法
924
919
  async useMasterInfo(uid, masterInfo, liveType) {
@@ -929,8 +924,8 @@ class ComRegister {
929
924
  let liveEndFollowerNum;
930
925
  let liveFollowerChange;
931
926
  // 判断直播状态
932
- if (liveType === type_1.LiveType.StartBroadcasting ||
933
- liveType === type_1.LiveType.FirstLiveBroadcast) {
927
+ if (liveType === LiveType.StartBroadcasting ||
928
+ liveType === LiveType.FirstLiveBroadcast) {
934
929
  // 第一次启动或刚开播
935
930
  // 将当前粉丝数赋值给liveOpenFollowerNum、liveEndFollowerNum
936
931
  liveOpenFollowerNum = data.follower_num;
@@ -938,8 +933,8 @@ class ComRegister {
938
933
  // 将粉丝数变化赋值为0
939
934
  liveFollowerChange = 0;
940
935
  }
941
- if (liveType === type_1.LiveType.StopBroadcast ||
942
- liveType === type_1.LiveType.LiveBroadcast) {
936
+ if (liveType === LiveType.StopBroadcast ||
937
+ liveType === LiveType.LiveBroadcast) {
943
938
  // 将上一次的liveOpenFollowerNum赋值给本次的liveOpenFollowerNum
944
939
  liveOpenFollowerNum = masterInfo.liveOpenFollowerNum;
945
940
  // 将当前粉丝数赋值给liveEndFollowerNum
@@ -959,7 +954,7 @@ class ComRegister {
959
954
  }
960
955
  async useLiveRoomInfo(roomId) {
961
956
  // 发送请求获取直播间信息
962
- const data = await (0, utils_1.withRetry)(async () => await this.ctx.ba.getLiveRoomInfo(roomId))
957
+ const data = await withRetry(async () => await this.ctx.ba.getLiveRoomInfo(roomId))
963
958
  .then((content) => content.data)
964
959
  .catch((e) => {
965
960
  this.logger.error(`liveDetect getLiveRoomInfo 发生了错误,错误为:${e.message}`);
@@ -974,7 +969,7 @@ class ComRegister {
974
969
  }
975
970
  async sendLiveNotifyCard(liveType, followerDisplay, liveInfo, target, liveNotifyMsg) {
976
971
  // 生成图片
977
- const buffer = await (0, utils_1.withRetry)(async () => {
972
+ const buffer = await withRetry(async () => {
978
973
  // 获取直播通知卡片
979
974
  return await this.ctx.gi.generateLiveImg(liveInfo.liveRoomInfo, liveInfo.masterInfo.username, liveInfo.masterInfo.userface, followerDisplay, liveType, liveInfo.cardStyle.enable ? liveInfo.cardStyle : undefined);
980
975
  }, 1).catch((e) => {
@@ -984,11 +979,11 @@ class ComRegister {
984
979
  if (!buffer)
985
980
  return await this.sendPrivateMsgAndStopService();
986
981
  // 推送直播信息
987
- const msg = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/jpeg"), liveNotifyMsg || ""] }));
982
+ const msg = (_jsxs(_Fragment, { children: [h.image(buffer, "image/jpeg"), liveNotifyMsg || ""] }));
988
983
  // 只有在开播时才艾特全体成员
989
- return await this.broadcastToTargets(target, msg, liveType === type_1.LiveType.StartBroadcasting
990
- ? type_1.PushType.StartBroadcasting
991
- : type_1.PushType.Live);
984
+ return await this.broadcastToTargets(target, msg, liveType === LiveType.StartBroadcasting
985
+ ? PushType.StartBroadcasting
986
+ : PushType.Live);
992
987
  }
993
988
  async liveDetectWithListener(roomId, target, cardStyle) {
994
989
  // 定义开播时间
@@ -1026,7 +1021,7 @@ class ComRegister {
1026
1021
  // 定义定时推送函数
1027
1022
  const pushAtTimeFunc = async () => {
1028
1023
  // 判断是否信息是否获取成功
1029
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.LiveBroadcast))) {
1024
+ if (!(await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast))) {
1030
1025
  // 未获取成功,直接返回
1031
1026
  await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
1032
1027
  // 停止服务
@@ -1057,7 +1052,7 @@ class ComRegister {
1057
1052
  .replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`)
1058
1053
  : null;
1059
1054
  // 发送直播通知卡片
1060
- await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, watched, {
1055
+ await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1061
1056
  liveRoomInfo,
1062
1057
  masterInfo,
1063
1058
  cardStyle,
@@ -1135,7 +1130,7 @@ class ComRegister {
1135
1130
  const content = `[${masterInfo.username}的直播间]「${body.user.uname}」加入了大航海(${body.gift_name})`;
1136
1131
  // 直接发送消息
1137
1132
  channelArrLen > 0 &&
1138
- this.broadcastToTargets(liveGuardBuyPushTargetArr, content, type_1.PushType.LiveGuardBuy);
1133
+ this.broadcastToTargets(liveGuardBuyPushTargetArr, content, PushType.LiveGuardBuy);
1139
1134
  },
1140
1135
  onLiveStart: async () => {
1141
1136
  // 判断是否已经开播
@@ -1144,7 +1139,7 @@ class ComRegister {
1144
1139
  // 设置开播状态为true
1145
1140
  liveStatus = true;
1146
1141
  // 判断是否信息是否获取成功
1147
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StartBroadcasting))) {
1142
+ if (!(await useMasterAndLiveRoomInfo(LiveType.StartBroadcasting))) {
1148
1143
  // 设置开播状态为false
1149
1144
  liveStatus = false;
1150
1145
  // 未获取成功,直接返回
@@ -1168,7 +1163,7 @@ class ComRegister {
1168
1163
  .replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`)
1169
1164
  : null;
1170
1165
  // 推送开播通知
1171
- await this.sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, {
1166
+ await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1172
1167
  liveRoomInfo,
1173
1168
  masterInfo,
1174
1169
  cardStyle,
@@ -1183,7 +1178,7 @@ class ComRegister {
1183
1178
  // 将直播状态设置为false
1184
1179
  liveStatus = false;
1185
1180
  // 判断是否信息是否获取成功
1186
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast))) {
1181
+ if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast))) {
1187
1182
  // 未获取成功,直接返回
1188
1183
  await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1189
1184
  // 停止服务
@@ -1216,7 +1211,7 @@ class ComRegister {
1216
1211
  .replace("\\n", "\n")
1217
1212
  : null;
1218
1213
  // 推送通知卡片
1219
- await this.sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, {
1214
+ await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1220
1215
  liveRoomInfo,
1221
1216
  masterInfo,
1222
1217
  cardStyle,
@@ -1230,7 +1225,7 @@ class ComRegister {
1230
1225
  // 启动直播间弹幕监测
1231
1226
  await this.ctx.bl.startLiveRoomListener(roomId, handler);
1232
1227
  // 第一次启动获取信息并判信息是否获取成功
1233
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.FirstLiveBroadcast))) {
1228
+ if (!(await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast))) {
1234
1229
  // 未获取成功,直接返回
1235
1230
  return this.sendPrivateMsg("获取直播间信息失败,启动直播间弹幕检测失败!");
1236
1231
  }
@@ -1251,7 +1246,7 @@ class ComRegister {
1251
1246
  : null;
1252
1247
  // 发送直播通知卡片
1253
1248
  if (this.config.restartPush) {
1254
- await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, watched, {
1249
+ await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1255
1250
  liveRoomInfo,
1256
1251
  masterInfo,
1257
1252
  cardStyle,
@@ -1301,7 +1296,7 @@ class ComRegister {
1301
1296
  }
1302
1297
  const useLiveInfo = async () => {
1303
1298
  // 发送请求
1304
- const { data } = await (0, utils_1.withRetry)(async () => (await this.ctx.ba.getLiveRoomInfoByUids(uids)), 3).catch(async () => {
1299
+ const { data } = await withRetry(async () => (await this.ctx.ba.getLiveRoomInfoByUids(uids)), 3).catch(async () => {
1305
1300
  // 返回undefined
1306
1301
  return undefined;
1307
1302
  });
@@ -1328,7 +1323,7 @@ class ComRegister {
1328
1323
  // 将直播状态改为true
1329
1324
  liveStatus.live = true;
1330
1325
  // 初始化主播和直播间信息
1331
- await useMasterAndLiveRoomInfo(type_1.LiveType.FirstLiveBroadcast, liveStatus);
1326
+ await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast, liveStatus);
1332
1327
  // 判断是否需要设置开播时间
1333
1328
  if (!liveStatus.liveStartTimeInit) {
1334
1329
  // 设置开播时间
@@ -1346,7 +1341,7 @@ class ComRegister {
1346
1341
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1347
1342
  : null;
1348
1343
  // 发送直播通知卡片
1349
- await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, "API", {
1344
+ await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1350
1345
  liveRoomInfo: liveStatus.liveRoomInfo,
1351
1346
  masterInfo: liveStatus.masterInfo,
1352
1347
  cardStyle: sub.card,
@@ -1376,7 +1371,7 @@ class ComRegister {
1376
1371
  if (liveStatus.live === true) {
1377
1372
  // 现在下播了,发送下播通知
1378
1373
  // 判断信息是否获取成功
1379
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast, liveStatus))) {
1374
+ if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, liveStatus))) {
1380
1375
  // 未获取成功,直接返回
1381
1376
  await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1382
1377
  // 停止服务
@@ -1414,7 +1409,7 @@ class ComRegister {
1414
1409
  .replace("\\n", "\n")
1415
1410
  : null;
1416
1411
  // 推送通知卡片
1417
- await this.sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, {
1412
+ await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1418
1413
  liveRoomInfo: liveStatus.liveRoomInfo,
1419
1414
  masterInfo: liveStatus.masterInfo,
1420
1415
  cardStyle: sub.card,
@@ -1430,7 +1425,7 @@ class ComRegister {
1430
1425
  if (liveStatus.live === false) {
1431
1426
  // 开播了
1432
1427
  // 判断信息是否获取成功
1433
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast, liveStatus))) {
1428
+ if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, liveStatus))) {
1434
1429
  // 未获取成功,直接返回
1435
1430
  await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
1436
1431
  // 停止服务
@@ -1454,7 +1449,7 @@ class ComRegister {
1454
1449
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1455
1450
  : null;
1456
1451
  // 推送开播通知
1457
- await this.sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, {
1452
+ await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1458
1453
  liveRoomInfo: liveStatus.liveRoomInfo,
1459
1454
  masterInfo: liveStatus.masterInfo,
1460
1455
  cardStyle: sub.card,
@@ -1471,7 +1466,7 @@ class ComRegister {
1471
1466
  break;
1472
1467
  }
1473
1468
  // 判断是否信息是否获取成功
1474
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.LiveBroadcast, liveStatus))) {
1469
+ if (!(await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast, liveStatus))) {
1475
1470
  // 未获取成功,直接返回
1476
1471
  await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
1477
1472
  // 停止服务
@@ -1494,7 +1489,7 @@ class ComRegister {
1494
1489
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1495
1490
  : null;
1496
1491
  // 发送直播通知卡片
1497
- await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, "API", {
1492
+ await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1498
1493
  liveRoomInfo: liveStatus.liveRoomInfo,
1499
1494
  masterInfo: liveStatus.masterInfo,
1500
1495
  cardStyle: sub.card,
@@ -1511,7 +1506,7 @@ class ComRegister {
1511
1506
  }
1512
1507
  };
1513
1508
  // 返回一个闭包函数
1514
- return (0, utils_1.withLock)(handler);
1509
+ return withLock(handler);
1515
1510
  }
1516
1511
  subShow() {
1517
1512
  // 在控制台中显示订阅对象
@@ -1537,9 +1532,9 @@ class ComRegister {
1537
1532
  const subTableArray = subInfo.split("\n");
1538
1533
  subTableArray.splice(subTableArray.length - 1, 1);
1539
1534
  // 定义Table
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) => (
1535
+ table = (_jsxs(_Fragment, { children: [_jsx("p", { children: "\u5F53\u524D\u8BA2\u9605\u5BF9\u8C61\uFF1A" }), _jsx("ul", { children: subTableArray.map((str) => (
1541
1536
  // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
1542
- (0, jsx_runtime_1.jsx)("li", { children: str }))) })] }));
1537
+ _jsx("li", { children: str }))) })] }));
1543
1538
  }
1544
1539
  // 设置更新后的提示
1545
1540
  this.subNotifier = this.ctx.notifier.create(table);
@@ -1729,7 +1724,7 @@ class ComRegister {
1729
1724
  // logger
1730
1725
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1731
1726
  // 定义Data
1732
- const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await (0, utils_1.withRetry)(async () => {
1727
+ const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await withRetry(async () => {
1733
1728
  // 获取用户信息
1734
1729
  const data = await this.ctx.ba.getUserInfo(sub.uid);
1735
1730
  // 返回用户信息
@@ -1806,7 +1801,7 @@ class ComRegister {
1806
1801
  }
1807
1802
  enableDynamicDetect() {
1808
1803
  // 定义Job
1809
- this.dynamicJob = new cron_1.CronJob("*/2 * * * *", this.config.dynamicDebugMode
1804
+ this.dynamicJob = new CronJob("*/2 * * * *", this.config.dynamicDebugMode
1810
1805
  ? this.debug_dynamicDetect()
1811
1806
  : this.dynamicDetect());
1812
1807
  // logger
@@ -1816,7 +1811,7 @@ class ComRegister {
1816
1811
  }
1817
1812
  async enableLiveDetect() {
1818
1813
  // 定义Job
1819
- this.liveJob = new cron_1.CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
1814
+ this.liveJob = new CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
1820
1815
  // logger
1821
1816
  this.logger.info("直播监测已开启");
1822
1817
  // 开始直播监测
@@ -1835,54 +1830,54 @@ class ComRegister {
1835
1830
  }
1836
1831
  }
1837
1832
  (function (ComRegister) {
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("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个"),
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("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个"),
1851
1846
  })).description("频道/群组信息"),
1852
- platform: koishi_1.Schema.string().description("推送平台"),
1847
+ platform: Schema.string().description("推送平台"),
1853
1848
  })).description("订阅用户需要发送的频道/群组信息"),
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(),
1849
+ card: Schema.object({
1850
+ enable: Schema.boolean(),
1851
+ cardColorStart: Schema.string(),
1852
+ cardColorEnd: Schema.string(),
1853
+ cardBasePlateColor: Schema.string(),
1854
+ cardBasePlateBorder: Schema.string(),
1860
1855
  }).description("自定义推送卡片颜色,默认使用插件内置的颜色,设置后会覆盖插件内置的颜色"),
1861
1856
  }))
1862
1857
  .role("table")
1863
1858
  .description("手动输入订阅信息,方便自定义订阅内容,这里的订阅内容不会存入数据库。uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
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(),
1859
+ master: Schema.object({
1860
+ enable: Schema.boolean(),
1861
+ platform: Schema.string(),
1862
+ masterAccount: Schema.string(),
1863
+ masterAccountGuildId: Schema.string(),
1869
1864
  }),
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),
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),
1884
1879
  }),
1885
- dynamicDebugMode: koishi_1.Schema.boolean().required(),
1880
+ dynamicDebugMode: Schema.boolean().required(),
1886
1881
  });
1887
1882
  })(ComRegister || (ComRegister = {}));
1888
- exports.default = ComRegister;
1883
+ export default ComRegister;