koishi-plugin-bilibili-notify 3.3.4-alpha.2 → 3.3.4-alpha.4
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 +24 -20
- package/lib/index.mjs +23 -19
- package/package.json +5 -5
- package/readme.md +2 -0
package/lib/index.d.mts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -46,7 +46,7 @@ const node_https = __toESM(require("node:https"));
|
|
|
46
46
|
const axios = __toESM(require("axios"));
|
|
47
47
|
const tough_cookie = __toESM(require("tough-cookie"));
|
|
48
48
|
const jsdom = __toESM(require("jsdom"));
|
|
49
|
-
const
|
|
49
|
+
const blive_message_listener = __toESM(require("blive-message-listener"));
|
|
50
50
|
|
|
51
51
|
//#region src/config.ts
|
|
52
52
|
const BAConfigSchema = koishi.Schema.object({
|
|
@@ -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) {
|
|
@@ -4111,7 +4115,7 @@ var BLive = class extends koishi.Service {
|
|
|
4111
4115
|
async startLiveRoomListener(roomId, handler) {
|
|
4112
4116
|
const cookiesStr = await this.ctx["bilibili-notify-api"].getCookiesForHeader();
|
|
4113
4117
|
const mySelfInfo = await this.ctx["bilibili-notify-api"].getMyselfInfo();
|
|
4114
|
-
this.listenerRecord[roomId] = (0,
|
|
4118
|
+
this.listenerRecord[roomId] = (0, blive_message_listener.startListen)(Number.parseInt(roomId), handler, { ws: {
|
|
4115
4119
|
headers: { Cookie: cookiesStr },
|
|
4116
4120
|
uid: mySelfInfo.data.mid
|
|
4117
4121
|
} });
|
package/lib/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import https from "node:https";
|
|
|
17
17
|
import axios from "axios";
|
|
18
18
|
import { Cookie, CookieJar } from "tough-cookie";
|
|
19
19
|
import { JSDOM } from "jsdom";
|
|
20
|
-
import { startListen } from "
|
|
20
|
+
import { startListen } from "blive-message-listener";
|
|
21
21
|
|
|
22
22
|
//#region rolldown:runtime
|
|
23
23
|
var __defProp = Object.defineProperty;
|
|
@@ -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
|
@@ -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-alpha.
|
|
4
|
+
"version": "3.3.4-alpha.4",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"build": "tsdown"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@akokko/blive-message-listener": "^0.5.1",
|
|
32
31
|
"@node-rs/jieba": "^2.0.1",
|
|
33
32
|
"axios": "^1.11.0",
|
|
34
33
|
"axios-cookiejar-support": "^6.0.4",
|
|
34
|
+
"blive-message-listener": "^0.5.1",
|
|
35
35
|
"cacheable-lookup": "^7.0.0",
|
|
36
|
-
"cron": "^4.3.
|
|
36
|
+
"cron": "^4.3.3",
|
|
37
37
|
"jsdom": "^26.1.0",
|
|
38
38
|
"luxon": "^3.7.1",
|
|
39
39
|
"md5": "^2.3.0",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/jsdom": "^21.1.7",
|
|
46
|
-
"@types/luxon": "^3.
|
|
46
|
+
"@types/luxon": "^3.7.1",
|
|
47
47
|
"@types/md5": "^2.3.5",
|
|
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.13.
|
|
51
|
+
"tsdown": "^0.13.3"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"koishi": "^4.18.8"
|
package/readme.md
CHANGED
|
@@ -337,6 +337,8 @@ 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 修复: 相同平台多个机器人可能造成消息重复推送、错误信息推送机器人未初始化完毕推送时会报错;
|
|
341
|
+
> - ver 3.3.4-alpha.4 优化:切换依赖 `blive-message-listener` 回官方版本;
|
|
340
342
|
|
|
341
343
|
## 交流群
|
|
342
344
|
|