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

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,
@@ -1146,7 +1141,7 @@ class ComRegister {
1146
1141
  const content = `[${masterInfo.username}的直播间]「${body.user.uname}」加入了大航海(${body.gift_name})`;
1147
1142
  // 直接发送消息
1148
1143
  channelArrLen > 0 &&
1149
- this.broadcastToTargets(liveGuardBuyPushTargetArr, content, type_1.PushType.LiveGuardBuy);
1144
+ this.broadcastToTargets(liveGuardBuyPushTargetArr, content, PushType.LiveGuardBuy);
1150
1145
  },
1151
1146
  onLiveStart: async () => {
1152
1147
  // 判断是否已经开播
@@ -1155,7 +1150,7 @@ class ComRegister {
1155
1150
  // 设置开播状态为true
1156
1151
  liveStatus = true;
1157
1152
  // 判断是否信息是否获取成功
1158
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StartBroadcasting))) {
1153
+ if (!(await useMasterAndLiveRoomInfo(LiveType.StartBroadcasting))) {
1159
1154
  // 设置开播状态为false
1160
1155
  liveStatus = false;
1161
1156
  // 未获取成功,直接返回
@@ -1179,7 +1174,7 @@ class ComRegister {
1179
1174
  .replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`)
1180
1175
  : null;
1181
1176
  // 推送开播通知
1182
- await this.sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, {
1177
+ await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1183
1178
  liveRoomInfo,
1184
1179
  masterInfo,
1185
1180
  cardStyle,
@@ -1194,7 +1189,7 @@ class ComRegister {
1194
1189
  // 将直播状态设置为false
1195
1190
  liveStatus = false;
1196
1191
  // 判断是否信息是否获取成功
1197
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast))) {
1192
+ if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast))) {
1198
1193
  // 未获取成功,直接返回
1199
1194
  await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1200
1195
  // 停止服务
@@ -1227,7 +1222,7 @@ class ComRegister {
1227
1222
  .replace("\\n", "\n")
1228
1223
  : null;
1229
1224
  // 推送通知卡片
1230
- await this.sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, {
1225
+ await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1231
1226
  liveRoomInfo,
1232
1227
  masterInfo,
1233
1228
  cardStyle,
@@ -1241,7 +1236,7 @@ class ComRegister {
1241
1236
  // 启动直播间弹幕监测
1242
1237
  await this.ctx.bl.startLiveRoomListener(roomId, handler);
1243
1238
  // 第一次启动获取信息并判信息是否获取成功
1244
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.FirstLiveBroadcast))) {
1239
+ if (!(await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast))) {
1245
1240
  // 未获取成功,直接返回
1246
1241
  return this.sendPrivateMsg("获取直播间信息失败,启动直播间弹幕检测失败!");
1247
1242
  }
@@ -1262,7 +1257,7 @@ class ComRegister {
1262
1257
  : null;
1263
1258
  // 发送直播通知卡片
1264
1259
  if (this.config.restartPush) {
1265
- await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, watched, {
1260
+ await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1266
1261
  liveRoomInfo,
1267
1262
  masterInfo,
1268
1263
  cardStyle,
@@ -1312,7 +1307,7 @@ class ComRegister {
1312
1307
  }
1313
1308
  const useLiveInfo = async () => {
1314
1309
  // 发送请求
1315
- const { data } = await (0, utils_1.withRetry)(async () => (await this.ctx.ba.getLiveRoomInfoByUids(uids)), 3).catch(async () => {
1310
+ const { data } = await withRetry(async () => (await this.ctx.ba.getLiveRoomInfoByUids(uids)), 3).catch(async () => {
1316
1311
  // 返回undefined
1317
1312
  return undefined;
1318
1313
  });
@@ -1339,7 +1334,7 @@ class ComRegister {
1339
1334
  // 将直播状态改为true
1340
1335
  liveStatus.live = true;
1341
1336
  // 初始化主播和直播间信息
1342
- await useMasterAndLiveRoomInfo(type_1.LiveType.FirstLiveBroadcast, liveStatus);
1337
+ await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast, liveStatus);
1343
1338
  // 判断是否需要设置开播时间
1344
1339
  if (!liveStatus.liveStartTimeInit) {
1345
1340
  // 设置开播时间
@@ -1357,7 +1352,7 @@ class ComRegister {
1357
1352
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1358
1353
  : null;
1359
1354
  // 发送直播通知卡片
1360
- await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, "API", {
1355
+ await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1361
1356
  liveRoomInfo: liveStatus.liveRoomInfo,
1362
1357
  masterInfo: liveStatus.masterInfo,
1363
1358
  cardStyle: sub.card,
@@ -1387,7 +1382,7 @@ class ComRegister {
1387
1382
  if (liveStatus.live === true) {
1388
1383
  // 现在下播了,发送下播通知
1389
1384
  // 判断信息是否获取成功
1390
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast, liveStatus))) {
1385
+ if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, liveStatus))) {
1391
1386
  // 未获取成功,直接返回
1392
1387
  await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1393
1388
  // 停止服务
@@ -1425,7 +1420,7 @@ class ComRegister {
1425
1420
  .replace("\\n", "\n")
1426
1421
  : null;
1427
1422
  // 推送通知卡片
1428
- await this.sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, {
1423
+ await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1429
1424
  liveRoomInfo: liveStatus.liveRoomInfo,
1430
1425
  masterInfo: liveStatus.masterInfo,
1431
1426
  cardStyle: sub.card,
@@ -1441,7 +1436,7 @@ class ComRegister {
1441
1436
  if (liveStatus.live === false) {
1442
1437
  // 开播了
1443
1438
  // 判断信息是否获取成功
1444
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast, liveStatus))) {
1439
+ if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, liveStatus))) {
1445
1440
  // 未获取成功,直接返回
1446
1441
  await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
1447
1442
  // 停止服务
@@ -1465,7 +1460,7 @@ class ComRegister {
1465
1460
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1466
1461
  : null;
1467
1462
  // 推送开播通知
1468
- await this.sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, {
1463
+ await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1469
1464
  liveRoomInfo: liveStatus.liveRoomInfo,
1470
1465
  masterInfo: liveStatus.masterInfo,
1471
1466
  cardStyle: sub.card,
@@ -1482,7 +1477,7 @@ class ComRegister {
1482
1477
  break;
1483
1478
  }
1484
1479
  // 判断是否信息是否获取成功
1485
- if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.LiveBroadcast, liveStatus))) {
1480
+ if (!(await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast, liveStatus))) {
1486
1481
  // 未获取成功,直接返回
1487
1482
  await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
1488
1483
  // 停止服务
@@ -1505,7 +1500,7 @@ class ComRegister {
1505
1500
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1506
1501
  : null;
1507
1502
  // 发送直播通知卡片
1508
- await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, "API", {
1503
+ await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1509
1504
  liveRoomInfo: liveStatus.liveRoomInfo,
1510
1505
  masterInfo: liveStatus.masterInfo,
1511
1506
  cardStyle: sub.card,
@@ -1522,7 +1517,7 @@ class ComRegister {
1522
1517
  }
1523
1518
  };
1524
1519
  // 返回一个闭包函数
1525
- return (0, utils_1.withLock)(handler);
1520
+ return withLock(handler);
1526
1521
  }
1527
1522
  subShow() {
1528
1523
  // 在控制台中显示订阅对象
@@ -1548,9 +1543,9 @@ class ComRegister {
1548
1543
  const subTableArray = subInfo.split("\n");
1549
1544
  subTableArray.splice(subTableArray.length - 1, 1);
1550
1545
  // 定义Table
1551
- 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) => (
1546
+ table = (_jsxs(_Fragment, { children: [_jsx("p", { children: "\u5F53\u524D\u8BA2\u9605\u5BF9\u8C61\uFF1A" }), _jsx("ul", { children: subTableArray.map((str) => (
1552
1547
  // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
1553
- (0, jsx_runtime_1.jsx)("li", { children: str }))) })] }));
1548
+ _jsx("li", { children: str }))) })] }));
1554
1549
  }
1555
1550
  // 设置更新后的提示
1556
1551
  this.subNotifier = this.ctx.notifier.create(table);
@@ -1740,7 +1735,7 @@ class ComRegister {
1740
1735
  // logger
1741
1736
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1742
1737
  // 定义Data
1743
- const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await (0, utils_1.withRetry)(async () => {
1738
+ const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await withRetry(async () => {
1744
1739
  // 获取用户信息
1745
1740
  const data = await this.ctx.ba.getUserInfo(sub.uid);
1746
1741
  // 返回用户信息
@@ -1817,7 +1812,7 @@ class ComRegister {
1817
1812
  }
1818
1813
  enableDynamicDetect() {
1819
1814
  // 定义Job
1820
- this.dynamicJob = new cron_1.CronJob("*/2 * * * *", this.config.dynamicDebugMode
1815
+ this.dynamicJob = new CronJob("*/2 * * * *", this.config.dynamicDebugMode
1821
1816
  ? this.debug_dynamicDetect()
1822
1817
  : this.dynamicDetect());
1823
1818
  // logger
@@ -1827,7 +1822,7 @@ class ComRegister {
1827
1822
  }
1828
1823
  async enableLiveDetect() {
1829
1824
  // 定义Job
1830
- this.liveJob = new cron_1.CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
1825
+ this.liveJob = new CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
1831
1826
  // logger
1832
1827
  this.logger.info("直播监测已开启");
1833
1828
  // 开始直播监测
@@ -1846,54 +1841,54 @@ class ComRegister {
1846
1841
  }
1847
1842
  }
1848
1843
  (function (ComRegister) {
1849
- ComRegister.Config = koishi_1.Schema.object({
1850
- sub: koishi_1.Schema.array(koishi_1.Schema.object({
1851
- uid: koishi_1.Schema.string().description("订阅用户UID"),
1852
- dynamic: koishi_1.Schema.boolean().description("是否订阅用户动态"),
1853
- live: koishi_1.Schema.boolean().description("是否订阅用户直播"),
1854
- target: koishi_1.Schema.array(koishi_1.Schema.object({
1855
- channelArr: koishi_1.Schema.array(koishi_1.Schema.object({
1856
- channelId: koishi_1.Schema.string().description("频道/群组号"),
1857
- dynamic: koishi_1.Schema.boolean().description("该频道/群组是否推送动态信息"),
1858
- live: koishi_1.Schema.boolean().description("该频道/群组是否推送直播通知"),
1859
- liveGuardBuy: koishi_1.Schema.boolean().description("该频道/群组是否推送弹幕消息"),
1860
- atAll: koishi_1.Schema.boolean().description("推送开播通知时是否艾特全体成员"),
1861
- bot: koishi_1.Schema.string().description("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个"),
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("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个"),
1862
1857
  })).description("频道/群组信息"),
1863
- platform: koishi_1.Schema.string().description("推送平台"),
1858
+ platform: Schema.string().description("推送平台"),
1864
1859
  })).description("订阅用户需要发送的频道/群组信息"),
1865
- card: koishi_1.Schema.object({
1866
- enable: koishi_1.Schema.boolean(),
1867
- cardColorStart: koishi_1.Schema.string(),
1868
- cardColorEnd: koishi_1.Schema.string(),
1869
- cardBasePlateColor: koishi_1.Schema.string(),
1870
- cardBasePlateBorder: koishi_1.Schema.string(),
1860
+ card: Schema.object({
1861
+ enable: Schema.boolean(),
1862
+ cardColorStart: Schema.string(),
1863
+ cardColorEnd: Schema.string(),
1864
+ cardBasePlateColor: Schema.string(),
1865
+ cardBasePlateBorder: Schema.string(),
1871
1866
  }).description("自定义推送卡片颜色,默认使用插件内置的颜色,设置后会覆盖插件内置的颜色"),
1872
1867
  }))
1873
1868
  .role("table")
1874
1869
  .description("手动输入订阅信息,方便自定义订阅内容,这里的订阅内容不会存入数据库。uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
1875
- master: koishi_1.Schema.object({
1876
- enable: koishi_1.Schema.boolean(),
1877
- platform: koishi_1.Schema.string(),
1878
- masterAccount: koishi_1.Schema.string(),
1879
- masterAccountGuildId: koishi_1.Schema.string(),
1870
+ master: Schema.object({
1871
+ enable: Schema.boolean(),
1872
+ platform: Schema.string(),
1873
+ masterAccount: Schema.string(),
1874
+ masterAccountGuildId: Schema.string(),
1880
1875
  }),
1881
- liveDetectType: koishi_1.Schema.string(),
1882
- restartPush: koishi_1.Schema.boolean().required(),
1883
- pushTime: koishi_1.Schema.number().required(),
1884
- pushImgsInDynamic: koishi_1.Schema.boolean().required(),
1885
- liveLoopTime: koishi_1.Schema.number().default(10),
1886
- customLiveStart: koishi_1.Schema.string().required(),
1887
- customLive: koishi_1.Schema.string(),
1888
- customLiveEnd: koishi_1.Schema.string().required(),
1889
- dynamicUrl: koishi_1.Schema.boolean().required(),
1890
- filter: koishi_1.Schema.object({
1891
- enable: koishi_1.Schema.boolean(),
1892
- notify: koishi_1.Schema.boolean(),
1893
- regex: koishi_1.Schema.string(),
1894
- keywords: koishi_1.Schema.array(String),
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),
1895
1890
  }),
1896
- dynamicDebugMode: koishi_1.Schema.boolean().required(),
1891
+ dynamicDebugMode: Schema.boolean().required(),
1897
1892
  });
1898
1893
  })(ComRegister || (ComRegister = {}));
1899
- exports.default = ComRegister;
1894
+ export default ComRegister;