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

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,
@@ -1095,7 +1100,7 @@ class ComRegister {
1095
1100
  // connFlag设置为false
1096
1101
  connFlag = false;
1097
1102
  // logger
1098
- this.logger.info(`${roomId}直播间连接已建立!`);
1103
+ this.logger.info(`[${roomId}]直播间连接已建立!`);
1099
1104
  }
1100
1105
  },
1101
1106
  onClose: async () => {
@@ -1109,10 +1114,21 @@ class ComRegister {
1109
1114
  // 更改connFlag
1110
1115
  connFlag = true;
1111
1116
  // 发送消息
1112
- await this.sendPrivateMsg(`${roomId}直播间连接已中断!`);
1113
- this.logger.error(`${roomId}直播间连接已中断!`);
1117
+ await this.sendPrivateMsg(`[${roomId}]直播间连接已中断!`);
1118
+ this.logger.error(`[${roomId}]直播间连接已中断!`);
1114
1119
  }
1115
1120
  },
1121
+ onError: async () => {
1122
+ // 更直播状态
1123
+ liveStatus = false;
1124
+ // 关闭定时推送
1125
+ pushAtTimeTimer?.();
1126
+ // 停止服务
1127
+ this.ctx.bl.closeListener(roomId);
1128
+ // 发送消息
1129
+ await this.sendPrivateMsg(`[${roomId}]直播间连接发生错误!`);
1130
+ this.logger.error(`[${roomId}]直播间连接发生错误!`);
1131
+ },
1116
1132
  onIncomeDanmu: ({ body }) => {
1117
1133
  // 保存消息到数组
1118
1134
  currentLiveDanmakuArr.push(body.content);
@@ -1130,7 +1146,7 @@ class ComRegister {
1130
1146
  const content = `[${masterInfo.username}的直播间]「${body.user.uname}」加入了大航海(${body.gift_name})`;
1131
1147
  // 直接发送消息
1132
1148
  channelArrLen > 0 &&
1133
- this.broadcastToTargets(liveGuardBuyPushTargetArr, content, PushType.LiveGuardBuy);
1149
+ this.broadcastToTargets(liveGuardBuyPushTargetArr, content, type_1.PushType.LiveGuardBuy);
1134
1150
  },
1135
1151
  onLiveStart: async () => {
1136
1152
  // 判断是否已经开播
@@ -1139,7 +1155,7 @@ class ComRegister {
1139
1155
  // 设置开播状态为true
1140
1156
  liveStatus = true;
1141
1157
  // 判断是否信息是否获取成功
1142
- if (!(await useMasterAndLiveRoomInfo(LiveType.StartBroadcasting))) {
1158
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StartBroadcasting))) {
1143
1159
  // 设置开播状态为false
1144
1160
  liveStatus = false;
1145
1161
  // 未获取成功,直接返回
@@ -1163,7 +1179,7 @@ class ComRegister {
1163
1179
  .replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`)
1164
1180
  : null;
1165
1181
  // 推送开播通知
1166
- await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1182
+ await this.sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, {
1167
1183
  liveRoomInfo,
1168
1184
  masterInfo,
1169
1185
  cardStyle,
@@ -1178,7 +1194,7 @@ class ComRegister {
1178
1194
  // 将直播状态设置为false
1179
1195
  liveStatus = false;
1180
1196
  // 判断是否信息是否获取成功
1181
- if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast))) {
1197
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast))) {
1182
1198
  // 未获取成功,直接返回
1183
1199
  await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1184
1200
  // 停止服务
@@ -1211,7 +1227,7 @@ class ComRegister {
1211
1227
  .replace("\\n", "\n")
1212
1228
  : null;
1213
1229
  // 推送通知卡片
1214
- await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1230
+ await this.sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, {
1215
1231
  liveRoomInfo,
1216
1232
  masterInfo,
1217
1233
  cardStyle,
@@ -1225,7 +1241,7 @@ class ComRegister {
1225
1241
  // 启动直播间弹幕监测
1226
1242
  await this.ctx.bl.startLiveRoomListener(roomId, handler);
1227
1243
  // 第一次启动获取信息并判信息是否获取成功
1228
- if (!(await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast))) {
1244
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.FirstLiveBroadcast))) {
1229
1245
  // 未获取成功,直接返回
1230
1246
  return this.sendPrivateMsg("获取直播间信息失败,启动直播间弹幕检测失败!");
1231
1247
  }
@@ -1246,7 +1262,7 @@ class ComRegister {
1246
1262
  : null;
1247
1263
  // 发送直播通知卡片
1248
1264
  if (this.config.restartPush) {
1249
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, watched, {
1265
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, watched, {
1250
1266
  liveRoomInfo,
1251
1267
  masterInfo,
1252
1268
  cardStyle,
@@ -1296,7 +1312,7 @@ class ComRegister {
1296
1312
  }
1297
1313
  const useLiveInfo = async () => {
1298
1314
  // 发送请求
1299
- const { data } = await withRetry(async () => (await this.ctx.ba.getLiveRoomInfoByUids(uids)), 3).catch(async () => {
1315
+ const { data } = await (0, utils_1.withRetry)(async () => (await this.ctx.ba.getLiveRoomInfoByUids(uids)), 3).catch(async () => {
1300
1316
  // 返回undefined
1301
1317
  return undefined;
1302
1318
  });
@@ -1323,7 +1339,7 @@ class ComRegister {
1323
1339
  // 将直播状态改为true
1324
1340
  liveStatus.live = true;
1325
1341
  // 初始化主播和直播间信息
1326
- await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast, liveStatus);
1342
+ await useMasterAndLiveRoomInfo(type_1.LiveType.FirstLiveBroadcast, liveStatus);
1327
1343
  // 判断是否需要设置开播时间
1328
1344
  if (!liveStatus.liveStartTimeInit) {
1329
1345
  // 设置开播时间
@@ -1341,7 +1357,7 @@ class ComRegister {
1341
1357
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1342
1358
  : null;
1343
1359
  // 发送直播通知卡片
1344
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1360
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, "API", {
1345
1361
  liveRoomInfo: liveStatus.liveRoomInfo,
1346
1362
  masterInfo: liveStatus.masterInfo,
1347
1363
  cardStyle: sub.card,
@@ -1371,7 +1387,7 @@ class ComRegister {
1371
1387
  if (liveStatus.live === true) {
1372
1388
  // 现在下播了,发送下播通知
1373
1389
  // 判断信息是否获取成功
1374
- if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, liveStatus))) {
1390
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast, liveStatus))) {
1375
1391
  // 未获取成功,直接返回
1376
1392
  await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
1377
1393
  // 停止服务
@@ -1409,7 +1425,7 @@ class ComRegister {
1409
1425
  .replace("\\n", "\n")
1410
1426
  : null;
1411
1427
  // 推送通知卡片
1412
- await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
1428
+ await this.sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, {
1413
1429
  liveRoomInfo: liveStatus.liveRoomInfo,
1414
1430
  masterInfo: liveStatus.masterInfo,
1415
1431
  cardStyle: sub.card,
@@ -1425,7 +1441,7 @@ class ComRegister {
1425
1441
  if (liveStatus.live === false) {
1426
1442
  // 开播了
1427
1443
  // 判断信息是否获取成功
1428
- if (!(await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, liveStatus))) {
1444
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.StopBroadcast, liveStatus))) {
1429
1445
  // 未获取成功,直接返回
1430
1446
  await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
1431
1447
  // 停止服务
@@ -1449,7 +1465,7 @@ class ComRegister {
1449
1465
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1450
1466
  : null;
1451
1467
  // 推送开播通知
1452
- await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
1468
+ await this.sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, {
1453
1469
  liveRoomInfo: liveStatus.liveRoomInfo,
1454
1470
  masterInfo: liveStatus.masterInfo,
1455
1471
  cardStyle: sub.card,
@@ -1466,7 +1482,7 @@ class ComRegister {
1466
1482
  break;
1467
1483
  }
1468
1484
  // 判断是否信息是否获取成功
1469
- if (!(await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast, liveStatus))) {
1485
+ if (!(await useMasterAndLiveRoomInfo(type_1.LiveType.LiveBroadcast, liveStatus))) {
1470
1486
  // 未获取成功,直接返回
1471
1487
  await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
1472
1488
  // 停止服务
@@ -1489,7 +1505,7 @@ class ComRegister {
1489
1505
  .replace("-link", `https://live.bilibili.com/${liveStatus.liveRoomInfo.short_id === 0 ? liveStatus.liveRoomInfo.room_id : liveStatus.liveRoomInfo.short_id}`)
1490
1506
  : null;
1491
1507
  // 发送直播通知卡片
1492
- await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
1508
+ await this.sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, "API", {
1493
1509
  liveRoomInfo: liveStatus.liveRoomInfo,
1494
1510
  masterInfo: liveStatus.masterInfo,
1495
1511
  cardStyle: sub.card,
@@ -1506,7 +1522,7 @@ class ComRegister {
1506
1522
  }
1507
1523
  };
1508
1524
  // 返回一个闭包函数
1509
- return withLock(handler);
1525
+ return (0, utils_1.withLock)(handler);
1510
1526
  }
1511
1527
  subShow() {
1512
1528
  // 在控制台中显示订阅对象
@@ -1532,9 +1548,9 @@ class ComRegister {
1532
1548
  const subTableArray = subInfo.split("\n");
1533
1549
  subTableArray.splice(subTableArray.length - 1, 1);
1534
1550
  // 定义Table
1535
- table = (_jsxs(_Fragment, { children: [_jsx("p", { children: "\u5F53\u524D\u8BA2\u9605\u5BF9\u8C61\uFF1A" }), _jsx("ul", { children: subTableArray.map((str) => (
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) => (
1536
1552
  // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
1537
- _jsx("li", { children: str }))) })] }));
1553
+ (0, jsx_runtime_1.jsx)("li", { children: str }))) })] }));
1538
1554
  }
1539
1555
  // 设置更新后的提示
1540
1556
  this.subNotifier = this.ctx.notifier.create(table);
@@ -1558,17 +1574,17 @@ class ComRegister {
1558
1574
  // 判断是否有数据
1559
1575
  if (!this.loginDBData?.dynamic_group_id) {
1560
1576
  // 没有数据,没有创建分组,尝试创建分组
1561
- const createGroupData = await this.ctx.ba.createGroup("订阅");
1577
+ const createGroupData = (await this.ctx.ba.createGroup("订阅"));
1562
1578
  // 如果分组已创建,则获取分组id
1563
1579
  if (createGroupData.code === 22106) {
1564
1580
  // 分组已存在,拿到之前的分组id
1565
- const allGroupData = await this.ctx.ba.getAllGroup();
1581
+ const allGroupData = (await this.ctx.ba.getAllGroup());
1566
1582
  // 遍历所有分组
1567
1583
  for (const group of allGroupData.data) {
1568
1584
  // 找到订阅分组
1569
1585
  if (group.name === "订阅") {
1570
1586
  // 拿到分组id
1571
- this.loginDBData.dynamic_group_id = group.tagid;
1587
+ this.loginDBData.dynamic_group_id = group.tagid.toString();
1572
1588
  // 保存到数据库
1573
1589
  this.ctx.database.set("loginBili", 1, {
1574
1590
  dynamic_group_id: this.loginDBData.dynamic_group_id,
@@ -1584,7 +1600,7 @@ class ComRegister {
1584
1600
  }
1585
1601
  // 创建成功,保存到数据库
1586
1602
  this.ctx.database.set("loginBili", 1, {
1587
- dynamic_group_id: this.loginDBData.dynamic_group_id,
1603
+ dynamic_group_id: createGroupData.data.tagid.toString(),
1588
1604
  });
1589
1605
  // 创建成功
1590
1606
  return { code: createGroupData.code, msg: createGroupData.message };
@@ -1724,7 +1740,7 @@ class ComRegister {
1724
1740
  // logger
1725
1741
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1726
1742
  // 定义Data
1727
- const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await withRetry(async () => {
1743
+ const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await (0, utils_1.withRetry)(async () => {
1728
1744
  // 获取用户信息
1729
1745
  const data = await this.ctx.ba.getUserInfo(sub.uid);
1730
1746
  // 返回用户信息
@@ -1801,7 +1817,7 @@ class ComRegister {
1801
1817
  }
1802
1818
  enableDynamicDetect() {
1803
1819
  // 定义Job
1804
- this.dynamicJob = new CronJob("*/2 * * * *", this.config.dynamicDebugMode
1820
+ this.dynamicJob = new cron_1.CronJob("*/2 * * * *", this.config.dynamicDebugMode
1805
1821
  ? this.debug_dynamicDetect()
1806
1822
  : this.dynamicDetect());
1807
1823
  // logger
@@ -1811,7 +1827,7 @@ class ComRegister {
1811
1827
  }
1812
1828
  async enableLiveDetect() {
1813
1829
  // 定义Job
1814
- this.liveJob = new CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
1830
+ this.liveJob = new cron_1.CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
1815
1831
  // logger
1816
1832
  this.logger.info("直播监测已开启");
1817
1833
  // 开始直播监测
@@ -1830,54 +1846,54 @@ class ComRegister {
1830
1846
  }
1831
1847
  }
1832
1848
  (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("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个"),
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("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个"),
1846
1862
  })).description("频道/群组信息"),
1847
- platform: Schema.string().description("推送平台"),
1863
+ platform: koishi_1.Schema.string().description("推送平台"),
1848
1864
  })).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(),
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(),
1855
1871
  }).description("自定义推送卡片颜色,默认使用插件内置的颜色,设置后会覆盖插件内置的颜色"),
1856
1872
  }))
1857
1873
  .role("table")
1858
1874
  .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(),
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(),
1864
1880
  }),
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),
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),
1879
1895
  }),
1880
- dynamicDebugMode: Schema.boolean().required(),
1896
+ dynamicDebugMode: koishi_1.Schema.boolean().required(),
1881
1897
  });
1882
1898
  })(ComRegister || (ComRegister = {}));
1883
- export default ComRegister;
1899
+ exports.default = ComRegister;