koishi-plugin-bilibili-notify 3.3.4-alpha.2 → 3.3.4-alpha.3
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.d.mts +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +22 -18
- package/lib/index.mjs +22 -18
- package/package.json +1 -1
- package/readme.md +1 -0
package/lib/index.d.mts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -751,8 +751,7 @@ var ComRegister = class {
|
|
|
751
751
|
liveAtAll: s.liveAtAll,
|
|
752
752
|
liveGuardBuy: s.liveGuardBuy,
|
|
753
753
|
wordcloud: s.wordcloud,
|
|
754
|
-
liveSummary: s.liveSummary
|
|
755
|
-
bot: null
|
|
754
|
+
liveSummary: s.liveSummary
|
|
756
755
|
}));
|
|
757
756
|
const target = [{
|
|
758
757
|
channelArr,
|
|
@@ -779,7 +778,7 @@ var ComRegister = class {
|
|
|
779
778
|
}
|
|
780
779
|
async sendPrivateMsg(content) {
|
|
781
780
|
if (this.config.master.enable) {
|
|
782
|
-
if (this.privateBot
|
|
781
|
+
if (this.privateBot?.status !== koishi.Universal.Status.ONLINE) {
|
|
783
782
|
this.logger.error(`${this.privateBot.platform} 机器人未初始化完毕,无法进行推送`);
|
|
784
783
|
return;
|
|
785
784
|
}
|
|
@@ -846,13 +845,16 @@ var ComRegister = class {
|
|
|
846
845
|
const liveSummaryArr = [];
|
|
847
846
|
for (const platform of sub.target) for (const channel of platform.channelArr) {
|
|
848
847
|
const target = `${platform.platform}:${channel.channelId}`;
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
848
|
+
const conditions = [
|
|
849
|
+
["dynamic", dynamicArr],
|
|
850
|
+
["dynamicAtAll", dynamicAtAllArr],
|
|
851
|
+
["live", liveArr],
|
|
852
|
+
["liveAtAll", liveAtAllArr],
|
|
853
|
+
["liveGuardBuy", liveGuardBuyArr],
|
|
854
|
+
["wordcloud", wordcloudArr],
|
|
855
|
+
["liveSummary", liveSummaryArr]
|
|
856
|
+
];
|
|
857
|
+
for (const [key, arr] of conditions) if (channel[key]) arr.push(target);
|
|
856
858
|
}
|
|
857
859
|
this.pushArrMap.set(sub.uid, {
|
|
858
860
|
dynamicArr,
|
|
@@ -877,24 +879,26 @@ var ComRegister = class {
|
|
|
877
879
|
for (const platform of Object.keys(t)) {
|
|
878
880
|
const bots = [];
|
|
879
881
|
for (const bot of this.ctx.bots) if (bot.platform === platform) bots.push(bot);
|
|
880
|
-
|
|
881
|
-
|
|
882
|
+
let num = 0;
|
|
883
|
+
const sendMessageByBot = async (channelId, botIndex = 0) => {
|
|
884
|
+
if (bots[botIndex].status !== koishi.Universal.Status.ONLINE) {
|
|
882
885
|
this.logger.error(`${platform} 机器人未初始化完毕,无法进行推送,${retry / 1e3}秒后重试`);
|
|
883
886
|
this.ctx.setTimeout(async () => {
|
|
884
887
|
await this.pushMessage(targets, content, retry * 2);
|
|
885
888
|
}, retry);
|
|
886
889
|
return;
|
|
887
890
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
await bot.sendMessage(channelId, content);
|
|
891
|
+
try {
|
|
892
|
+
await bots[botIndex].sendMessage(channelId, content);
|
|
891
893
|
num++;
|
|
894
|
+
await this.ctx.sleep(500);
|
|
892
895
|
} catch (e) {
|
|
893
896
|
this.logger.error(e);
|
|
894
|
-
if (bots.length > 1)
|
|
897
|
+
if (bots.length > 1) await sendMessageByBot(channelId, botIndex++);
|
|
895
898
|
}
|
|
896
|
-
|
|
897
|
-
|
|
899
|
+
};
|
|
900
|
+
for (const channelId of t[platform]) await sendMessageByBot(channelId);
|
|
901
|
+
this.logger.info(`成功推送消息 ${num} 条`);
|
|
898
902
|
}
|
|
899
903
|
}
|
|
900
904
|
async broadcastToTargets(uid, content, type) {
|
package/lib/index.mjs
CHANGED
|
@@ -732,8 +732,7 @@ var ComRegister = class {
|
|
|
732
732
|
liveAtAll: s.liveAtAll,
|
|
733
733
|
liveGuardBuy: s.liveGuardBuy,
|
|
734
734
|
wordcloud: s.wordcloud,
|
|
735
|
-
liveSummary: s.liveSummary
|
|
736
|
-
bot: null
|
|
735
|
+
liveSummary: s.liveSummary
|
|
737
736
|
}));
|
|
738
737
|
const target = [{
|
|
739
738
|
channelArr,
|
|
@@ -760,7 +759,7 @@ var ComRegister = class {
|
|
|
760
759
|
}
|
|
761
760
|
async sendPrivateMsg(content) {
|
|
762
761
|
if (this.config.master.enable) {
|
|
763
|
-
if (this.privateBot
|
|
762
|
+
if (this.privateBot?.status !== Universal.Status.ONLINE) {
|
|
764
763
|
this.logger.error(`${this.privateBot.platform} 机器人未初始化完毕,无法进行推送`);
|
|
765
764
|
return;
|
|
766
765
|
}
|
|
@@ -827,13 +826,16 @@ var ComRegister = class {
|
|
|
827
826
|
const liveSummaryArr = [];
|
|
828
827
|
for (const platform of sub.target) for (const channel of platform.channelArr) {
|
|
829
828
|
const target = `${platform.platform}:${channel.channelId}`;
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
829
|
+
const conditions = [
|
|
830
|
+
["dynamic", dynamicArr],
|
|
831
|
+
["dynamicAtAll", dynamicAtAllArr],
|
|
832
|
+
["live", liveArr],
|
|
833
|
+
["liveAtAll", liveAtAllArr],
|
|
834
|
+
["liveGuardBuy", liveGuardBuyArr],
|
|
835
|
+
["wordcloud", wordcloudArr],
|
|
836
|
+
["liveSummary", liveSummaryArr]
|
|
837
|
+
];
|
|
838
|
+
for (const [key, arr] of conditions) if (channel[key]) arr.push(target);
|
|
837
839
|
}
|
|
838
840
|
this.pushArrMap.set(sub.uid, {
|
|
839
841
|
dynamicArr,
|
|
@@ -858,24 +860,26 @@ var ComRegister = class {
|
|
|
858
860
|
for (const platform of Object.keys(t)) {
|
|
859
861
|
const bots = [];
|
|
860
862
|
for (const bot of this.ctx.bots) if (bot.platform === platform) bots.push(bot);
|
|
861
|
-
|
|
862
|
-
|
|
863
|
+
let num = 0;
|
|
864
|
+
const sendMessageByBot = async (channelId, botIndex = 0) => {
|
|
865
|
+
if (bots[botIndex].status !== Universal.Status.ONLINE) {
|
|
863
866
|
this.logger.error(`${platform} 机器人未初始化完毕,无法进行推送,${retry / 1e3}秒后重试`);
|
|
864
867
|
this.ctx.setTimeout(async () => {
|
|
865
868
|
await this.pushMessage(targets, content, retry * 2);
|
|
866
869
|
}, retry);
|
|
867
870
|
return;
|
|
868
871
|
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
await bot.sendMessage(channelId, content);
|
|
872
|
+
try {
|
|
873
|
+
await bots[botIndex].sendMessage(channelId, content);
|
|
872
874
|
num++;
|
|
875
|
+
await this.ctx.sleep(500);
|
|
873
876
|
} catch (e) {
|
|
874
877
|
this.logger.error(e);
|
|
875
|
-
if (bots.length > 1)
|
|
878
|
+
if (bots.length > 1) await sendMessageByBot(channelId, botIndex++);
|
|
876
879
|
}
|
|
877
|
-
|
|
878
|
-
|
|
880
|
+
};
|
|
881
|
+
for (const channelId of t[platform]) await sendMessageByBot(channelId);
|
|
882
|
+
this.logger.info(`成功推送消息 ${num} 条`);
|
|
879
883
|
}
|
|
880
884
|
}
|
|
881
885
|
async broadcastToTargets(uid, content, type) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -337,6 +337,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
337
337
|
> - ver 3.3.4-alpha.0 优化:在错误消息向主人帐号推送前会先进行机器人状态判断; 重构:部分重构消息发送逻辑;
|
|
338
338
|
> - ver 3.3.4-alpha.1 修复: CI错误;
|
|
339
339
|
> - ver 3.3.4-alpha.2 修复: 推送消息时发送6000的bug;
|
|
340
|
+
> - ver 3.3.4-alpha.3 修复: 相同平台多个机器人可能造成消息重复推送、错误信息推送机器人未初始化完毕推送时会报错;
|
|
340
341
|
|
|
341
342
|
## 交流群
|
|
342
343
|
|