koishi-plugin-bilibili-notify 3.3.4-alpha.4 → 3.3.6-alpha.0
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 +101 -131
- package/lib/index.mjs +102 -131
- package/package.json +1 -1
- package/readme.md +0 -265
package/lib/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "node:module";
|
|
1
2
|
import { Schema, Service, Universal, h } from "koishi";
|
|
2
3
|
import "@koishijs/plugin-notifier";
|
|
3
4
|
import "@koishijs/plugin-help";
|
|
@@ -6,7 +7,6 @@ import { CronJob } from "cron";
|
|
|
6
7
|
import { DateTime } from "luxon";
|
|
7
8
|
import { Jieba } from "@node-rs/jieba";
|
|
8
9
|
import { dict } from "@node-rs/jieba/dict";
|
|
9
|
-
import { Fragment, jsx, jsxs } from "@satorijs/element/jsx-runtime";
|
|
10
10
|
import "koishi-plugin-puppeteer";
|
|
11
11
|
import { resolve } from "node:path";
|
|
12
12
|
import { pathToFileURL } from "node:url";
|
|
@@ -322,7 +322,7 @@ const stopwords = new Set([
|
|
|
322
322
|
var stop_words_default = stopwords;
|
|
323
323
|
|
|
324
324
|
//#endregion
|
|
325
|
-
//#region src/command_register.
|
|
325
|
+
//#region src/command_register.ts
|
|
326
326
|
var ComRegister = class {
|
|
327
327
|
static inject = [
|
|
328
328
|
"bilibili-notify",
|
|
@@ -604,7 +604,7 @@ var ComRegister = class {
|
|
|
604
604
|
["田七", 25]
|
|
605
605
|
];
|
|
606
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(
|
|
607
|
+
await session.send(h("message", [img, h.text(summary)]));
|
|
608
608
|
});
|
|
609
609
|
biliCom.subcommand(".cap").action(async ({ session }) => {
|
|
610
610
|
const { code: userInfoCode, data: userInfoData } = await withRetry(async () => {
|
|
@@ -714,12 +714,12 @@ var ComRegister = class {
|
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
716
|
initAllManager() {
|
|
717
|
-
this.subManager = new Map();
|
|
718
|
-
this.dynamicTimelineManager = new Map();
|
|
719
|
-
this.liveAPIManager = new Map();
|
|
720
|
-
this.liveWSManager = new Map();
|
|
721
|
-
this.liveMsgManager = new Map();
|
|
722
|
-
this.pushArrMap = new Map();
|
|
717
|
+
this.subManager = /* @__PURE__ */ new Map();
|
|
718
|
+
this.dynamicTimelineManager = /* @__PURE__ */ new Map();
|
|
719
|
+
this.liveAPIManager = /* @__PURE__ */ new Map();
|
|
720
|
+
this.liveWSManager = /* @__PURE__ */ new Map();
|
|
721
|
+
this.liveMsgManager = /* @__PURE__ */ new Map();
|
|
722
|
+
this.pushArrMap = /* @__PURE__ */ new Map();
|
|
723
723
|
}
|
|
724
724
|
configSubsToSubscription(sub) {
|
|
725
725
|
const subs = {};
|
|
@@ -788,7 +788,6 @@ var ComRegister = class {
|
|
|
788
788
|
await this.sendPrivateMsg("插件发生未知错误,请检查机器人状态后使用指令 bn start 启动插件");
|
|
789
789
|
this.logger.error("插件发生未知错误,请检查机器人状态后使用指令 bn start 启动插件");
|
|
790
790
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
791
|
-
return;
|
|
792
791
|
}
|
|
793
792
|
async sendMessageWithRetry(bot, channelId, content) {
|
|
794
793
|
withRetry(async () => await bot.sendMessage(channelId, content), 1).catch(async (e) => {
|
|
@@ -883,43 +882,35 @@ var ComRegister = class {
|
|
|
883
882
|
}
|
|
884
883
|
}
|
|
885
884
|
async broadcastToTargets(uid, content, type) {
|
|
886
|
-
this.logger.info(`本次推送对象:${uid},推送类型:${PushTypeMsg[type]}`);
|
|
887
885
|
const record = this.pushArrMap.get(uid);
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
886
|
+
if (!record) return;
|
|
887
|
+
const hasTargets = type === PushType.StartBroadcasting && record.liveAtAllArr?.length > 0 || type === PushType.Dynamic && (record.dynamicArr?.length > 0 || record.dynamicAtAllArr?.length > 0) || (type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length > 0 || type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length > 0 || type === PushType.WordCloudAndLiveSummary && (record.wordcloudArr?.length > 0 || record.liveSummaryArr?.length > 0);
|
|
888
|
+
if (!hasTargets) return;
|
|
889
|
+
this.logger.info(`本次推送对象:${uid},推送类型:${PushTypeMsg[type]}`);
|
|
890
|
+
if (type === PushType.StartBroadcasting && record.liveAtAllArr?.length > 0) {
|
|
891
|
+
this.logger.info("推送 @全体:", record.liveAtAllArr);
|
|
891
892
|
const atAllArr = structuredClone(record.liveAtAllArr);
|
|
892
|
-
await withRetry(
|
|
893
|
-
return await this.pushMessage(atAllArr, /* @__PURE__ */ jsx("message", { children: /* @__PURE__ */ jsx("at", { type: "all" }) }));
|
|
894
|
-
}, 1);
|
|
893
|
+
await withRetry(() => this.pushMessage(atAllArr, h.at("all")), 1);
|
|
895
894
|
}
|
|
896
|
-
if (type === PushType.Dynamic && record.dynamicArr?.length
|
|
897
|
-
if (record.dynamicAtAllArr?.length
|
|
898
|
-
this.logger.info(record.dynamicAtAllArr);
|
|
895
|
+
if (type === PushType.Dynamic && record.dynamicArr?.length > 0) {
|
|
896
|
+
if (record.dynamicAtAllArr?.length > 0) {
|
|
897
|
+
this.logger.info("推送动态 @全体:", record.dynamicAtAllArr);
|
|
899
898
|
const dynamicAtAllArr = structuredClone(record.dynamicAtAllArr);
|
|
900
|
-
await withRetry(
|
|
901
|
-
return await this.pushMessage(dynamicAtAllArr, /* @__PURE__ */ jsx("message", { children: /* @__PURE__ */ jsx("at", { type: "all" }) }));
|
|
902
|
-
}, 1);
|
|
899
|
+
await withRetry(() => this.pushMessage(dynamicAtAllArr, h.at("all")), 1);
|
|
903
900
|
}
|
|
904
|
-
this.logger.info(record.dynamicArr);
|
|
901
|
+
this.logger.info("推送动态:", record.dynamicArr);
|
|
905
902
|
const dynamicArr = structuredClone(record.dynamicArr);
|
|
906
|
-
await withRetry(
|
|
907
|
-
return await this.pushMessage(dynamicArr, /* @__PURE__ */ jsx("message", { children: content }));
|
|
908
|
-
}, 1);
|
|
903
|
+
await withRetry(() => this.pushMessage(dynamicArr, h("message", content)), 1);
|
|
909
904
|
}
|
|
910
|
-
if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length
|
|
911
|
-
this.logger.info(record.liveArr);
|
|
905
|
+
if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length > 0) {
|
|
906
|
+
this.logger.info("推送直播:", record.liveArr);
|
|
912
907
|
const liveArr = structuredClone(record.liveArr);
|
|
913
|
-
await withRetry(
|
|
914
|
-
return await this.pushMessage(liveArr, /* @__PURE__ */ jsx("message", { children: content }));
|
|
915
|
-
}, 1);
|
|
908
|
+
await withRetry(() => this.pushMessage(liveArr, h("message", content)), 1);
|
|
916
909
|
}
|
|
917
|
-
if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length
|
|
918
|
-
this.logger.info(record.liveGuardBuyArr);
|
|
910
|
+
if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length > 0) {
|
|
911
|
+
this.logger.info("推送直播守护购买:", record.liveGuardBuyArr);
|
|
919
912
|
const liveGuardBuyArr = structuredClone(record.liveGuardBuyArr);
|
|
920
|
-
await withRetry(
|
|
921
|
-
return await this.pushMessage(liveGuardBuyArr, /* @__PURE__ */ jsx("message", { children: content }));
|
|
922
|
-
}, 1);
|
|
913
|
+
await withRetry(() => this.pushMessage(liveGuardBuyArr, h(h.Fragment, h(content))), 1);
|
|
923
914
|
}
|
|
924
915
|
if (type === PushType.WordCloudAndLiveSummary) {
|
|
925
916
|
const wordcloudArr = structuredClone(record.wordcloudArr);
|
|
@@ -928,25 +919,16 @@ var ComRegister = class {
|
|
|
928
919
|
const wordcloudOnlyArr = wordcloudArr.filter((item) => !liveSummaryArr.includes(item));
|
|
929
920
|
const liveSummaryOnlyArr = liveSummaryArr.filter((item) => !wordcloudArr.includes(item));
|
|
930
921
|
if (wordcloudAndLiveSummaryArr.length > 0) {
|
|
931
|
-
this.logger.info("
|
|
932
|
-
this.
|
|
933
|
-
await withRetry(async () => {
|
|
934
|
-
return await this.pushMessage(wordcloudAndLiveSummaryArr, /* @__PURE__ */ jsxs("message", { children: [content[0], content[1]] }));
|
|
935
|
-
}, 1);
|
|
922
|
+
this.logger.info("推送词云和直播总结:", wordcloudAndLiveSummaryArr);
|
|
923
|
+
await withRetry(() => this.pushMessage(wordcloudAndLiveSummaryArr, h("message", [content[0], content[1]])), 1);
|
|
936
924
|
}
|
|
937
925
|
if (wordcloudOnlyArr.length > 0) {
|
|
938
|
-
this.logger.info("
|
|
939
|
-
this.
|
|
940
|
-
await withRetry(async () => {
|
|
941
|
-
return await this.pushMessage(wordcloudOnlyArr, /* @__PURE__ */ jsx("message", { children: content[0] }));
|
|
942
|
-
}, 1);
|
|
926
|
+
this.logger.info("推送词云:", wordcloudOnlyArr);
|
|
927
|
+
await withRetry(() => this.pushMessage(wordcloudOnlyArr, h("message", [content[0]])), 1);
|
|
943
928
|
}
|
|
944
929
|
if (liveSummaryOnlyArr.length > 0) {
|
|
945
|
-
this.logger.info("
|
|
946
|
-
this.
|
|
947
|
-
await withRetry(async () => {
|
|
948
|
-
return await this.pushMessage(liveSummaryOnlyArr, /* @__PURE__ */ jsx("message", { children: content[1] }));
|
|
949
|
-
}, 1);
|
|
930
|
+
this.logger.info("推送直播总结:", liveSummaryOnlyArr);
|
|
931
|
+
await withRetry(() => this.pushMessage(liveSummaryOnlyArr, h("message", [content[1]])), 1);
|
|
950
932
|
}
|
|
951
933
|
}
|
|
952
934
|
}
|
|
@@ -960,24 +942,21 @@ var ComRegister = class {
|
|
|
960
942
|
});
|
|
961
943
|
if (!content) return;
|
|
962
944
|
if (content.code !== 0) switch (content.code) {
|
|
963
|
-
case -101:
|
|
945
|
+
case -101:
|
|
964
946
|
this.logger.error("账号未登录,插件已停止工作,请登录");
|
|
965
947
|
await this.sendPrivateMsg("账号未登录,插件已停止工作,请登录");
|
|
966
948
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
967
949
|
break;
|
|
968
|
-
|
|
969
|
-
case -352: {
|
|
950
|
+
case -352:
|
|
970
951
|
this.logger.error("账号被风控,插件已停止工作,请输入指令 bili cap 根据提示解除风控");
|
|
971
952
|
await this.sendPrivateMsg("账号被风控,插件已停止工作,请输入指令 bili cap 根据提示解除风控");
|
|
972
953
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
973
954
|
break;
|
|
974
|
-
|
|
975
|
-
default: {
|
|
955
|
+
default:
|
|
976
956
|
this.logger.error(`获取动态信息错误,错误码为:${content.code},错误为:${content.message},请排除错误后输入指令 bn start 重启插件`);
|
|
977
957
|
await this.sendPrivateMsg(`获取动态信息错误,错误码为:${content.code},错误为:${content.message},请排除错误后输入指令 bn start 重启插件`);
|
|
978
958
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
979
959
|
break;
|
|
980
|
-
}
|
|
981
960
|
}
|
|
982
961
|
const items = content.data.items;
|
|
983
962
|
for (const item of items) {
|
|
@@ -994,15 +973,15 @@ var ComRegister = class {
|
|
|
994
973
|
}, 1).catch(async (e) => {
|
|
995
974
|
if (e.message === "直播开播动态,不做处理") return;
|
|
996
975
|
if (e.message === "出现关键词,屏蔽该动态") {
|
|
997
|
-
if (this.config.filter.notify) await this.broadcastToTargets(uid,
|
|
976
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, h("message", `${name$2}发布了一条含有屏蔽关键字的动态`), PushType.Dynamic);
|
|
998
977
|
return;
|
|
999
978
|
}
|
|
1000
979
|
if (e.message === "已屏蔽转发动态") {
|
|
1001
|
-
if (this.config.filter.notify) await this.broadcastToTargets(uid,
|
|
980
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, h("message", `${name$2}转发了一条动态,已屏蔽`), PushType.Dynamic);
|
|
1002
981
|
return;
|
|
1003
982
|
}
|
|
1004
983
|
if (e.message === "已屏蔽专栏动态") {
|
|
1005
|
-
if (this.config.filter.notify) await this.broadcastToTargets(uid,
|
|
984
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, h("message", `${name$2}投稿了一条专栏,已屏蔽`), PushType.Dynamic);
|
|
1006
985
|
return;
|
|
1007
986
|
}
|
|
1008
987
|
this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
|
|
@@ -1016,18 +995,12 @@ var ComRegister = class {
|
|
|
1016
995
|
} else dUrl = `${name$2}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
|
|
1017
996
|
else dUrl = `${name$2}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
|
|
1018
997
|
this.logger.info("推送动态中...");
|
|
1019
|
-
await this.broadcastToTargets(uid,
|
|
998
|
+
await this.broadcastToTargets(uid, h("message", [h.image(buffer, "image/jpeg"), h.text(dUrl)]), PushType.Dynamic);
|
|
1020
999
|
if (this.config.pushImgsInDynamic) {
|
|
1021
1000
|
if (item.type === "DYNAMIC_TYPE_DRAW") {
|
|
1022
1001
|
const pics = item.modules?.module_dynamic?.major?.opus?.pics;
|
|
1023
1002
|
if (pics) {
|
|
1024
|
-
const picsMsg =
|
|
1025
|
-
forward: true,
|
|
1026
|
-
children: pics.map((pic) => /* @__PURE__ */ jsx("img", {
|
|
1027
|
-
src: pic.url,
|
|
1028
|
-
alt: "动态图片"
|
|
1029
|
-
}, pic.url))
|
|
1030
|
-
});
|
|
1003
|
+
const picsMsg = h("message", { forward: true }, pics.map((pic) => h.img(pic.url)));
|
|
1031
1004
|
await this.broadcastToTargets(uid, picsMsg, PushType.Dynamic);
|
|
1032
1005
|
}
|
|
1033
1006
|
}
|
|
@@ -1055,24 +1028,21 @@ var ComRegister = class {
|
|
|
1055
1028
|
});
|
|
1056
1029
|
if (!content) return;
|
|
1057
1030
|
if (content.code !== 0) switch (content.code) {
|
|
1058
|
-
case -101:
|
|
1031
|
+
case -101:
|
|
1059
1032
|
this.logger.error("账号未登录,插件已停止工作,请登录");
|
|
1060
1033
|
await this.sendPrivateMsg("账号未登录,插件已停止工作,请登录");
|
|
1061
1034
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
1062
1035
|
break;
|
|
1063
|
-
|
|
1064
|
-
case -352: {
|
|
1036
|
+
case -352:
|
|
1065
1037
|
this.logger.error("账号被风控,插件已停止工作,请输入指令 bili cap 根据提示解除风控");
|
|
1066
1038
|
await this.sendPrivateMsg("账号被风控,插件已停止工作,请输入指令 bili cap 根据提示解除风控");
|
|
1067
1039
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
1068
1040
|
break;
|
|
1069
|
-
|
|
1070
|
-
default: {
|
|
1041
|
+
default:
|
|
1071
1042
|
this.logger.error(`获取动态信息错误,错误码为:${content.code},错误为:${content.message},请排除错误后输入指令 bn start 重启插件`);
|
|
1072
1043
|
await this.sendPrivateMsg(`获取动态信息错误,错误码为:${content.code},错误为:${content.message},请排除错误后输入指令 bn start 重启插件`);
|
|
1073
1044
|
await this.ctx["bilibili-notify"].disposePlugin();
|
|
1074
1045
|
break;
|
|
1075
|
-
}
|
|
1076
1046
|
}
|
|
1077
1047
|
this.logger.info("获取动态信息成功!开始处理动态信息...");
|
|
1078
1048
|
const items = content.data.items;
|
|
@@ -1095,15 +1065,15 @@ var ComRegister = class {
|
|
|
1095
1065
|
}, 1).catch(async (e) => {
|
|
1096
1066
|
if (e.message === "直播开播动态,不做处理") return;
|
|
1097
1067
|
if (e.message === "出现关键词,屏蔽该动态") {
|
|
1098
|
-
if (this.config.filter.notify) await this.broadcastToTargets(uid,
|
|
1068
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, h("message", `${name$2}发布了一条含有屏蔽关键字的动态`), PushType.Dynamic);
|
|
1099
1069
|
return;
|
|
1100
1070
|
}
|
|
1101
1071
|
if (e.message === "已屏蔽转发动态") {
|
|
1102
|
-
if (this.config.filter.notify) await this.broadcastToTargets(uid,
|
|
1072
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, h("message", `${name$2}转发了一条动态,已屏蔽`), PushType.Dynamic);
|
|
1103
1073
|
return;
|
|
1104
1074
|
}
|
|
1105
1075
|
if (e.message === "已屏蔽专栏动态") {
|
|
1106
|
-
if (this.config.filter.notify) await this.broadcastToTargets(uid,
|
|
1076
|
+
if (this.config.filter.notify) await this.broadcastToTargets(uid, h("message", `${name$2}投稿了一条专栏,已屏蔽`), PushType.Dynamic);
|
|
1107
1077
|
return;
|
|
1108
1078
|
}
|
|
1109
1079
|
this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
|
|
@@ -1122,19 +1092,13 @@ var ComRegister = class {
|
|
|
1122
1092
|
this.logger.info("动态链接生成成功!");
|
|
1123
1093
|
}
|
|
1124
1094
|
this.logger.info("推送动态中...");
|
|
1125
|
-
await this.broadcastToTargets(uid,
|
|
1095
|
+
await this.broadcastToTargets(uid, h("message", [h.image(buffer, "image/jpeg"), h.text(dUrl)]), PushType.Dynamic);
|
|
1126
1096
|
if (this.config.pushImgsInDynamic) {
|
|
1127
1097
|
this.logger.info("需要发送动态中的图片,开始发送...");
|
|
1128
1098
|
if (item.type === "DYNAMIC_TYPE_DRAW") {
|
|
1129
1099
|
const pics = item.modules?.module_dynamic?.major?.opus?.pics;
|
|
1130
1100
|
if (pics) {
|
|
1131
|
-
const picsMsg =
|
|
1132
|
-
forward: true,
|
|
1133
|
-
children: pics.map((pic) => /* @__PURE__ */ jsx("img", {
|
|
1134
|
-
src: pic.url,
|
|
1135
|
-
alt: "动态图片"
|
|
1136
|
-
}, pic.url))
|
|
1137
|
-
});
|
|
1101
|
+
const picsMsg = h("message", { forward: true }, pics.map((pic) => h.img(pic.url)));
|
|
1138
1102
|
await this.broadcastToTargets(uid, picsMsg, PushType.Dynamic);
|
|
1139
1103
|
}
|
|
1140
1104
|
}
|
|
@@ -1195,7 +1159,7 @@ var ComRegister = class {
|
|
|
1195
1159
|
this.logger.error(`liveDetect generateLiveImg() 推送卡片生成失败,原因:${e.message}`);
|
|
1196
1160
|
});
|
|
1197
1161
|
if (!buffer) return await this.sendPrivateMsgAndStopService();
|
|
1198
|
-
const msg =
|
|
1162
|
+
const msg = h("message", [h.image(buffer, "image/jpeg"), h.text(liveNotifyMsg || "")]);
|
|
1199
1163
|
return await this.broadcastToTargets(uid, msg, liveType === LiveType.StartBroadcasting ? PushType.StartBroadcasting : PushType.Live);
|
|
1200
1164
|
}
|
|
1201
1165
|
async segmentDanmaku(danmaku, danmakuWeightRecord) {
|
|
@@ -1280,10 +1244,14 @@ var ComRegister = class {
|
|
|
1280
1244
|
});
|
|
1281
1245
|
return flag;
|
|
1282
1246
|
};
|
|
1247
|
+
const LIVE_EVENT_COOLDOWN = 10 * 1e3;
|
|
1248
|
+
let lastLiveStart = 0;
|
|
1249
|
+
let lastLiveEnd = 0;
|
|
1283
1250
|
const handler = {
|
|
1284
1251
|
onError: async () => {
|
|
1285
1252
|
liveStatus = false;
|
|
1286
1253
|
pushAtTimeTimer?.();
|
|
1254
|
+
pushAtTimeTimer = null;
|
|
1287
1255
|
this.ctx["bilibili-notify-live"].closeListener(sub.roomid);
|
|
1288
1256
|
await this.sendPrivateMsg(`[${sub.roomid}]直播间连接发生错误!`);
|
|
1289
1257
|
this.logger.error(`[${sub.roomid}]直播间连接发生错误!`);
|
|
@@ -1300,19 +1268,20 @@ var ComRegister = class {
|
|
|
1300
1268
|
watchedNum = body.text_small;
|
|
1301
1269
|
},
|
|
1302
1270
|
onGuardBuy: ({ body }) => {
|
|
1303
|
-
const content =
|
|
1304
|
-
"【",
|
|
1305
|
-
masterInfo.username,
|
|
1306
|
-
"的直播间】",
|
|
1307
|
-
body.user.uname,
|
|
1308
|
-
"加入了大航海(",
|
|
1309
|
-
body.gift_name,
|
|
1310
|
-
")"
|
|
1311
|
-
] });
|
|
1271
|
+
const content = h("message", [h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`)]);
|
|
1312
1272
|
this.broadcastToTargets(sub.uid, content, PushType.LiveGuardBuy);
|
|
1313
1273
|
},
|
|
1314
1274
|
onLiveStart: async () => {
|
|
1315
|
-
|
|
1275
|
+
const now = Date.now();
|
|
1276
|
+
if (now - lastLiveStart < LIVE_EVENT_COOLDOWN) {
|
|
1277
|
+
this.logger.warn(`[${sub.roomid}] 开播事件冷却期内被忽略`);
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
lastLiveStart = now;
|
|
1281
|
+
if (liveStatus) {
|
|
1282
|
+
this.logger.warn(`[${sub.roomid}] 已是开播状态,忽略重复开播事件`);
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1316
1285
|
liveStatus = true;
|
|
1317
1286
|
if (!await useMasterAndLiveRoomInfo(LiveType.StartBroadcasting)) {
|
|
1318
1287
|
liveStatus = false;
|
|
@@ -1333,6 +1302,16 @@ var ComRegister = class {
|
|
|
1333
1302
|
}
|
|
1334
1303
|
},
|
|
1335
1304
|
onLiveEnd: async () => {
|
|
1305
|
+
const now = Date.now();
|
|
1306
|
+
if (now - lastLiveEnd < LIVE_EVENT_COOLDOWN) {
|
|
1307
|
+
this.logger.warn(`[${sub.roomid}] 下播事件冷却期内被忽略`);
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
lastLiveEnd = now;
|
|
1311
|
+
if (!liveStatus) {
|
|
1312
|
+
this.logger.warn(`[${sub.roomid}] 已是下播状态,忽略重复下播事件`);
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1336
1315
|
liveStatus = false;
|
|
1337
1316
|
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast)) {
|
|
1338
1317
|
await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
|
|
@@ -1341,8 +1320,8 @@ var ComRegister = class {
|
|
|
1341
1320
|
liveRoomInfo.live_time = liveTime;
|
|
1342
1321
|
const followerChange = (() => {
|
|
1343
1322
|
const liveFollowerChangeNum = masterInfo.liveFollowerChange;
|
|
1344
|
-
if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
|
|
1345
|
-
return liveFollowerChangeNum <= -1e4 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1323
|
+
if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : `+${liveFollowerChangeNum}`;
|
|
1324
|
+
return liveFollowerChangeNum <= -1e4 ? `${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1346
1325
|
})();
|
|
1347
1326
|
const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
|
|
1348
1327
|
await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
|
|
@@ -1350,8 +1329,11 @@ var ComRegister = class {
|
|
|
1350
1329
|
masterInfo,
|
|
1351
1330
|
cardStyle: sub.customCardStyle
|
|
1352
1331
|
}, sub.uid, liveEndMsg);
|
|
1353
|
-
pushAtTimeTimer
|
|
1354
|
-
|
|
1332
|
+
if (pushAtTimeTimer) {
|
|
1333
|
+
pushAtTimeTimer();
|
|
1334
|
+
pushAtTimeTimer = null;
|
|
1335
|
+
this.liveWSManager.delete(sub.roomid);
|
|
1336
|
+
}
|
|
1355
1337
|
await sendDanmakuWordCloudAndLiveSummary(liveMsgObj.liveSummary);
|
|
1356
1338
|
}
|
|
1357
1339
|
};
|
|
@@ -1433,7 +1415,7 @@ var ComRegister = class {
|
|
|
1433
1415
|
if (!sub) return;
|
|
1434
1416
|
switch (item.live_status) {
|
|
1435
1417
|
case 0:
|
|
1436
|
-
case 2:
|
|
1418
|
+
case 2:
|
|
1437
1419
|
if (LiveAPIStatus.live === true) {
|
|
1438
1420
|
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, LiveAPIStatus)) {
|
|
1439
1421
|
await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
|
|
@@ -1457,8 +1439,7 @@ var ComRegister = class {
|
|
|
1457
1439
|
LiveAPIStatus.live = false;
|
|
1458
1440
|
}
|
|
1459
1441
|
break;
|
|
1460
|
-
|
|
1461
|
-
case 1: {
|
|
1442
|
+
case 1:
|
|
1462
1443
|
if (LiveAPIStatus.live === false) {
|
|
1463
1444
|
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, LiveAPIStatus)) {
|
|
1464
1445
|
await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
|
|
@@ -1497,7 +1478,6 @@ var ComRegister = class {
|
|
|
1497
1478
|
LiveAPIStatus.push = 0;
|
|
1498
1479
|
}
|
|
1499
1480
|
break;
|
|
1500
|
-
}
|
|
1501
1481
|
default: break;
|
|
1502
1482
|
}
|
|
1503
1483
|
}
|
|
@@ -1517,7 +1497,7 @@ var ComRegister = class {
|
|
|
1517
1497
|
else {
|
|
1518
1498
|
const subTableArray = subInfo.split("\n");
|
|
1519
1499
|
subTableArray.splice(subTableArray.length - 1, 1);
|
|
1520
|
-
table =
|
|
1500
|
+
table = h(h.Fragment, [h("p", "当前订阅对象:"), h("ul", subTableArray.map((str) => h("li", str)))]);
|
|
1521
1501
|
}
|
|
1522
1502
|
this.subNotifier = this.ctx.notifier.create(table);
|
|
1523
1503
|
}
|
|
@@ -1756,7 +1736,7 @@ var ComRegister = class {
|
|
|
1756
1736
|
}
|
|
1757
1737
|
};
|
|
1758
1738
|
(function(_ComRegister) {
|
|
1759
|
-
|
|
1739
|
+
_ComRegister.Config = Schema.object({
|
|
1760
1740
|
advancedSub: Schema.boolean(),
|
|
1761
1741
|
subs: Schema.array(Schema.object({
|
|
1762
1742
|
name: Schema.string().required().description("备注"),
|
|
@@ -2099,7 +2079,7 @@ var GenerateImg = class extends Service {
|
|
|
2099
2079
|
switch (dynamic.type) {
|
|
2100
2080
|
case DYNAMIC_TYPE_WORD:
|
|
2101
2081
|
case DYNAMIC_TYPE_DRAW:
|
|
2102
|
-
case DYNAMIC_TYPE_FORWARD:
|
|
2082
|
+
case DYNAMIC_TYPE_FORWARD:
|
|
2103
2083
|
basicDynamic();
|
|
2104
2084
|
if (dynamic.type === DYNAMIC_TYPE_FORWARD) {
|
|
2105
2085
|
if (this.giConfig.filter.enable && this.giConfig.filter.forward) throw new Error("已屏蔽转发动态");
|
|
@@ -2200,7 +2180,6 @@ var GenerateImg = class extends Service {
|
|
|
2200
2180
|
}
|
|
2201
2181
|
}
|
|
2202
2182
|
break;
|
|
2203
|
-
}
|
|
2204
2183
|
case DYNAMIC_TYPE_AV: {
|
|
2205
2184
|
basicDynamic();
|
|
2206
2185
|
const archive = dynamic.modules.module_dynamic.major.archive;
|
|
@@ -2268,10 +2247,9 @@ var GenerateImg = class extends Service {
|
|
|
2268
2247
|
case DYNAMIC_TYPE_LIVE: return [`${upName}发起了直播预约,我暂时无法渲染,请自行查看`];
|
|
2269
2248
|
case DYNAMIC_TYPE_MEDIALIST: return [`${upName}分享了收藏夹,我暂时无法渲染,请自行查看`];
|
|
2270
2249
|
case DYNAMIC_TYPE_PGC: return [`${upName}发布了剧集(番剧、电影、纪录片),我暂时无法渲染,请自行查看`];
|
|
2271
|
-
case DYNAMIC_TYPE_ARTICLE:
|
|
2250
|
+
case DYNAMIC_TYPE_ARTICLE:
|
|
2272
2251
|
if (this.giConfig.filter.enable && this.giConfig.filter.article) throw new Error("已屏蔽专栏动态");
|
|
2273
2252
|
return [`${upName}投稿了新专栏,我暂时无法渲染,请自行查看`];
|
|
2274
|
-
}
|
|
2275
2253
|
case DYNAMIC_TYPE_MUSIC: return [`${upName}发行了新歌,我暂时无法渲染,请自行查看`];
|
|
2276
2254
|
case DYNAMIC_TYPE_COMMON_SQUARE: return [`${upName}发布了装扮|剧集|点评|普通分享,我暂时无法渲染,请自行查看`];
|
|
2277
2255
|
case DYNAMIC_TYPE_COURSES_SEASON: return [`${upName}发布了新课程,我暂时无法渲染,请自行查看`];
|
|
@@ -3182,8 +3160,8 @@ var GenerateImg = class extends Service {
|
|
|
3182
3160
|
</div>
|
|
3183
3161
|
</div>
|
|
3184
3162
|
|
|
3185
|
-
<script src="${wordcloudJS}"
|
|
3186
|
-
<script src="${renderFunc}"
|
|
3163
|
+
<script src="${wordcloudJS}"><\/script>
|
|
3164
|
+
<script src="${renderFunc}"><\/script>
|
|
3187
3165
|
<script>
|
|
3188
3166
|
const canvas = document.getElementById('wordCloudCanvas');
|
|
3189
3167
|
const ctx = canvas.getContext('2d');
|
|
@@ -3207,7 +3185,7 @@ var GenerateImg = class extends Service {
|
|
|
3207
3185
|
densityTarget: 0.3,
|
|
3208
3186
|
weightExponent: 0.4
|
|
3209
3187
|
});
|
|
3210
|
-
|
|
3188
|
+
<\/script>
|
|
3211
3189
|
</body>
|
|
3212
3190
|
|
|
3213
3191
|
</html>
|
|
@@ -3221,30 +3199,26 @@ var GenerateImg = class extends Service {
|
|
|
3221
3199
|
let liveTime;
|
|
3222
3200
|
let cover;
|
|
3223
3201
|
switch (liveStatus) {
|
|
3224
|
-
case 0:
|
|
3202
|
+
case 0:
|
|
3225
3203
|
titleStatus = "未直播";
|
|
3226
3204
|
liveTime = "未开播";
|
|
3227
3205
|
cover = true;
|
|
3228
3206
|
break;
|
|
3229
|
-
|
|
3230
|
-
case 1: {
|
|
3207
|
+
case 1:
|
|
3231
3208
|
titleStatus = "开播啦";
|
|
3232
3209
|
liveTime = `开播时间:${time}`;
|
|
3233
3210
|
cover = true;
|
|
3234
3211
|
break;
|
|
3235
|
-
|
|
3236
|
-
case 2: {
|
|
3212
|
+
case 2:
|
|
3237
3213
|
titleStatus = "正在直播";
|
|
3238
3214
|
liveTime = `直播时长:${await this.getTimeDifference(time)}`;
|
|
3239
3215
|
cover = false;
|
|
3240
3216
|
break;
|
|
3241
|
-
|
|
3242
|
-
case 3: {
|
|
3217
|
+
case 3:
|
|
3243
3218
|
titleStatus = "下播啦";
|
|
3244
3219
|
liveTime = `开播时间:${time}`;
|
|
3245
3220
|
cover = true;
|
|
3246
3221
|
break;
|
|
3247
|
-
}
|
|
3248
3222
|
}
|
|
3249
3223
|
return [
|
|
3250
3224
|
titleStatus,
|
|
@@ -3275,7 +3249,7 @@ var GenerateImg = class extends Service {
|
|
|
3275
3249
|
return parts.length > 0 ? `${sign}${parts.join("")}` : "0秒";
|
|
3276
3250
|
}
|
|
3277
3251
|
unixTimestampToString(timestamp) {
|
|
3278
|
-
const date = new Date(timestamp * 1e3);
|
|
3252
|
+
const date = /* @__PURE__ */ new Date(timestamp * 1e3);
|
|
3279
3253
|
const year = date.getFullYear();
|
|
3280
3254
|
const month = `0${date.getMonth() + 1}`.slice(-2);
|
|
3281
3255
|
const day = `0${date.getDate()}`.slice(-2);
|
|
@@ -3286,7 +3260,7 @@ var GenerateImg = class extends Service {
|
|
|
3286
3260
|
}
|
|
3287
3261
|
};
|
|
3288
3262
|
(function(_GenerateImg) {
|
|
3289
|
-
|
|
3263
|
+
_GenerateImg.Config = Schema.object({
|
|
3290
3264
|
filter: Schema.object({
|
|
3291
3265
|
enable: Schema.boolean(),
|
|
3292
3266
|
notify: Schema.boolean(),
|
|
@@ -4013,15 +3987,13 @@ var BiliAPI = class extends Service {
|
|
|
4013
3987
|
}, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
4014
3988
|
switch (refreshData.code) {
|
|
4015
3989
|
case -101: return await this.createNewClient();
|
|
4016
|
-
case -111:
|
|
3990
|
+
case -111:
|
|
4017
3991
|
await this.ctx.database.remove("loginBili", [1]);
|
|
4018
3992
|
notifyAndError("csrf 校验错误,请重新登录");
|
|
4019
3993
|
break;
|
|
4020
|
-
|
|
4021
|
-
case 86095: {
|
|
3994
|
+
case 86095:
|
|
4022
3995
|
await this.ctx.database.remove("loginBili", [1]);
|
|
4023
3996
|
notifyAndError("refresh_csrf 错误或 refresh_token 与 cookie 不匹配,请重新登录");
|
|
4024
|
-
}
|
|
4025
3997
|
}
|
|
4026
3998
|
const encryptedCookies = this.encrypt(this.getCookies());
|
|
4027
3999
|
const encryptedRefreshToken = this.encrypt(refreshData.data.refresh_token);
|
|
@@ -4038,11 +4010,10 @@ var BiliAPI = class extends Service {
|
|
|
4038
4010
|
refresh_token: refreshToken
|
|
4039
4011
|
}, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
4040
4012
|
switch (aceeptData.code) {
|
|
4041
|
-
case -111:
|
|
4013
|
+
case -111:
|
|
4042
4014
|
await this.ctx.database.remove("loginBili", [1]);
|
|
4043
4015
|
notifyAndError("csrf 校验失败,请重新登录");
|
|
4044
4016
|
break;
|
|
4045
|
-
}
|
|
4046
4017
|
case -400: throw new Error("请求错误");
|
|
4047
4018
|
}
|
|
4048
4019
|
}
|
|
@@ -4075,7 +4046,7 @@ var BiliAPI = class extends Service {
|
|
|
4075
4046
|
}
|
|
4076
4047
|
};
|
|
4077
4048
|
(function(_BiliAPI) {
|
|
4078
|
-
|
|
4049
|
+
_BiliAPI.Config = Schema.object({
|
|
4079
4050
|
userAgent: Schema.string(),
|
|
4080
4051
|
key: Schema.string().pattern(/^[0-9a-f]{32}$/).required()
|
|
4081
4052
|
});
|