koishi-plugin-bilibili-notify 3.3.1-alpha.1 → 3.3.1-rc.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.
- package/lib/index.js +178 -152
- package/lib/index.mjs +178 -152
- package/package.json +1 -1
- package/readme.md +2 -0
package/lib/index.mjs
CHANGED
|
@@ -45,7 +45,7 @@ const BAConfigSchema = Schema.object({
|
|
|
45
45
|
"satori",
|
|
46
46
|
"chronocat",
|
|
47
47
|
"lark"
|
|
48
|
-
]).description("
|
|
48
|
+
]).description("请选择您的私人机器人平台"),
|
|
49
49
|
masterAccount: Schema.string().role("secret").required().description("主人账号,在Q群使用可直接使用QQ号,若在其他平台使用,请使用inspect插件获取自身ID"),
|
|
50
50
|
masterAccountGuildId: Schema.string().role("secret").description("主人账号所在的群组ID,只有在QQ频道、Discord这样的环境才需要填写,请使用inspect插件获取群组ID")
|
|
51
51
|
}), Schema.object({})])]),
|
|
@@ -345,17 +345,19 @@ var ComRegister = class {
|
|
|
345
345
|
rebootCount = 0;
|
|
346
346
|
subNotifier;
|
|
347
347
|
ctx;
|
|
348
|
-
subManager
|
|
349
|
-
dynamicTimelineManager
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
348
|
+
subManager;
|
|
349
|
+
dynamicTimelineManager;
|
|
350
|
+
liveAPIManager;
|
|
351
|
+
liveWSManager;
|
|
352
|
+
liveMsgManager;
|
|
353
|
+
pushArrMap;
|
|
353
354
|
loginDBData;
|
|
354
355
|
privateBot;
|
|
355
356
|
dynamicJob;
|
|
356
|
-
|
|
357
|
+
liveAPIJob;
|
|
357
358
|
_jieba = Jieba.withDict(dict);
|
|
358
359
|
stopwords;
|
|
360
|
+
reciveSubTimes = 0;
|
|
359
361
|
constructor(ctx, config) {
|
|
360
362
|
this.ctx = ctx;
|
|
361
363
|
this.init(config);
|
|
@@ -390,7 +392,7 @@ var ComRegister = class {
|
|
|
390
392
|
} catch (_) {
|
|
391
393
|
return "bili login getLoginQRCode() 本次网络请求失败";
|
|
392
394
|
}
|
|
393
|
-
if (content.code !== 0) return await session.send("
|
|
395
|
+
if (content.code !== 0) return await session.send("出问题咯!");
|
|
394
396
|
QRCode.toBuffer(content.data.url, {
|
|
395
397
|
errorCorrectionLevel: "H",
|
|
396
398
|
type: "png",
|
|
@@ -455,16 +457,16 @@ var ComRegister = class {
|
|
|
455
457
|
biliCom.subcommand(".ll").usage("展示当前正在直播的订阅对象").example("bili ll").action(async () => {
|
|
456
458
|
const { data: { live_users } } = await ctx["bilibili-notify-api"].getTheUserWhoIsLiveStreaming();
|
|
457
459
|
const subLiveUsers = [];
|
|
458
|
-
for (const sub of this.subManager) {
|
|
460
|
+
for (const [uid, sub] of this.subManager) {
|
|
459
461
|
let onLive = false;
|
|
460
462
|
if (live_users.items) {
|
|
461
|
-
for (const user of live_users.items) if (user.mid.toString() ===
|
|
463
|
+
for (const user of live_users.items) if (user.mid.toString() === uid && sub.live) {
|
|
462
464
|
onLive = true;
|
|
463
465
|
break;
|
|
464
466
|
}
|
|
465
467
|
}
|
|
466
468
|
subLiveUsers.push({
|
|
467
|
-
uid: Number.parseInt(
|
|
469
|
+
uid: Number.parseInt(uid),
|
|
468
470
|
uname: sub.uname,
|
|
469
471
|
onLive
|
|
470
472
|
});
|
|
@@ -593,7 +595,7 @@ var ComRegister = class {
|
|
|
593
595
|
["初中", 4],
|
|
594
596
|
["毕业", 4]
|
|
595
597
|
];
|
|
596
|
-
|
|
598
|
+
const img = h.image(await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(words, "词云测试"), "image/jpg");
|
|
597
599
|
const top5DanmakuMaker = [
|
|
598
600
|
["张三", 60],
|
|
599
601
|
["李四", 48],
|
|
@@ -601,8 +603,8 @@ var ComRegister = class {
|
|
|
601
603
|
["赵六", 27],
|
|
602
604
|
["田七", 25]
|
|
603
605
|
];
|
|
604
|
-
const
|
|
605
|
-
await session.send(
|
|
606
|
+
const summary = this.config.liveSummary.join("\n").replace("-dmc", "114").replace("-mdn", "特工").replace("-dca", "514").replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
|
|
607
|
+
await session.send(/* @__PURE__ */ jsxs("message", { children: [img, summary] }));
|
|
606
608
|
});
|
|
607
609
|
biliCom.subcommand(".cap").action(async ({ session }) => {
|
|
608
610
|
const { code: userInfoCode, data: userInfoData } = await withRetry(async () => {
|
|
@@ -624,7 +626,9 @@ var ComRegister = class {
|
|
|
624
626
|
const seccode = `${validate}|jordan`;
|
|
625
627
|
const { data: validateCaptchaData } = await ctx["bilibili-notify-api"].validateCaptcha(data.geetest.challenge, data.token, validate, seccode);
|
|
626
628
|
if (validateCaptchaData?.is_valid !== 1) return "验证不成功!";
|
|
627
|
-
await ctx
|
|
629
|
+
await this.ctx.sleep(10 * 1e3);
|
|
630
|
+
const { code: validCode, data: validData } = await ctx["bilibili-notify-api"].getUserInfo("114514", validateCaptchaData.grisk_id);
|
|
631
|
+
if (validCode === -352 && validData.v_voucher) return "验证不成功!";
|
|
628
632
|
await session.send("验证成功!请重启插件");
|
|
629
633
|
});
|
|
630
634
|
}
|
|
@@ -641,25 +645,34 @@ var ComRegister = class {
|
|
|
641
645
|
return;
|
|
642
646
|
}
|
|
643
647
|
this.mergeStopWords(config.wordcloudStopWords);
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
});
|
|
648
|
-
this.ctx.emit("bilibili-notify/ready-to-recive");
|
|
649
|
-
} else if (config.subs && config.subs.length > 0) {
|
|
648
|
+
this.registeringForEvents();
|
|
649
|
+
if (config.advancedSub) this.ctx.emit("bilibili-notify/ready-to-recive");
|
|
650
|
+
else if (config.subs && config.subs.length > 0) {
|
|
650
651
|
const subs = this.configSubsToSubscription(config.subs);
|
|
651
652
|
await this.initAsyncPart(subs);
|
|
652
653
|
}
|
|
654
|
+
}
|
|
655
|
+
registeringForEvents() {
|
|
653
656
|
this.ctx.on("dispose", () => {
|
|
654
657
|
if (this.loginTimer) this.loginTimer();
|
|
655
658
|
if (this.dynamicJob) this.dynamicJob.stop();
|
|
656
|
-
if (this.
|
|
659
|
+
if (this.liveAPIJob) this.liveAPIJob.stop();
|
|
660
|
+
for (const [roomId, timer] of this.liveWSManager) {
|
|
661
|
+
this.ctx["bilibili-notify-live"].closeListener(roomId);
|
|
662
|
+
if (timer) timer();
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
this.ctx.on("bilibili-notify/advanced-sub", async (subs) => {
|
|
666
|
+
if (this.reciveSubTimes >= 1) await this.ctx["bilibili-notify"].restartPlugin();
|
|
667
|
+
else await this.initAsyncPart(subs);
|
|
668
|
+
this.reciveSubTimes++;
|
|
657
669
|
});
|
|
658
670
|
}
|
|
659
671
|
async initAsyncPart(subs) {
|
|
660
|
-
|
|
672
|
+
this.initAllManager();
|
|
673
|
+
const { code, message } = await this.loadSubFromConfig(subs);
|
|
661
674
|
if (code !== 0) {
|
|
662
|
-
this.logger.error(
|
|
675
|
+
this.logger.error(message);
|
|
663
676
|
this.logger.error("订阅对象加载失败,插件初始化失败!");
|
|
664
677
|
await this.sendPrivateMsg("订阅对象加载失败,插件初始化失败!");
|
|
665
678
|
return;
|
|
@@ -679,9 +692,9 @@ var ComRegister = class {
|
|
|
679
692
|
this.stopwords = new Set([...stop_words_default, ...additionalStopWords]);
|
|
680
693
|
}
|
|
681
694
|
initManager() {
|
|
682
|
-
for (const sub of this.subManager) {
|
|
683
|
-
if (sub.dynamic) this.dynamicTimelineManager.set(
|
|
684
|
-
if (sub.live) this.
|
|
695
|
+
for (const [uid, sub] of this.subManager) {
|
|
696
|
+
if (sub.dynamic) this.dynamicTimelineManager.set(uid, Math.floor(DateTime.now().toSeconds()));
|
|
697
|
+
if (sub.live) this.liveAPIManager.set(uid, {
|
|
685
698
|
roomId: sub.roomId,
|
|
686
699
|
live: false,
|
|
687
700
|
liveRoomInfo: void 0,
|
|
@@ -693,6 +706,14 @@ var ComRegister = class {
|
|
|
693
706
|
});
|
|
694
707
|
}
|
|
695
708
|
}
|
|
709
|
+
initAllManager() {
|
|
710
|
+
this.subManager = new Map();
|
|
711
|
+
this.dynamicTimelineManager = new Map();
|
|
712
|
+
this.liveAPIManager = new Map();
|
|
713
|
+
this.liveWSManager = new Map();
|
|
714
|
+
this.liveMsgManager = new Map();
|
|
715
|
+
this.pushArrMap = new Map();
|
|
716
|
+
}
|
|
696
717
|
configSubsToSubscription(sub) {
|
|
697
718
|
const subs = {};
|
|
698
719
|
sub.forEach((s) => {
|
|
@@ -908,25 +929,21 @@ var ComRegister = class {
|
|
|
908
929
|
if (!content) return;
|
|
909
930
|
if (content.code !== 0) switch (content.code) {
|
|
910
931
|
case -101: {
|
|
911
|
-
this.logger.error("
|
|
912
|
-
await this.sendPrivateMsg("
|
|
932
|
+
this.logger.error("账号未登录,插件已停止工作,请登录");
|
|
933
|
+
await this.sendPrivateMsg("账号未登录,插件已停止工作,请登录");
|
|
913
934
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
914
935
|
break;
|
|
915
936
|
}
|
|
916
937
|
case -352: {
|
|
917
|
-
this.logger.error("
|
|
918
|
-
await this.sendPrivateMsg("
|
|
938
|
+
this.logger.error("账号被风控,插件已停止工作,请输入指令 bili cap 根据提示解除风控");
|
|
939
|
+
await this.sendPrivateMsg("账号被风控,插件已停止工作,请输入指令 bili cap 根据提示解除风控");
|
|
919
940
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
920
941
|
break;
|
|
921
942
|
}
|
|
922
|
-
case 4101128:
|
|
923
|
-
case 4101129: {
|
|
924
|
-
this.logger.error(`获取动态信息错误,错误码为:${content.code},错误为:${content.message}`);
|
|
925
|
-
await this.sendPrivateMsg(`获取动态信息错误,错误码为:${content.code},错误为:${content.message}`);
|
|
926
|
-
break;
|
|
927
|
-
}
|
|
928
943
|
default: {
|
|
929
|
-
|
|
944
|
+
this.logger.error(`获取动态信息错误,错误码为:${content.code},错误为:${content.message},请排除错误后输入指令 bn restart 重启插件`);
|
|
945
|
+
await this.sendPrivateMsg(`获取动态信息错误,错误码为:${content.code},错误为:${content.message},请排除错误后输入指令 bn restart 重启插件`);
|
|
946
|
+
await this.ctx["bilibili-notify"].disposePlugin();
|
|
930
947
|
break;
|
|
931
948
|
}
|
|
932
949
|
}
|
|
@@ -939,21 +956,21 @@ var ComRegister = class {
|
|
|
939
956
|
if (this.dynamicTimelineManager.has(uid)) {
|
|
940
957
|
const timeline = this.dynamicTimelineManager.get(uid);
|
|
941
958
|
if (timeline < postTime) {
|
|
942
|
-
const sub = this.subManager.
|
|
959
|
+
const sub = this.subManager.get(uid);
|
|
943
960
|
const buffer = await withRetry(async () => {
|
|
944
961
|
return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.customCardStyle.enable ? sub.customCardStyle : void 0);
|
|
945
962
|
}, 1).catch(async (e) => {
|
|
946
963
|
if (e.message === "直播开播动态,不做处理") return;
|
|
947
964
|
if (e.message === "出现关键词,屏蔽该动态") {
|
|
948
|
-
if (this.config.filter.notify) await this.broadcastToTargets(
|
|
965
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
|
|
949
966
|
return;
|
|
950
967
|
}
|
|
951
968
|
if (e.message === "已屏蔽转发动态") {
|
|
952
|
-
if (this.config.filter.notify) await this.broadcastToTargets(
|
|
969
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
|
|
953
970
|
return;
|
|
954
971
|
}
|
|
955
972
|
if (e.message === "已屏蔽专栏动态") {
|
|
956
|
-
if (this.config.filter.notify) await this.broadcastToTargets(
|
|
973
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
|
|
957
974
|
return;
|
|
958
975
|
}
|
|
959
976
|
this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
|
|
@@ -967,7 +984,7 @@ var ComRegister = class {
|
|
|
967
984
|
} else dUrl = `${name$2}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
|
|
968
985
|
else dUrl = `${name$2}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
|
|
969
986
|
this.logger.info("推送动态中...");
|
|
970
|
-
await this.broadcastToTargets(
|
|
987
|
+
await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
|
|
971
988
|
if (this.config.pushImgsInDynamic) {
|
|
972
989
|
if (item.type === "DYNAMIC_TYPE_DRAW") {
|
|
973
990
|
const pics = item.modules?.module_dynamic?.major?.opus?.pics;
|
|
@@ -979,7 +996,7 @@ var ComRegister = class {
|
|
|
979
996
|
alt: "动态图片"
|
|
980
997
|
}, pic.url))
|
|
981
998
|
});
|
|
982
|
-
await this.broadcastToTargets(
|
|
999
|
+
await this.broadcastToTargets(uid, picsMsg, PushType.Dynamic);
|
|
983
1000
|
}
|
|
984
1001
|
}
|
|
985
1002
|
}
|
|
@@ -1007,25 +1024,21 @@ var ComRegister = class {
|
|
|
1007
1024
|
if (!content) return;
|
|
1008
1025
|
if (content.code !== 0) switch (content.code) {
|
|
1009
1026
|
case -101: {
|
|
1010
|
-
this.logger.error("
|
|
1011
|
-
await this.sendPrivateMsg("
|
|
1027
|
+
this.logger.error("账号未登录,插件已停止工作,请登录");
|
|
1028
|
+
await this.sendPrivateMsg("账号未登录,插件已停止工作,请登录");
|
|
1012
1029
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
1013
1030
|
break;
|
|
1014
1031
|
}
|
|
1015
1032
|
case -352: {
|
|
1016
|
-
this.logger.error("
|
|
1017
|
-
await this.sendPrivateMsg("
|
|
1033
|
+
this.logger.error("账号被风控,插件已停止工作,请输入指令 bili cap 根据提示解除风控");
|
|
1034
|
+
await this.sendPrivateMsg("账号被风控,插件已停止工作,请输入指令 bili cap 根据提示解除风控");
|
|
1018
1035
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
1019
1036
|
break;
|
|
1020
1037
|
}
|
|
1021
|
-
case 4101128:
|
|
1022
|
-
case 4101129: {
|
|
1023
|
-
this.logger.error(`获取动态信息错误,错误码为:${content.code},错误为:${content.message}`);
|
|
1024
|
-
await this.sendPrivateMsg(`获取动态信息错误,错误码为:${content.code},错误为:${content.message}`);
|
|
1025
|
-
break;
|
|
1026
|
-
}
|
|
1027
1038
|
default: {
|
|
1028
|
-
|
|
1039
|
+
this.logger.error(`获取动态信息错误,错误码为:${content.code},错误为:${content.message},请排除错误后输入指令 bn restart 重启插件`);
|
|
1040
|
+
await this.sendPrivateMsg(`获取动态信息错误,错误码为:${content.code},错误为:${content.message},请排除错误后输入指令 bn restart 重启插件`);
|
|
1041
|
+
await this.ctx["bilibili-notify"].disposePlugin();
|
|
1029
1042
|
break;
|
|
1030
1043
|
}
|
|
1031
1044
|
}
|
|
@@ -1043,22 +1056,22 @@ var ComRegister = class {
|
|
|
1043
1056
|
this.logger.info(`上次推送时间线:${DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
|
|
1044
1057
|
if (timeline < postTime) {
|
|
1045
1058
|
this.logger.info("需要推送该条动态,开始推送...");
|
|
1046
|
-
const sub = this.subManager.
|
|
1059
|
+
const sub = this.subManager.get(uid);
|
|
1047
1060
|
this.logger.info("开始渲染推送卡片...");
|
|
1048
1061
|
const buffer = await withRetry(async () => {
|
|
1049
1062
|
return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item, sub.customCardStyle.enable ? sub.customCardStyle : void 0);
|
|
1050
1063
|
}, 1).catch(async (e) => {
|
|
1051
1064
|
if (e.message === "直播开播动态,不做处理") return;
|
|
1052
1065
|
if (e.message === "出现关键词,屏蔽该动态") {
|
|
1053
|
-
if (this.config.filter.notify) await this.broadcastToTargets(
|
|
1066
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "发布了一条含有屏蔽关键字的动态"] }), PushType.Dynamic);
|
|
1054
1067
|
return;
|
|
1055
1068
|
}
|
|
1056
1069
|
if (e.message === "已屏蔽转发动态") {
|
|
1057
|
-
if (this.config.filter.notify) await this.broadcastToTargets(
|
|
1070
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "转发了一条动态,已屏蔽"] }), PushType.Dynamic);
|
|
1058
1071
|
return;
|
|
1059
1072
|
}
|
|
1060
1073
|
if (e.message === "已屏蔽专栏动态") {
|
|
1061
|
-
if (this.config.filter.notify) await this.broadcastToTargets(
|
|
1074
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [name$2, "投稿了一条专栏,已屏蔽"] }), PushType.Dynamic);
|
|
1062
1075
|
return;
|
|
1063
1076
|
}
|
|
1064
1077
|
this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
|
|
@@ -1077,7 +1090,7 @@ var ComRegister = class {
|
|
|
1077
1090
|
this.logger.info("动态链接生成成功!");
|
|
1078
1091
|
}
|
|
1079
1092
|
this.logger.info("推送动态中...");
|
|
1080
|
-
await this.broadcastToTargets(
|
|
1093
|
+
await this.broadcastToTargets(uid, /* @__PURE__ */ jsxs("message", { children: [h.image(buffer, "image/jpeg"), dUrl] }), PushType.Dynamic);
|
|
1081
1094
|
if (this.config.pushImgsInDynamic) {
|
|
1082
1095
|
this.logger.info("需要发送动态中的图片,开始发送...");
|
|
1083
1096
|
if (item.type === "DYNAMIC_TYPE_DRAW") {
|
|
@@ -1090,7 +1103,7 @@ var ComRegister = class {
|
|
|
1090
1103
|
alt: "动态图片"
|
|
1091
1104
|
}, pic.url))
|
|
1092
1105
|
});
|
|
1093
|
-
await this.broadcastToTargets(
|
|
1106
|
+
await this.broadcastToTargets(uid, picsMsg, PushType.Dynamic);
|
|
1094
1107
|
}
|
|
1095
1108
|
}
|
|
1096
1109
|
this.logger.info("动态中的图片发送完毕!");
|
|
@@ -1179,13 +1192,12 @@ var ComRegister = class {
|
|
|
1179
1192
|
this.logger.info(top90Words);
|
|
1180
1193
|
this.logger.info("正在准备生成弹幕词云");
|
|
1181
1194
|
const buffer = await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(top90Words, masterInfo.username);
|
|
1182
|
-
const img =
|
|
1195
|
+
const img = h.image(buffer, "image/jpeg");
|
|
1183
1196
|
this.logger.info("开始构建弹幕发送排行榜消息");
|
|
1184
1197
|
const danmakuMakerCount = Object.keys(danmakuMakerRecord).length;
|
|
1185
1198
|
const danmakuCount = Object.values(danmakuMakerRecord).reduce((sum, val) => sum + val, 0);
|
|
1186
1199
|
const top5DanmakuMaker = Object.entries(danmakuMakerRecord).sort((a, b) => b[1] - a[1]).slice(0, 5);
|
|
1187
|
-
const
|
|
1188
|
-
const summary = /* @__PURE__ */ jsx("message", { children: danmakuMakerMsg });
|
|
1200
|
+
const summary = customLiveSummary.replace("-dmc", `${danmakuMakerCount}`).replace("-mdn", `${masterInfo.medalName}`).replace("-dca", `${danmakuCount}`).replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
|
|
1189
1201
|
await this.broadcastToTargets(sub.uid, [img, summary], PushType.WordCloudAndLiveSummary);
|
|
1190
1202
|
Object.keys(danmakuWeightRecord).forEach((key) => delete danmakuWeightRecord[key]);
|
|
1191
1203
|
Object.keys(danmakuMakerRecord).forEach((key) => delete danmakuMakerRecord[key]);
|
|
@@ -1273,7 +1285,10 @@ var ComRegister = class {
|
|
|
1273
1285
|
masterInfo,
|
|
1274
1286
|
cardStyle: sub.customCardStyle
|
|
1275
1287
|
}, sub.uid, liveStartMsg);
|
|
1276
|
-
if (this.config.pushTime !== 0 && !pushAtTimeTimer)
|
|
1288
|
+
if (this.config.pushTime !== 0 && !pushAtTimeTimer) {
|
|
1289
|
+
pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
|
|
1290
|
+
this.liveWSManager.set(roomId, pushAtTimeTimer);
|
|
1291
|
+
}
|
|
1277
1292
|
},
|
|
1278
1293
|
onLiveEnd: async () => {
|
|
1279
1294
|
liveStatus = false;
|
|
@@ -1309,29 +1324,32 @@ var ComRegister = class {
|
|
|
1309
1324
|
masterInfo,
|
|
1310
1325
|
cardStyle: sub.customCardStyle
|
|
1311
1326
|
}, sub.uid, liveMsg);
|
|
1312
|
-
if (this.config.pushTime !== 0 && !pushAtTimeTimer)
|
|
1327
|
+
if (this.config.pushTime !== 0 && !pushAtTimeTimer) {
|
|
1328
|
+
pushAtTimeTimer = this.ctx.setInterval(pushAtTimeFunc, this.config.pushTime * 1e3 * 60 * 60);
|
|
1329
|
+
this.liveWSManager.set(roomId, pushAtTimeTimer);
|
|
1330
|
+
}
|
|
1313
1331
|
liveStatus = true;
|
|
1314
1332
|
}
|
|
1315
1333
|
}
|
|
1316
1334
|
async liveDetectWithAPI() {
|
|
1317
|
-
const useMasterAndLiveRoomInfo = async (liveType,
|
|
1335
|
+
const useMasterAndLiveRoomInfo = async (liveType, LiveAPIStatus) => {
|
|
1318
1336
|
let flag = true;
|
|
1319
|
-
|
|
1337
|
+
LiveAPIStatus.liveRoomInfo = await this.useLiveRoomInfo(LiveAPIStatus.roomId).catch(() => {
|
|
1320
1338
|
flag = false;
|
|
1321
1339
|
return null;
|
|
1322
1340
|
});
|
|
1323
|
-
if (!flag || !
|
|
1341
|
+
if (!flag || !LiveAPIStatus.liveRoomInfo?.uid) {
|
|
1324
1342
|
flag = false;
|
|
1325
1343
|
return flag;
|
|
1326
1344
|
}
|
|
1327
|
-
|
|
1345
|
+
LiveAPIStatus.masterInfo = await this.useMasterInfo(LiveAPIStatus.liveRoomInfo.uid, LiveAPIStatus.masterInfo, liveType).catch(() => {
|
|
1328
1346
|
flag = false;
|
|
1329
1347
|
return null;
|
|
1330
1348
|
});
|
|
1331
1349
|
return flag;
|
|
1332
1350
|
};
|
|
1333
1351
|
const uids = [];
|
|
1334
|
-
for (const [uid] of this.
|
|
1352
|
+
for (const [uid] of this.liveAPIManager.entries()) uids.push(uid);
|
|
1335
1353
|
const useLiveInfo = async () => {
|
|
1336
1354
|
const { data: data$1 } = await withRetry(async () => await this.ctx["bilibili-notify-api"].getLiveRoomInfoByUids(uids), 3).catch(async () => {
|
|
1337
1355
|
return void 0;
|
|
@@ -1345,96 +1363,96 @@ var ComRegister = class {
|
|
|
1345
1363
|
const data = await useLiveInfo();
|
|
1346
1364
|
for (const item of Object.values(data)) {
|
|
1347
1365
|
const uid = item.uid.toString();
|
|
1348
|
-
const
|
|
1366
|
+
const LiveAPIStatus = this.liveAPIManager.get(uid);
|
|
1349
1367
|
const liveMsgObj = this.liveMsgManager.get(uid);
|
|
1350
|
-
const sub = this.subManager.
|
|
1368
|
+
const sub = this.subManager.get(uid);
|
|
1351
1369
|
if (item.live_status === 1) {
|
|
1352
|
-
|
|
1353
|
-
await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast,
|
|
1354
|
-
if (!
|
|
1355
|
-
|
|
1356
|
-
|
|
1370
|
+
LiveAPIStatus.live = true;
|
|
1371
|
+
await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast, LiveAPIStatus);
|
|
1372
|
+
if (!LiveAPIStatus.liveStartTimeInit) {
|
|
1373
|
+
LiveAPIStatus.liveStartTime = LiveAPIStatus.liveRoomInfo.live_time;
|
|
1374
|
+
LiveAPIStatus.liveStartTimeInit = true;
|
|
1357
1375
|
}
|
|
1358
|
-
const liveMsg = liveMsgObj.customLive.replace("-name",
|
|
1376
|
+
const liveMsg = liveMsgObj.customLive.replace("-name", LiveAPIStatus.masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(LiveAPIStatus.liveStartTime)).replace("-watched", "API模式无法获取").replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${LiveAPIStatus.liveRoomInfo.short_id === 0 ? LiveAPIStatus.liveRoomInfo.room_id : LiveAPIStatus.liveRoomInfo.short_id}`);
|
|
1359
1377
|
await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
|
|
1360
|
-
liveRoomInfo:
|
|
1361
|
-
masterInfo:
|
|
1378
|
+
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1379
|
+
masterInfo: LiveAPIStatus.masterInfo,
|
|
1362
1380
|
cardStyle: sub.customCardStyle
|
|
1363
|
-
},
|
|
1381
|
+
}, uid, liveMsg);
|
|
1364
1382
|
}
|
|
1365
1383
|
}
|
|
1366
1384
|
const handler = async () => {
|
|
1367
1385
|
const data$1 = await useLiveInfo();
|
|
1368
1386
|
for (const item of Object.values(data$1)) {
|
|
1369
1387
|
const uid = item.uid.toString();
|
|
1370
|
-
const
|
|
1388
|
+
const LiveAPIStatus = this.liveAPIManager.get(uid);
|
|
1371
1389
|
const liveMsgObj = this.liveMsgManager.get(uid);
|
|
1372
|
-
const sub = this.subManager.
|
|
1390
|
+
const sub = this.subManager.get(uid);
|
|
1373
1391
|
if (!sub) return;
|
|
1374
1392
|
switch (item.live_status) {
|
|
1375
1393
|
case 0:
|
|
1376
1394
|
case 2: {
|
|
1377
|
-
if (
|
|
1378
|
-
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast,
|
|
1395
|
+
if (LiveAPIStatus.live === true) {
|
|
1396
|
+
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, LiveAPIStatus)) {
|
|
1379
1397
|
await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
|
|
1380
1398
|
return await this.sendPrivateMsgAndStopService();
|
|
1381
1399
|
}
|
|
1382
|
-
if (
|
|
1383
|
-
|
|
1384
|
-
|
|
1400
|
+
if (LiveAPIStatus.liveStartTimeInit) {
|
|
1401
|
+
LiveAPIStatus.liveRoomInfo.live_time = LiveAPIStatus.liveStartTime;
|
|
1402
|
+
LiveAPIStatus.liveStartTimeInit = false;
|
|
1385
1403
|
}
|
|
1386
1404
|
const followerChange = (() => {
|
|
1387
|
-
const liveFollowerChangeNum =
|
|
1405
|
+
const liveFollowerChangeNum = LiveAPIStatus.masterInfo.liveFollowerChange;
|
|
1388
1406
|
if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
|
|
1389
1407
|
return liveFollowerChangeNum <= -1e4 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1390
1408
|
})();
|
|
1391
|
-
const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name",
|
|
1409
|
+
const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name", LiveAPIStatus.masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(LiveAPIStatus.liveStartTime)).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
|
|
1392
1410
|
await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
|
|
1393
|
-
liveRoomInfo:
|
|
1394
|
-
masterInfo:
|
|
1411
|
+
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1412
|
+
masterInfo: LiveAPIStatus.masterInfo,
|
|
1395
1413
|
cardStyle: sub.customCardStyle
|
|
1396
|
-
},
|
|
1397
|
-
|
|
1414
|
+
}, uid, liveEndMsg);
|
|
1415
|
+
LiveAPIStatus.live = false;
|
|
1398
1416
|
}
|
|
1399
1417
|
break;
|
|
1400
1418
|
}
|
|
1401
1419
|
case 1: {
|
|
1402
|
-
if (
|
|
1403
|
-
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast,
|
|
1420
|
+
if (LiveAPIStatus.live === false) {
|
|
1421
|
+
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, LiveAPIStatus)) {
|
|
1404
1422
|
await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
|
|
1405
1423
|
return await this.sendPrivateMsgAndStopService();
|
|
1406
1424
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
const follower =
|
|
1410
|
-
const liveStartMsg = liveMsgObj.customLiveStart.replace("-name",
|
|
1425
|
+
LiveAPIStatus.liveStartTime = LiveAPIStatus.liveRoomInfo.live_time;
|
|
1426
|
+
LiveAPIStatus.liveStartTimeInit = true;
|
|
1427
|
+
const follower = LiveAPIStatus.masterInfo.liveOpenFollowerNum >= 1e4 ? `${(LiveAPIStatus.masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : LiveAPIStatus.masterInfo.liveOpenFollowerNum.toString();
|
|
1428
|
+
const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", LiveAPIStatus.masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(LiveAPIStatus.liveStartTime)).replace("-follower", follower).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${LiveAPIStatus.liveRoomInfo.short_id === 0 ? LiveAPIStatus.liveRoomInfo.room_id : LiveAPIStatus.liveRoomInfo.short_id}`);
|
|
1411
1429
|
await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
|
|
1412
|
-
liveRoomInfo:
|
|
1413
|
-
masterInfo:
|
|
1430
|
+
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1431
|
+
masterInfo: LiveAPIStatus.masterInfo,
|
|
1414
1432
|
cardStyle: sub.customCardStyle
|
|
1415
|
-
},
|
|
1416
|
-
|
|
1433
|
+
}, uid, liveStartMsg);
|
|
1434
|
+
LiveAPIStatus.live = true;
|
|
1417
1435
|
}
|
|
1418
|
-
if (
|
|
1419
|
-
if (
|
|
1420
|
-
|
|
1436
|
+
if (LiveAPIStatus.live === true) {
|
|
1437
|
+
if (LiveAPIStatus.push < this.config.pushTime * 60 * 60 / 30) {
|
|
1438
|
+
LiveAPIStatus.push++;
|
|
1421
1439
|
break;
|
|
1422
1440
|
}
|
|
1423
|
-
if (!await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast,
|
|
1441
|
+
if (!await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast, LiveAPIStatus)) {
|
|
1424
1442
|
await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
|
|
1425
1443
|
return await this.sendPrivateMsgAndStopService();
|
|
1426
1444
|
}
|
|
1427
|
-
if (!
|
|
1428
|
-
|
|
1429
|
-
|
|
1445
|
+
if (!LiveAPIStatus.liveStartTimeInit) {
|
|
1446
|
+
LiveAPIStatus.liveStartTime = LiveAPIStatus.liveRoomInfo.live_time;
|
|
1447
|
+
LiveAPIStatus.liveStartTimeInit = true;
|
|
1430
1448
|
}
|
|
1431
|
-
const liveMsg = liveMsgObj.customLive.replace("-name",
|
|
1449
|
+
const liveMsg = liveMsgObj.customLive.replace("-name", LiveAPIStatus.masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(LiveAPIStatus.liveStartTime)).replace("-watched", "API模式无法获取").replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${LiveAPIStatus.liveRoomInfo.short_id === 0 ? LiveAPIStatus.liveRoomInfo.room_id : LiveAPIStatus.liveRoomInfo.short_id}`);
|
|
1432
1450
|
await this.sendLiveNotifyCard(LiveType.LiveBroadcast, "API", {
|
|
1433
|
-
liveRoomInfo:
|
|
1434
|
-
masterInfo:
|
|
1451
|
+
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1452
|
+
masterInfo: LiveAPIStatus.masterInfo,
|
|
1435
1453
|
cardStyle: sub.customCardStyle
|
|
1436
|
-
},
|
|
1437
|
-
|
|
1454
|
+
}, uid, liveMsg);
|
|
1455
|
+
LiveAPIStatus.push = 0;
|
|
1438
1456
|
}
|
|
1439
1457
|
break;
|
|
1440
1458
|
}
|
|
@@ -1446,7 +1464,7 @@ var ComRegister = class {
|
|
|
1446
1464
|
}
|
|
1447
1465
|
subShow() {
|
|
1448
1466
|
let table = "";
|
|
1449
|
-
for (const sub of this.subManager) table += `UID:${
|
|
1467
|
+
for (const [uid, sub] of this.subManager) table += `UID:${uid} ${sub.dynamic ? "已订阅动态" : ""} ${sub.live ? "已订阅直播" : ""}\n`;
|
|
1450
1468
|
return table ? table : "没有订阅任何UP";
|
|
1451
1469
|
}
|
|
1452
1470
|
updateSubNotifier() {
|
|
@@ -1481,22 +1499,22 @@ var ComRegister = class {
|
|
|
1481
1499
|
this.ctx.database.set("loginBili", 1, { dynamic_group_id: this.loginDBData.dynamic_group_id });
|
|
1482
1500
|
return {
|
|
1483
1501
|
code: 0,
|
|
1484
|
-
|
|
1502
|
+
message: "分组已存在"
|
|
1485
1503
|
};
|
|
1486
1504
|
}
|
|
1487
1505
|
} else if (createGroupData.code !== 0) return {
|
|
1488
1506
|
code: createGroupData.code,
|
|
1489
|
-
|
|
1507
|
+
message: createGroupData.message
|
|
1490
1508
|
};
|
|
1491
1509
|
this.ctx.database.set("loginBili", 1, { dynamic_group_id: createGroupData.data.tagid.toString() });
|
|
1492
1510
|
return {
|
|
1493
1511
|
code: createGroupData.code,
|
|
1494
|
-
|
|
1512
|
+
message: createGroupData.message
|
|
1495
1513
|
};
|
|
1496
1514
|
}
|
|
1497
1515
|
return {
|
|
1498
1516
|
code: 0,
|
|
1499
|
-
|
|
1517
|
+
message: "分组已存在"
|
|
1500
1518
|
};
|
|
1501
1519
|
};
|
|
1502
1520
|
const resp = await checkGroupIsReady();
|
|
@@ -1512,93 +1530,105 @@ var ComRegister = class {
|
|
|
1512
1530
|
}
|
|
1513
1531
|
return {
|
|
1514
1532
|
code: relationGroupDetailData.code,
|
|
1515
|
-
|
|
1533
|
+
message: relationGroupDetailData.message,
|
|
1516
1534
|
data: void 0
|
|
1517
1535
|
};
|
|
1518
1536
|
}
|
|
1519
1537
|
return {
|
|
1520
1538
|
code: 0,
|
|
1521
|
-
|
|
1539
|
+
message: "获取分组明细成功",
|
|
1522
1540
|
data: relationGroupDetailData.data
|
|
1523
1541
|
};
|
|
1524
1542
|
};
|
|
1525
|
-
const { code,
|
|
1543
|
+
const { code, message, data } = await getGroupDetailData();
|
|
1526
1544
|
if (code !== 0) return {
|
|
1527
1545
|
code,
|
|
1528
|
-
|
|
1546
|
+
message
|
|
1529
1547
|
};
|
|
1530
1548
|
for (const user of data) if (user.mid === mid) return {
|
|
1531
1549
|
code: 0,
|
|
1532
|
-
|
|
1550
|
+
message: "订阅对象已存在于分组中"
|
|
1533
1551
|
};
|
|
1534
1552
|
const subUserData = await this.ctx["bilibili-notify-api"].follow(mid);
|
|
1535
1553
|
const subUserMatchPattern = {
|
|
1536
1554
|
[-101]: () => {
|
|
1537
1555
|
return {
|
|
1538
1556
|
code: subUserData.code,
|
|
1539
|
-
|
|
1557
|
+
message: "账号未登录,请使用指令bili login登录后再进行订阅操作"
|
|
1540
1558
|
};
|
|
1541
1559
|
},
|
|
1542
1560
|
[-102]: () => {
|
|
1543
1561
|
return {
|
|
1544
1562
|
code: subUserData.code,
|
|
1545
|
-
|
|
1563
|
+
message: "账号被封停,无法进行订阅操作"
|
|
1546
1564
|
};
|
|
1547
1565
|
},
|
|
1548
1566
|
22002: () => {
|
|
1549
1567
|
return {
|
|
1550
1568
|
code: subUserData.code,
|
|
1551
|
-
|
|
1569
|
+
message: "因对方隐私设置,无法进行订阅操作"
|
|
1552
1570
|
};
|
|
1553
1571
|
},
|
|
1554
1572
|
22003: () => {
|
|
1555
1573
|
return {
|
|
1556
1574
|
code: subUserData.code,
|
|
1557
|
-
|
|
1575
|
+
message: "你已将对方拉黑,无法进行订阅操作"
|
|
1558
1576
|
};
|
|
1559
1577
|
},
|
|
1560
1578
|
22013: () => {
|
|
1561
1579
|
return {
|
|
1562
1580
|
code: subUserData.code,
|
|
1563
|
-
|
|
1581
|
+
message: "账号已注销,无法进行订阅操作"
|
|
1564
1582
|
};
|
|
1565
1583
|
},
|
|
1566
1584
|
40061: () => {
|
|
1567
1585
|
return {
|
|
1568
1586
|
code: subUserData.code,
|
|
1569
|
-
|
|
1587
|
+
message: "账号不存在,请检查uid输入是否正确或用户是否存在"
|
|
1570
1588
|
};
|
|
1571
1589
|
},
|
|
1572
1590
|
22001: () => {
|
|
1573
1591
|
return {
|
|
1574
1592
|
code: 0,
|
|
1575
|
-
|
|
1593
|
+
message: "订阅对象为自己,无需添加到分组"
|
|
1576
1594
|
};
|
|
1577
1595
|
},
|
|
1578
1596
|
22014: async () => {
|
|
1579
1597
|
const copyUserToGroupData = await this.ctx["bilibili-notify-api"].copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
|
|
1580
1598
|
if (copyUserToGroupData.code !== 0) return {
|
|
1581
1599
|
code: copyUserToGroupData.code,
|
|
1582
|
-
|
|
1600
|
+
message: "添加订阅对象到分组失败,请稍后重试"
|
|
1583
1601
|
};
|
|
1584
1602
|
return {
|
|
1585
1603
|
code: 0,
|
|
1586
|
-
|
|
1604
|
+
message: "订阅对象添加成功"
|
|
1605
|
+
};
|
|
1606
|
+
},
|
|
1607
|
+
22015: async () => {
|
|
1608
|
+
return {
|
|
1609
|
+
code: subUserData.code,
|
|
1610
|
+
message: subUserData.message
|
|
1587
1611
|
};
|
|
1588
1612
|
},
|
|
1589
1613
|
0: async () => {
|
|
1590
1614
|
const copyUserToGroupData = await this.ctx["bilibili-notify-api"].copyUserToGroup(mid, this.loginDBData.dynamic_group_id);
|
|
1591
1615
|
if (copyUserToGroupData.code !== 0) return {
|
|
1592
1616
|
code: copyUserToGroupData.code,
|
|
1593
|
-
|
|
1617
|
+
message: "添加订阅对象到分组失败,请稍后重试"
|
|
1594
1618
|
};
|
|
1595
1619
|
return {
|
|
1596
1620
|
code: 0,
|
|
1597
|
-
|
|
1621
|
+
message: "订阅对象添加成功"
|
|
1598
1622
|
};
|
|
1599
1623
|
}
|
|
1600
1624
|
};
|
|
1601
|
-
|
|
1625
|
+
const subUserExecute = subUserMatchPattern[subUserData.code] || (() => {
|
|
1626
|
+
return {
|
|
1627
|
+
code: subUserData.code,
|
|
1628
|
+
message: subUserData.message
|
|
1629
|
+
};
|
|
1630
|
+
});
|
|
1631
|
+
return await subUserExecute();
|
|
1602
1632
|
}
|
|
1603
1633
|
async loadSubFromConfig(subs) {
|
|
1604
1634
|
this.preInitConfig(subs);
|
|
@@ -1606,11 +1636,8 @@ var ComRegister = class {
|
|
|
1606
1636
|
this.logger.info(`加载订阅UID:${sub.uid}中...`);
|
|
1607
1637
|
const { code: userInfoCode, message: userInfoMsg, data: userInfoData } = await withRetry(async () => {
|
|
1608
1638
|
const data = await this.ctx["bilibili-notify-api"].getUserInfo(sub.uid);
|
|
1609
|
-
return
|
|
1610
|
-
|
|
1611
|
-
data
|
|
1612
|
-
};
|
|
1613
|
-
}).then((content) => content.data).catch((e) => {
|
|
1639
|
+
return data;
|
|
1640
|
+
}).catch((e) => {
|
|
1614
1641
|
this.logger.error(`loadSubFromConfig() getUserInfo() 发生了错误,错误为:${e.message}`);
|
|
1615
1642
|
return {
|
|
1616
1643
|
code: -1,
|
|
@@ -1622,12 +1649,12 @@ var ComRegister = class {
|
|
|
1622
1649
|
await this.sendPrivateMsg("账号被风控,请使用指令 bili cap 进行风控验证");
|
|
1623
1650
|
return {
|
|
1624
1651
|
code: userInfoCode,
|
|
1625
|
-
|
|
1652
|
+
message: userInfoMsg
|
|
1626
1653
|
};
|
|
1627
1654
|
}
|
|
1628
1655
|
if (userInfoCode !== 0) return {
|
|
1629
1656
|
code: userInfoCode,
|
|
1630
|
-
|
|
1657
|
+
message: userInfoMsg
|
|
1631
1658
|
};
|
|
1632
1659
|
if (this.config.liveDetectType === "WS" && sub.live) {
|
|
1633
1660
|
if (!userInfoData.live_room) {
|
|
@@ -1638,8 +1665,7 @@ var ComRegister = class {
|
|
|
1638
1665
|
}
|
|
1639
1666
|
const subInfo = await this.subUserInBili(sub.uid);
|
|
1640
1667
|
if (subInfo.code !== 0) return subInfo;
|
|
1641
|
-
this.subManager.
|
|
1642
|
-
uid: sub.uid,
|
|
1668
|
+
this.subManager.set(sub.uid, {
|
|
1643
1669
|
uname: userInfoData.name,
|
|
1644
1670
|
roomId: sub.live ? userInfoData.live_room.roomid : "",
|
|
1645
1671
|
target: sub.target,
|
|
@@ -1658,7 +1684,7 @@ var ComRegister = class {
|
|
|
1658
1684
|
}
|
|
1659
1685
|
return {
|
|
1660
1686
|
code: 0,
|
|
1661
|
-
|
|
1687
|
+
message: "订阅加载完毕!"
|
|
1662
1688
|
};
|
|
1663
1689
|
}
|
|
1664
1690
|
checkIfDynamicDetectIsNeeded() {
|
|
@@ -1666,7 +1692,7 @@ var ComRegister = class {
|
|
|
1666
1692
|
}
|
|
1667
1693
|
checkIfLiveDetectIsNeeded() {
|
|
1668
1694
|
if (this.config.liveDetectType === "API") {
|
|
1669
|
-
if (this.
|
|
1695
|
+
if (this.liveAPIManager.size > 0) this.enableLiveDetect();
|
|
1670
1696
|
}
|
|
1671
1697
|
}
|
|
1672
1698
|
enableDynamicDetect() {
|
|
@@ -1675,9 +1701,9 @@ var ComRegister = class {
|
|
|
1675
1701
|
this.dynamicJob.start();
|
|
1676
1702
|
}
|
|
1677
1703
|
async enableLiveDetect() {
|
|
1678
|
-
this.
|
|
1704
|
+
this.liveAPIJob = new CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
|
|
1679
1705
|
this.logger.info("直播监测已开启");
|
|
1680
|
-
this.
|
|
1706
|
+
this.liveAPIJob.start();
|
|
1681
1707
|
}
|
|
1682
1708
|
async checkIfIsLogin() {
|
|
1683
1709
|
if ((await this.ctx.database.get("loginBili", 1)).length !== 0) {
|