koishi-plugin-bilibili-notify 3.3.2 → 3.3.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +75 -51
- package/lib/index.mjs +75 -51
- package/package.json +5 -5
- package/readme.md +3 -0
package/lib/index.js
CHANGED
|
@@ -665,11 +665,13 @@ var ComRegister = class {
|
|
|
665
665
|
}
|
|
666
666
|
this.mergeStopWords(config.wordcloudStopWords);
|
|
667
667
|
this.registeringForEvents();
|
|
668
|
-
if (config.advancedSub)
|
|
669
|
-
|
|
668
|
+
if (config.advancedSub) {
|
|
669
|
+
this.logger.info("开启高级订阅,等待加载订阅...");
|
|
670
|
+
this.ctx.emit("bilibili-notify/ready-to-recive");
|
|
671
|
+
} else if (config.subs && config.subs.length > 0) {
|
|
670
672
|
const subs = this.configSubsToSubscription(config.subs);
|
|
671
673
|
await this.initAsyncPart(subs);
|
|
672
|
-
}
|
|
674
|
+
} else this.logger.info("初始化完毕,未添加任何订阅!");
|
|
673
675
|
}
|
|
674
676
|
registeringForEvents() {
|
|
675
677
|
this.ctx.on("dispose", () => {
|
|
@@ -682,6 +684,10 @@ var ComRegister = class {
|
|
|
682
684
|
}
|
|
683
685
|
});
|
|
684
686
|
this.ctx.on("bilibili-notify/advanced-sub", async (subs) => {
|
|
687
|
+
if (Object.keys(subs).length === 0) {
|
|
688
|
+
this.logger.info("初始化完毕,未添加任何订阅!");
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
685
691
|
if (this.reciveSubTimes >= 1) await this.ctx["bilibili-notify"].restartPlugin();
|
|
686
692
|
else await this.initAsyncPart(subs);
|
|
687
693
|
this.reciveSubTimes++;
|
|
@@ -689,6 +695,7 @@ var ComRegister = class {
|
|
|
689
695
|
}
|
|
690
696
|
async initAsyncPart(subs) {
|
|
691
697
|
this.initAllManager();
|
|
698
|
+
this.logger.info("获取到订阅信息,开始加载订阅...");
|
|
692
699
|
const { code, message } = await this.loadSubFromConfig(subs);
|
|
693
700
|
if (code !== 0) {
|
|
694
701
|
this.logger.error(message);
|
|
@@ -771,8 +778,14 @@ var ComRegister = class {
|
|
|
771
778
|
return this.ctx.bots.find((bot) => bot.platform === pf && bot.selfId === selfId);
|
|
772
779
|
}
|
|
773
780
|
async sendPrivateMsg(content) {
|
|
774
|
-
if (this.config.master.enable)
|
|
775
|
-
|
|
781
|
+
if (this.config.master.enable) {
|
|
782
|
+
if (this.privateBot.status !== koishi.Universal.Status.ONLINE) {
|
|
783
|
+
this.logger.error(`${this.privateBot.platform} 机器人未初始化完毕,无法进行推送`);
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
if (this.config.master.masterAccountGuildId) await this.privateBot.sendPrivateMessage(this.config.master.masterAccount, content, this.config.master.masterAccountGuildId);
|
|
787
|
+
else await this.privateBot.sendPrivateMessage(this.config.master.masterAccount, content);
|
|
788
|
+
}
|
|
776
789
|
}
|
|
777
790
|
async sendPrivateMsgAndRebootService() {
|
|
778
791
|
if (this.rebootCount >= 3) {
|
|
@@ -854,59 +867,74 @@ var ComRegister = class {
|
|
|
854
867
|
this.logger.info("初始化推送群组/频道信息:");
|
|
855
868
|
this.logger.info(this.pushArrMap);
|
|
856
869
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
this.ctx.setTimeout(() => {
|
|
864
|
-
this.broadcastToTargets(uid, content, type, retry * 2);
|
|
865
|
-
}, retry);
|
|
866
|
-
return;
|
|
870
|
+
async pushMessage(targets, content, retry = 3e3) {
|
|
871
|
+
const t = {};
|
|
872
|
+
for (const target of targets) {
|
|
873
|
+
const [platform, channleId] = target.split(":");
|
|
874
|
+
if (!t[platform]) t[platform] = [channleId];
|
|
875
|
+
else t[platform].push(channleId);
|
|
867
876
|
}
|
|
877
|
+
for (const platform of Object.keys(t)) {
|
|
878
|
+
const bots = [];
|
|
879
|
+
for (const bot of this.ctx.bots) if (bot.platform === platform) bots.push(bot);
|
|
880
|
+
botloop: for (const bot of bots) {
|
|
881
|
+
if (bot.status !== koishi.Universal.Status.ONLINE) {
|
|
882
|
+
this.logger.error(`${platform} 机器人未初始化完毕,无法进行推送,${retry / 1e3}秒后重试`);
|
|
883
|
+
this.ctx.setTimeout(async () => {
|
|
884
|
+
await this.pushMessage(targets, retry * 2);
|
|
885
|
+
}, retry);
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
let num = 0;
|
|
889
|
+
for (const channelId of t[platform]) try {
|
|
890
|
+
await bot.sendMessage(channelId, content);
|
|
891
|
+
num++;
|
|
892
|
+
} catch (e) {
|
|
893
|
+
this.logger.error(e);
|
|
894
|
+
if (bots.length > 1) continue botloop;
|
|
895
|
+
}
|
|
896
|
+
this.logger.info(`成功推送消息 ${num} 条`);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
async broadcastToTargets(uid, content, type) {
|
|
868
901
|
this.logger.info(`本次推送对象:${uid},推送类型:${PushTypeMsg[type]}`);
|
|
869
902
|
const record = this.pushArrMap.get(uid);
|
|
870
903
|
this.logger.info("本次推送目标:");
|
|
871
904
|
if (type === PushType.StartBroadcasting && record.liveAtAllArr?.length >= 1) {
|
|
872
905
|
this.logger.info(record.liveAtAllArr);
|
|
873
906
|
const atAllArr = structuredClone(record.liveAtAllArr);
|
|
874
|
-
|
|
875
|
-
return await this.
|
|
907
|
+
await withRetry(async () => {
|
|
908
|
+
return await this.pushMessage(atAllArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("at", { type: "all" }) }));
|
|
876
909
|
}, 1);
|
|
877
|
-
this.logger.info(`成功推送全体成员消息:${success.length}条`);
|
|
878
910
|
}
|
|
879
911
|
if (type === PushType.Dynamic && record.dynamicArr?.length >= 1) {
|
|
880
912
|
if (record.dynamicAtAllArr?.length >= 1) {
|
|
881
913
|
this.logger.info(record.dynamicAtAllArr);
|
|
882
914
|
const dynamicAtAllArr = structuredClone(record.dynamicAtAllArr);
|
|
883
|
-
|
|
884
|
-
return await this.
|
|
915
|
+
await withRetry(async () => {
|
|
916
|
+
return await this.pushMessage(dynamicAtAllArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("at", { type: "all" }) }));
|
|
885
917
|
}, 1);
|
|
886
|
-
this.logger.info(`成功推送全体成员消息:${success$1.length}条`);
|
|
887
918
|
}
|
|
888
919
|
this.logger.info(record.dynamicArr);
|
|
889
920
|
const dynamicArr = structuredClone(record.dynamicArr);
|
|
890
|
-
|
|
891
|
-
return await this.
|
|
921
|
+
await withRetry(async () => {
|
|
922
|
+
return await this.pushMessage(dynamicArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
|
|
892
923
|
}, 1);
|
|
893
|
-
this.logger.info(`成功推送动态消息:${success.length}条`);
|
|
894
924
|
}
|
|
895
925
|
if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length >= 1) {
|
|
896
926
|
this.logger.info(record.liveArr);
|
|
897
927
|
const liveArr = structuredClone(record.liveArr);
|
|
898
|
-
|
|
899
|
-
return await this.
|
|
928
|
+
await withRetry(async () => {
|
|
929
|
+
return await this.pushMessage(liveArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
|
|
900
930
|
}, 1);
|
|
901
|
-
this.logger.info(`成功推送直播消息:${success.length}条`);
|
|
902
931
|
}
|
|
903
932
|
if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length >= 1) {
|
|
904
933
|
this.logger.info(record.liveGuardBuyArr);
|
|
905
934
|
const liveGuardBuyArr = structuredClone(record.liveGuardBuyArr);
|
|
906
|
-
|
|
907
|
-
return await this.
|
|
935
|
+
await withRetry(async () => {
|
|
936
|
+
return await this.pushMessage(liveGuardBuyArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
|
|
908
937
|
}, 1);
|
|
909
|
-
this.logger.info(`成功推送上舰消息:${success.length}条`);
|
|
910
938
|
}
|
|
911
939
|
if (type === PushType.WordCloudAndLiveSummary) {
|
|
912
940
|
const wordcloudArr = structuredClone(record.wordcloudArr);
|
|
@@ -917,26 +945,23 @@ var ComRegister = class {
|
|
|
917
945
|
if (wordcloudAndLiveSummaryArr.length > 0) {
|
|
918
946
|
this.logger.info("词云和直播总结");
|
|
919
947
|
this.logger.info(wordcloudAndLiveSummaryArr);
|
|
920
|
-
|
|
921
|
-
return await this.
|
|
948
|
+
await withRetry(async () => {
|
|
949
|
+
return await this.pushMessage(wordcloudAndLiveSummaryArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [content[0], content[1]] }));
|
|
922
950
|
}, 1);
|
|
923
|
-
this.logger.info(`成功推送词云和直播总结消息:${success.length}条`);
|
|
924
951
|
}
|
|
925
952
|
if (wordcloudOnlyArr.length > 0) {
|
|
926
953
|
this.logger.info("词云");
|
|
927
954
|
this.logger.info(wordcloudOnlyArr);
|
|
928
|
-
|
|
929
|
-
return await this.
|
|
955
|
+
await withRetry(async () => {
|
|
956
|
+
return await this.pushMessage(wordcloudOnlyArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content[0] }));
|
|
930
957
|
}, 1);
|
|
931
|
-
this.logger.info(`成功推送词云消息:${success.length}条`);
|
|
932
958
|
}
|
|
933
959
|
if (liveSummaryOnlyArr.length > 0) {
|
|
934
960
|
this.logger.info("直播总结");
|
|
935
961
|
this.logger.info(liveSummaryOnlyArr);
|
|
936
|
-
|
|
937
|
-
return await this.
|
|
962
|
+
await withRetry(async () => {
|
|
963
|
+
return await this.pushMessage(liveSummaryOnlyArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content[1] }));
|
|
938
964
|
}, 1);
|
|
939
|
-
this.logger.info(`成功推送直播总结消息:${success.length}条`);
|
|
940
965
|
}
|
|
941
966
|
}
|
|
942
967
|
}
|
|
@@ -1522,19 +1547,18 @@ var ComRegister = class {
|
|
|
1522
1547
|
}
|
|
1523
1548
|
async subUserInBili(mid) {
|
|
1524
1549
|
const checkGroupIsReady = async () => {
|
|
1525
|
-
|
|
1550
|
+
const allGroupData = await this.ctx["bilibili-notify-api"].getAllGroup();
|
|
1551
|
+
let existFlag = false;
|
|
1552
|
+
for (const group of allGroupData.data) if (group.name === "订阅") {
|
|
1553
|
+
if (this.loginDBData.dynamic_group_id !== group.tagid.toString()) {
|
|
1554
|
+
this.loginDBData.dynamic_group_id = group.tagid.toString();
|
|
1555
|
+
this.ctx.database.set("loginBili", 1, { dynamic_group_id: this.loginDBData.dynamic_group_id });
|
|
1556
|
+
}
|
|
1557
|
+
existFlag = true;
|
|
1558
|
+
}
|
|
1559
|
+
if (!existFlag) {
|
|
1526
1560
|
const createGroupData = await this.ctx["bilibili-notify-api"].createGroup("订阅");
|
|
1527
|
-
if (createGroupData.code
|
|
1528
|
-
const allGroupData = await this.ctx["bilibili-notify-api"].getAllGroup();
|
|
1529
|
-
for (const group of allGroupData.data) if (group.name === "订阅") {
|
|
1530
|
-
this.loginDBData.dynamic_group_id = group.tagid.toString();
|
|
1531
|
-
this.ctx.database.set("loginBili", 1, { dynamic_group_id: this.loginDBData.dynamic_group_id });
|
|
1532
|
-
return {
|
|
1533
|
-
code: 0,
|
|
1534
|
-
message: "分组已存在"
|
|
1535
|
-
};
|
|
1536
|
-
}
|
|
1537
|
-
} else if (createGroupData.code !== 0) return {
|
|
1561
|
+
if (createGroupData.code !== 0) return {
|
|
1538
1562
|
code: createGroupData.code,
|
|
1539
1563
|
message: createGroupData.message
|
|
1540
1564
|
};
|
package/lib/index.mjs
CHANGED
|
@@ -646,11 +646,13 @@ var ComRegister = class {
|
|
|
646
646
|
}
|
|
647
647
|
this.mergeStopWords(config.wordcloudStopWords);
|
|
648
648
|
this.registeringForEvents();
|
|
649
|
-
if (config.advancedSub)
|
|
650
|
-
|
|
649
|
+
if (config.advancedSub) {
|
|
650
|
+
this.logger.info("开启高级订阅,等待加载订阅...");
|
|
651
|
+
this.ctx.emit("bilibili-notify/ready-to-recive");
|
|
652
|
+
} else if (config.subs && config.subs.length > 0) {
|
|
651
653
|
const subs = this.configSubsToSubscription(config.subs);
|
|
652
654
|
await this.initAsyncPart(subs);
|
|
653
|
-
}
|
|
655
|
+
} else this.logger.info("初始化完毕,未添加任何订阅!");
|
|
654
656
|
}
|
|
655
657
|
registeringForEvents() {
|
|
656
658
|
this.ctx.on("dispose", () => {
|
|
@@ -663,6 +665,10 @@ var ComRegister = class {
|
|
|
663
665
|
}
|
|
664
666
|
});
|
|
665
667
|
this.ctx.on("bilibili-notify/advanced-sub", async (subs) => {
|
|
668
|
+
if (Object.keys(subs).length === 0) {
|
|
669
|
+
this.logger.info("初始化完毕,未添加任何订阅!");
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
666
672
|
if (this.reciveSubTimes >= 1) await this.ctx["bilibili-notify"].restartPlugin();
|
|
667
673
|
else await this.initAsyncPart(subs);
|
|
668
674
|
this.reciveSubTimes++;
|
|
@@ -670,6 +676,7 @@ var ComRegister = class {
|
|
|
670
676
|
}
|
|
671
677
|
async initAsyncPart(subs) {
|
|
672
678
|
this.initAllManager();
|
|
679
|
+
this.logger.info("获取到订阅信息,开始加载订阅...");
|
|
673
680
|
const { code, message } = await this.loadSubFromConfig(subs);
|
|
674
681
|
if (code !== 0) {
|
|
675
682
|
this.logger.error(message);
|
|
@@ -752,8 +759,14 @@ var ComRegister = class {
|
|
|
752
759
|
return this.ctx.bots.find((bot) => bot.platform === pf && bot.selfId === selfId);
|
|
753
760
|
}
|
|
754
761
|
async sendPrivateMsg(content) {
|
|
755
|
-
if (this.config.master.enable)
|
|
756
|
-
|
|
762
|
+
if (this.config.master.enable) {
|
|
763
|
+
if (this.privateBot.status !== Universal.Status.ONLINE) {
|
|
764
|
+
this.logger.error(`${this.privateBot.platform} 机器人未初始化完毕,无法进行推送`);
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
if (this.config.master.masterAccountGuildId) await this.privateBot.sendPrivateMessage(this.config.master.masterAccount, content, this.config.master.masterAccountGuildId);
|
|
768
|
+
else await this.privateBot.sendPrivateMessage(this.config.master.masterAccount, content);
|
|
769
|
+
}
|
|
757
770
|
}
|
|
758
771
|
async sendPrivateMsgAndRebootService() {
|
|
759
772
|
if (this.rebootCount >= 3) {
|
|
@@ -835,59 +848,74 @@ var ComRegister = class {
|
|
|
835
848
|
this.logger.info("初始化推送群组/频道信息:");
|
|
836
849
|
this.logger.info(this.pushArrMap);
|
|
837
850
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
this.ctx.setTimeout(() => {
|
|
845
|
-
this.broadcastToTargets(uid, content, type, retry * 2);
|
|
846
|
-
}, retry);
|
|
847
|
-
return;
|
|
851
|
+
async pushMessage(targets, content, retry = 3e3) {
|
|
852
|
+
const t = {};
|
|
853
|
+
for (const target of targets) {
|
|
854
|
+
const [platform, channleId] = target.split(":");
|
|
855
|
+
if (!t[platform]) t[platform] = [channleId];
|
|
856
|
+
else t[platform].push(channleId);
|
|
848
857
|
}
|
|
858
|
+
for (const platform of Object.keys(t)) {
|
|
859
|
+
const bots = [];
|
|
860
|
+
for (const bot of this.ctx.bots) if (bot.platform === platform) bots.push(bot);
|
|
861
|
+
botloop: for (const bot of bots) {
|
|
862
|
+
if (bot.status !== Universal.Status.ONLINE) {
|
|
863
|
+
this.logger.error(`${platform} 机器人未初始化完毕,无法进行推送,${retry / 1e3}秒后重试`);
|
|
864
|
+
this.ctx.setTimeout(async () => {
|
|
865
|
+
await this.pushMessage(targets, retry * 2);
|
|
866
|
+
}, retry);
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
let num = 0;
|
|
870
|
+
for (const channelId of t[platform]) try {
|
|
871
|
+
await bot.sendMessage(channelId, content);
|
|
872
|
+
num++;
|
|
873
|
+
} catch (e) {
|
|
874
|
+
this.logger.error(e);
|
|
875
|
+
if (bots.length > 1) continue botloop;
|
|
876
|
+
}
|
|
877
|
+
this.logger.info(`成功推送消息 ${num} 条`);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
async broadcastToTargets(uid, content, type) {
|
|
849
882
|
this.logger.info(`本次推送对象:${uid},推送类型:${PushTypeMsg[type]}`);
|
|
850
883
|
const record = this.pushArrMap.get(uid);
|
|
851
884
|
this.logger.info("本次推送目标:");
|
|
852
885
|
if (type === PushType.StartBroadcasting && record.liveAtAllArr?.length >= 1) {
|
|
853
886
|
this.logger.info(record.liveAtAllArr);
|
|
854
887
|
const atAllArr = structuredClone(record.liveAtAllArr);
|
|
855
|
-
|
|
856
|
-
return await this.
|
|
888
|
+
await withRetry(async () => {
|
|
889
|
+
return await this.pushMessage(atAllArr, /* @__PURE__ */ jsx("message", { children: /* @__PURE__ */ jsx("at", { type: "all" }) }));
|
|
857
890
|
}, 1);
|
|
858
|
-
this.logger.info(`成功推送全体成员消息:${success.length}条`);
|
|
859
891
|
}
|
|
860
892
|
if (type === PushType.Dynamic && record.dynamicArr?.length >= 1) {
|
|
861
893
|
if (record.dynamicAtAllArr?.length >= 1) {
|
|
862
894
|
this.logger.info(record.dynamicAtAllArr);
|
|
863
895
|
const dynamicAtAllArr = structuredClone(record.dynamicAtAllArr);
|
|
864
|
-
|
|
865
|
-
return await this.
|
|
896
|
+
await withRetry(async () => {
|
|
897
|
+
return await this.pushMessage(dynamicAtAllArr, /* @__PURE__ */ jsx("message", { children: /* @__PURE__ */ jsx("at", { type: "all" }) }));
|
|
866
898
|
}, 1);
|
|
867
|
-
this.logger.info(`成功推送全体成员消息:${success$1.length}条`);
|
|
868
899
|
}
|
|
869
900
|
this.logger.info(record.dynamicArr);
|
|
870
901
|
const dynamicArr = structuredClone(record.dynamicArr);
|
|
871
|
-
|
|
872
|
-
return await this.
|
|
902
|
+
await withRetry(async () => {
|
|
903
|
+
return await this.pushMessage(dynamicArr, /* @__PURE__ */ jsx("message", { children: content }));
|
|
873
904
|
}, 1);
|
|
874
|
-
this.logger.info(`成功推送动态消息:${success.length}条`);
|
|
875
905
|
}
|
|
876
906
|
if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length >= 1) {
|
|
877
907
|
this.logger.info(record.liveArr);
|
|
878
908
|
const liveArr = structuredClone(record.liveArr);
|
|
879
|
-
|
|
880
|
-
return await this.
|
|
909
|
+
await withRetry(async () => {
|
|
910
|
+
return await this.pushMessage(liveArr, /* @__PURE__ */ jsx("message", { children: content }));
|
|
881
911
|
}, 1);
|
|
882
|
-
this.logger.info(`成功推送直播消息:${success.length}条`);
|
|
883
912
|
}
|
|
884
913
|
if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length >= 1) {
|
|
885
914
|
this.logger.info(record.liveGuardBuyArr);
|
|
886
915
|
const liveGuardBuyArr = structuredClone(record.liveGuardBuyArr);
|
|
887
|
-
|
|
888
|
-
return await this.
|
|
916
|
+
await withRetry(async () => {
|
|
917
|
+
return await this.pushMessage(liveGuardBuyArr, /* @__PURE__ */ jsx("message", { children: content }));
|
|
889
918
|
}, 1);
|
|
890
|
-
this.logger.info(`成功推送上舰消息:${success.length}条`);
|
|
891
919
|
}
|
|
892
920
|
if (type === PushType.WordCloudAndLiveSummary) {
|
|
893
921
|
const wordcloudArr = structuredClone(record.wordcloudArr);
|
|
@@ -898,26 +926,23 @@ var ComRegister = class {
|
|
|
898
926
|
if (wordcloudAndLiveSummaryArr.length > 0) {
|
|
899
927
|
this.logger.info("词云和直播总结");
|
|
900
928
|
this.logger.info(wordcloudAndLiveSummaryArr);
|
|
901
|
-
|
|
902
|
-
return await this.
|
|
929
|
+
await withRetry(async () => {
|
|
930
|
+
return await this.pushMessage(wordcloudAndLiveSummaryArr, /* @__PURE__ */ jsxs("message", { children: [content[0], content[1]] }));
|
|
903
931
|
}, 1);
|
|
904
|
-
this.logger.info(`成功推送词云和直播总结消息:${success.length}条`);
|
|
905
932
|
}
|
|
906
933
|
if (wordcloudOnlyArr.length > 0) {
|
|
907
934
|
this.logger.info("词云");
|
|
908
935
|
this.logger.info(wordcloudOnlyArr);
|
|
909
|
-
|
|
910
|
-
return await this.
|
|
936
|
+
await withRetry(async () => {
|
|
937
|
+
return await this.pushMessage(wordcloudOnlyArr, /* @__PURE__ */ jsx("message", { children: content[0] }));
|
|
911
938
|
}, 1);
|
|
912
|
-
this.logger.info(`成功推送词云消息:${success.length}条`);
|
|
913
939
|
}
|
|
914
940
|
if (liveSummaryOnlyArr.length > 0) {
|
|
915
941
|
this.logger.info("直播总结");
|
|
916
942
|
this.logger.info(liveSummaryOnlyArr);
|
|
917
|
-
|
|
918
|
-
return await this.
|
|
943
|
+
await withRetry(async () => {
|
|
944
|
+
return await this.pushMessage(liveSummaryOnlyArr, /* @__PURE__ */ jsx("message", { children: content[1] }));
|
|
919
945
|
}, 1);
|
|
920
|
-
this.logger.info(`成功推送直播总结消息:${success.length}条`);
|
|
921
946
|
}
|
|
922
947
|
}
|
|
923
948
|
}
|
|
@@ -1503,19 +1528,18 @@ var ComRegister = class {
|
|
|
1503
1528
|
}
|
|
1504
1529
|
async subUserInBili(mid) {
|
|
1505
1530
|
const checkGroupIsReady = async () => {
|
|
1506
|
-
|
|
1531
|
+
const allGroupData = await this.ctx["bilibili-notify-api"].getAllGroup();
|
|
1532
|
+
let existFlag = false;
|
|
1533
|
+
for (const group of allGroupData.data) if (group.name === "订阅") {
|
|
1534
|
+
if (this.loginDBData.dynamic_group_id !== group.tagid.toString()) {
|
|
1535
|
+
this.loginDBData.dynamic_group_id = group.tagid.toString();
|
|
1536
|
+
this.ctx.database.set("loginBili", 1, { dynamic_group_id: this.loginDBData.dynamic_group_id });
|
|
1537
|
+
}
|
|
1538
|
+
existFlag = true;
|
|
1539
|
+
}
|
|
1540
|
+
if (!existFlag) {
|
|
1507
1541
|
const createGroupData = await this.ctx["bilibili-notify-api"].createGroup("订阅");
|
|
1508
|
-
if (createGroupData.code
|
|
1509
|
-
const allGroupData = await this.ctx["bilibili-notify-api"].getAllGroup();
|
|
1510
|
-
for (const group of allGroupData.data) if (group.name === "订阅") {
|
|
1511
|
-
this.loginDBData.dynamic_group_id = group.tagid.toString();
|
|
1512
|
-
this.ctx.database.set("loginBili", 1, { dynamic_group_id: this.loginDBData.dynamic_group_id });
|
|
1513
|
-
return {
|
|
1514
|
-
code: 0,
|
|
1515
|
-
message: "分组已存在"
|
|
1516
|
-
};
|
|
1517
|
-
}
|
|
1518
|
-
} else if (createGroupData.code !== 0) return {
|
|
1542
|
+
if (createGroupData.code !== 0) return {
|
|
1519
1543
|
code: createGroupData.code,
|
|
1520
1544
|
message: createGroupData.message
|
|
1521
1545
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-bilibili-notify",
|
|
3
3
|
"description": "Koishi bilibili notify plugin",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.4-alpha.1",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@akokko/blive-message-listener": "^0.5.1",
|
|
32
32
|
"@node-rs/jieba": "^2.0.1",
|
|
33
|
-
"axios": "^1.
|
|
34
|
-
"axios-cookiejar-support": "^6.0.
|
|
33
|
+
"axios": "^1.11.0",
|
|
34
|
+
"axios-cookiejar-support": "^6.0.4",
|
|
35
35
|
"cacheable-lookup": "^7.0.0",
|
|
36
|
-
"cron": "^4.3.
|
|
36
|
+
"cron": "^4.3.2",
|
|
37
37
|
"jsdom": "^26.1.0",
|
|
38
38
|
"luxon": "^3.7.1",
|
|
39
39
|
"md5": "^2.3.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@types/qrcode": "^1.5.5",
|
|
49
49
|
"@types/tough-cookie": "^4.0.5",
|
|
50
50
|
"koishi-plugin-puppeteer": "^3.9.0",
|
|
51
|
-
"tsdown": "^0.
|
|
51
|
+
"tsdown": "^0.13.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"koishi": "^4.18.8"
|
package/readme.md
CHANGED
|
@@ -333,6 +333,9 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
333
333
|
> - ver 3.3.1-rc.3 修复:当订阅用户没有直播且勾选订阅直播间报错;
|
|
334
334
|
> - ver 3.3.1 优化:如果不订阅UP主直播且未填写房间号不再请求用户接口;
|
|
335
335
|
> - ver 3.3.2 修复:当插件因动态报错停止后,应使用指令 `bn start` 启动插件,而不是 `bn restart`;
|
|
336
|
+
> - ver 3.3.3 优化:初始化logger输出; 修复:B站订阅操作bug;
|
|
337
|
+
> - ver 3.3.4-alpha.0 优化:在错误消息向主人帐号推送前会先进行机器人状态判断; 重构:部分重构消息发送逻辑;
|
|
338
|
+
> - ver 3.3.4-alpha.1 修复CI错误;
|
|
336
339
|
|
|
337
340
|
## 交流群
|
|
338
341
|
|