koishi-plugin-bilibili-notify 3.4.2 → 3.5.0-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.cjs +99 -192
- package/lib/index.d.cts +13 -1
- package/lib/index.d.mts +13 -1
- package/lib/index.mjs +89 -186
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -5,21 +5,30 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (all) => {
|
|
8
|
+
var __export = (all, symbols) => {
|
|
9
9
|
let target = {};
|
|
10
|
-
for (var name$2 in all)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
for (var name$2 in all) {
|
|
11
|
+
__defProp(target, name$2, {
|
|
12
|
+
get: all[name$2],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (symbols) {
|
|
17
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
+
}
|
|
14
19
|
return target;
|
|
15
20
|
};
|
|
16
21
|
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
24
|
+
key = keys[i];
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
26
|
+
__defProp(to, key, {
|
|
27
|
+
get: ((k) => from[k]).bind(null, key),
|
|
28
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
23
32
|
}
|
|
24
33
|
return to;
|
|
25
34
|
};
|
|
@@ -108,7 +117,6 @@ const BAConfigSchema = koishi.Schema.object({
|
|
|
108
117
|
dynamicVideoUrlToBV: koishi.Schema.boolean().default(false).description("如果推送的动态是视频动态,且开启了发送链接选项,开启此选项则会将链接转换为BV号以便其他用途"),
|
|
109
118
|
pushImgsInDynamic: koishi.Schema.boolean().default(false).description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
|
|
110
119
|
live: koishi.Schema.object({}).description("直播推送设置"),
|
|
111
|
-
liveDetectType: koishi.Schema.union([koishi.Schema.const("WS").description("使用WebSocket连接到B站消息服务器进行直播检测,推荐使用"), koishi.Schema.const("API").description("通过轮询API发送请求监测直播状态,此模式理论可无限订阅,但容易产生其他问题,功能没有WS模式全面").experimental()]).role("radio").default("WS").description("直播检测方式,WS为连接到B站消息服务器,API为通过轮询发送请求监测,默认使用WS检测"),
|
|
112
120
|
wordcloudStopWords: koishi.Schema.string().description("词云生成时的停用词,多个停用词请使用英文逗号分隔,例如:哔哩哔哩,弹幕,直播,词云"),
|
|
113
121
|
liveSummary: koishi.Schema.array(String).default([
|
|
114
122
|
"🔍【弹幕情报站】本场直播数据如下:",
|
|
@@ -122,6 +130,12 @@ const BAConfigSchema = koishi.Schema.object({
|
|
|
122
130
|
"🎖️ 特别嘉奖:-un4 & -un5",
|
|
123
131
|
"你们的弹幕,我们都记录在案!🕵️♀️"
|
|
124
132
|
]).role("table").description("自定义直播总结语,开启弹幕词云自动发送。变量解释:-dmc代表总弹幕发送人数,-mdn代表主播粉丝牌子名,-dca代表总弹幕数,-un1到-un5代表弹幕发送条数前五名用户的用户名,-dc1到-dc5代表弹幕发送条数前五名的弹幕发送数量,数组每一行代表换行"),
|
|
133
|
+
customGuardBuyImg: koishi.Schema.intersect([koishi.Schema.object({ enable: koishi.Schema.boolean().default(false).description("是否开启自定义上舰图片功能").experimental() }), koishi.Schema.union([koishi.Schema.object({
|
|
134
|
+
enable: koishi.Schema.const(true).required(),
|
|
135
|
+
captainImgUrl: koishi.Schema.string().default("https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/captain-Bjw5Byb5.png").description("舰长图片链接"),
|
|
136
|
+
supervisorImgUrl: koishi.Schema.string().default("https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/supervisor-u43ElIjU.png").description("提督图片链接"),
|
|
137
|
+
governorImgUrl: koishi.Schema.string().default("https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/governor-DpDXKEdA.png").description("总督图片链接")
|
|
138
|
+
}), koishi.Schema.object({})])]),
|
|
125
139
|
restartPush: koishi.Schema.boolean().default(true).description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
|
|
126
140
|
pushTime: koishi.Schema.number().min(0).max(12).step(.5).default(1).description("设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时"),
|
|
127
141
|
customLiveStart: koishi.Schema.string().default("-name开播啦,当前粉丝数:-follower\\n-link").description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
|
|
@@ -392,7 +406,6 @@ var ComRegister = class ComRegister {
|
|
|
392
406
|
dynamicTimelineManager;
|
|
393
407
|
liveAPIManager;
|
|
394
408
|
liveWSManager;
|
|
395
|
-
liveMsgManager;
|
|
396
409
|
pushArrMap;
|
|
397
410
|
loginDBData;
|
|
398
411
|
privateBot;
|
|
@@ -795,7 +808,6 @@ var ComRegister = class ComRegister {
|
|
|
795
808
|
}
|
|
796
809
|
this.initManagerAfterLoadSub();
|
|
797
810
|
this.checkIfDynamicDetectIsNeeded();
|
|
798
|
-
this.checkIfLiveDetectIsNeeded();
|
|
799
811
|
this.updateSubNotifier();
|
|
800
812
|
this.logger.info("插件初始化完毕!");
|
|
801
813
|
}
|
|
@@ -827,7 +839,6 @@ var ComRegister = class ComRegister {
|
|
|
827
839
|
this.dynamicTimelineManager = /* @__PURE__ */ new Map();
|
|
828
840
|
this.liveAPIManager = /* @__PURE__ */ new Map();
|
|
829
841
|
this.liveWSManager = /* @__PURE__ */ new Map();
|
|
830
|
-
this.liveMsgManager = /* @__PURE__ */ new Map();
|
|
831
842
|
this.pushArrMap = /* @__PURE__ */ new Map();
|
|
832
843
|
}
|
|
833
844
|
configSubsToSubscription(sub) {
|
|
@@ -857,7 +868,8 @@ var ComRegister = class ComRegister {
|
|
|
857
868
|
target,
|
|
858
869
|
customCardStyle: { enable: false },
|
|
859
870
|
customLiveMsg: { enable: false },
|
|
860
|
-
customLiveSummary: { enable: false }
|
|
871
|
+
customLiveSummary: { enable: false },
|
|
872
|
+
customGuardBuyImg: { enable: false }
|
|
861
873
|
};
|
|
862
874
|
});
|
|
863
875
|
return subs;
|
|
@@ -911,19 +923,32 @@ var ComRegister = class ComRegister {
|
|
|
911
923
|
}
|
|
912
924
|
preInitConfig(subs) {
|
|
913
925
|
for (const sub of Object.values(subs)) {
|
|
914
|
-
const liveMsg = {
|
|
915
|
-
customLiveStart: this.config.customLiveStart || "",
|
|
916
|
-
customLive: this.config.customLive || "",
|
|
917
|
-
customLiveEnd: this.config.customLiveEnd || "",
|
|
918
|
-
liveSummary: this.config.liveSummary.join("\n") || ""
|
|
919
|
-
};
|
|
920
926
|
if (sub.customLiveMsg.enable) {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
927
|
+
if (!sub.customLiveMsg.customLiveStart.trim()) sub.customLiveMsg.customLiveStart = this.config.customLiveStart;
|
|
928
|
+
if (!sub.customLiveMsg.customLiveEnd.trim()) sub.customLiveMsg.customLiveEnd = this.config.customLiveEnd;
|
|
929
|
+
if (!sub.customLiveMsg.customLive.trim()) sub.customLiveMsg.customLive = this.config.customLive;
|
|
930
|
+
} else {
|
|
931
|
+
sub.customLiveMsg.enable = false;
|
|
932
|
+
sub.customLiveMsg.customLiveStart = this.config.customLiveStart;
|
|
933
|
+
sub.customLiveMsg.customLiveEnd = this.config.customLiveEnd;
|
|
934
|
+
sub.customLiveMsg.customLive = this.config.customLive;
|
|
935
|
+
}
|
|
936
|
+
if (sub.customGuardBuyImg.enable) {
|
|
937
|
+
if (!sub.customGuardBuyImg.captainImgUrl.trim()) sub.customGuardBuyImg.captainImgUrl = this.config.customGuardBuyImg.captainImgUrl;
|
|
938
|
+
if (!sub.customGuardBuyImg.supervisorImgUrl.trim()) sub.customGuardBuyImg.supervisorImgUrl = this.config.customGuardBuyImg.supervisorImgUrl;
|
|
939
|
+
if (!sub.customGuardBuyImg.governorImgUrl.trim()) sub.customGuardBuyImg.governorImgUrl = this.config.customGuardBuyImg.governorImgUrl;
|
|
940
|
+
} else if (this.config.customGuardBuyImg.enable) {
|
|
941
|
+
sub.customGuardBuyImg.enable = true;
|
|
942
|
+
sub.customGuardBuyImg.captainImgUrl = this.config.customGuardBuyImg.captainImgUrl;
|
|
943
|
+
sub.customGuardBuyImg.supervisorImgUrl = this.config.customGuardBuyImg.supervisorImgUrl;
|
|
944
|
+
sub.customGuardBuyImg.governorImgUrl = this.config.customGuardBuyImg.governorImgUrl;
|
|
945
|
+
}
|
|
946
|
+
if (sub.customLiveSummary.enable) {
|
|
947
|
+
if (!sub.customLiveSummary.liveSummary.trim()) sub.customLiveSummary.liveSummary = this.config.liveSummary.join("\n");
|
|
948
|
+
} else {
|
|
949
|
+
sub.customLiveSummary.enable = false;
|
|
950
|
+
sub.customLiveSummary.liveSummary = this.config.liveSummary.join("\n");
|
|
924
951
|
}
|
|
925
|
-
if (sub.customLiveSummary.enable) liveMsg.liveSummary = sub.customLiveSummary.liveSummary || this.config.liveSummary.join("\n");
|
|
926
|
-
this.liveMsgManager.set(sub.uid, liveMsg);
|
|
927
952
|
const dynamicArr = [];
|
|
928
953
|
const dynamicAtAllArr = [];
|
|
929
954
|
const liveArr = [];
|
|
@@ -1328,7 +1353,6 @@ var ComRegister = class ComRegister {
|
|
|
1328
1353
|
let liveRoomInfo;
|
|
1329
1354
|
let masterInfo;
|
|
1330
1355
|
const liveData = { likedNum: "0" };
|
|
1331
|
-
const liveMsgObj = this.liveMsgManager.get(sub.uid);
|
|
1332
1356
|
const sendDanmakuWordCloudAndLiveSummary = async (customLiveSummary) => {
|
|
1333
1357
|
this.logger.info("开始制作弹幕词云");
|
|
1334
1358
|
this.logger.info("正在获取前90热词");
|
|
@@ -1405,7 +1429,7 @@ var ComRegister = class ComRegister {
|
|
|
1405
1429
|
liveTime = liveRoomInfo.live_time;
|
|
1406
1430
|
const watched = liveData.watchedNum || "暂未获取到";
|
|
1407
1431
|
liveData.watchedNum = watched;
|
|
1408
|
-
const liveMsg =
|
|
1432
|
+
const liveMsg = sub.customLiveMsg.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1409
1433
|
await this.sendLiveNotifyCard(LiveType.LiveBroadcast, liveData, {
|
|
1410
1434
|
liveRoomInfo,
|
|
1411
1435
|
masterInfo,
|
|
@@ -1464,24 +1488,35 @@ var ComRegister = class ComRegister {
|
|
|
1464
1488
|
liveData.likedNum = body.count.toString();
|
|
1465
1489
|
},
|
|
1466
1490
|
onGuardBuy: async ({ body }) => {
|
|
1467
|
-
const
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1491
|
+
const msg = await (async () => {
|
|
1492
|
+
if (sub.customGuardBuyImg.enable) {
|
|
1493
|
+
const guardImg = {
|
|
1494
|
+
[blive_message_listener.GuardLevel.Jianzhang]: sub.customGuardBuyImg.captainImgUrl,
|
|
1495
|
+
[blive_message_listener.GuardLevel.Tidu]: sub.customGuardBuyImg.supervisorImgUrl,
|
|
1496
|
+
[blive_message_listener.GuardLevel.Zongdu]: sub.customGuardBuyImg.governorImgUrl
|
|
1497
|
+
};
|
|
1498
|
+
return (0, koishi.h)("message", [koishi.h.image(guardImg[body.guard_level]), koishi.h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`)]);
|
|
1499
|
+
} else {
|
|
1500
|
+
const guardImg = ComRegister.GUARD_LEVEL_IMG[body.guard_level];
|
|
1501
|
+
const data = await this.ctx["bilibili-notify-api"].getUserInfoInLive(body.user.uid.toString(), sub.uid);
|
|
1502
|
+
if (data.code !== 0) {
|
|
1503
|
+
const content = (0, koishi.h)("message", [koishi.h.image(guardImg), koishi.h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`)]);
|
|
1504
|
+
return this.broadcastToTargets(sub.uid, content, PushType.LiveGuardBuy);
|
|
1505
|
+
}
|
|
1506
|
+
const userInfo = data.data;
|
|
1507
|
+
const buffer = await this.ctx["bilibili-notify-generate-img"].generateBoardingImg(guardImg, {
|
|
1508
|
+
guardLevel: body.guard_level,
|
|
1509
|
+
uname: userInfo.uname,
|
|
1510
|
+
face: userInfo.face,
|
|
1511
|
+
isAdmin: userInfo.is_admin
|
|
1512
|
+
}, {
|
|
1513
|
+
masterName: masterInfo.username,
|
|
1514
|
+
masterAvatarUrl: masterInfo.userface
|
|
1515
|
+
});
|
|
1516
|
+
return koishi.h.image(buffer, "image/jpeg");
|
|
1517
|
+
}
|
|
1518
|
+
})();
|
|
1519
|
+
this.broadcastToTargets(sub.uid, msg, PushType.LiveGuardBuy);
|
|
1485
1520
|
},
|
|
1486
1521
|
onLiveStart: async () => {
|
|
1487
1522
|
const now = Date.now();
|
|
@@ -1505,7 +1540,7 @@ var ComRegister = class ComRegister {
|
|
|
1505
1540
|
const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
|
|
1506
1541
|
const followerNum = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
|
|
1507
1542
|
liveData.fansNum = followerNum;
|
|
1508
|
-
const liveStartMsg =
|
|
1543
|
+
const liveStartMsg = sub.customLiveMsg.customLiveStart.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower", followerNum).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1509
1544
|
await this.sendLiveNotifyCard(LiveType.StartBroadcasting, liveData, {
|
|
1510
1545
|
liveRoomInfo,
|
|
1511
1546
|
masterInfo,
|
|
@@ -1542,7 +1577,7 @@ var ComRegister = class ComRegister {
|
|
|
1542
1577
|
return liveFollowerChangeNum <= -1e4 ? `${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1543
1578
|
})();
|
|
1544
1579
|
liveData.fansChanged = followerChange;
|
|
1545
|
-
const liveEndMsg =
|
|
1580
|
+
const liveEndMsg = sub.customLiveMsg.customLiveEnd.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
|
|
1546
1581
|
await this.sendLiveNotifyCard(LiveType.StopBroadcast, liveData, {
|
|
1547
1582
|
liveRoomInfo,
|
|
1548
1583
|
masterInfo,
|
|
@@ -1553,7 +1588,7 @@ var ComRegister = class ComRegister {
|
|
|
1553
1588
|
pushAtTimeTimer = null;
|
|
1554
1589
|
this.liveWSManager.delete(sub.roomid);
|
|
1555
1590
|
}
|
|
1556
|
-
await sendDanmakuWordCloudAndLiveSummary(
|
|
1591
|
+
await sendDanmakuWordCloudAndLiveSummary(sub.customLiveSummary.liveSummary);
|
|
1557
1592
|
}
|
|
1558
1593
|
});
|
|
1559
1594
|
if (!await useLiveRoomInfo(LiveType.FirstLiveBroadcast) && !await useMasterInfo(LiveType.FirstLiveBroadcast)) return this.sendPrivateMsg("获取直播间信息失败,启动直播间弹幕检测失败!");
|
|
@@ -1562,7 +1597,7 @@ var ComRegister = class ComRegister {
|
|
|
1562
1597
|
liveTime = liveRoomInfo.live_time;
|
|
1563
1598
|
const watched = liveData.watchedNum || "暂未获取到";
|
|
1564
1599
|
liveData.watchedNum = watched;
|
|
1565
|
-
const liveMsg =
|
|
1600
|
+
const liveMsg = sub.customLiveMsg.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1566
1601
|
if (this.config.restartPush) this.sendLiveNotifyCard(LiveType.LiveBroadcast, liveData, {
|
|
1567
1602
|
liveRoomInfo,
|
|
1568
1603
|
masterInfo,
|
|
@@ -1575,133 +1610,6 @@ var ComRegister = class ComRegister {
|
|
|
1575
1610
|
liveStatus = true;
|
|
1576
1611
|
}
|
|
1577
1612
|
}
|
|
1578
|
-
async liveDetectWithAPI() {
|
|
1579
|
-
const useMasterAndLiveRoomInfo = async (liveType, LiveAPIStatus) => {
|
|
1580
|
-
let flag = true;
|
|
1581
|
-
LiveAPIStatus.liveRoomInfo = await this.getLiveRoomInfo(LiveAPIStatus.roomId).catch(() => {
|
|
1582
|
-
flag = false;
|
|
1583
|
-
return null;
|
|
1584
|
-
});
|
|
1585
|
-
if (!flag || !LiveAPIStatus.liveRoomInfo?.uid) {
|
|
1586
|
-
flag = false;
|
|
1587
|
-
return flag;
|
|
1588
|
-
}
|
|
1589
|
-
LiveAPIStatus.masterInfo = await this.getMasterInfo(LiveAPIStatus.liveRoomInfo.uid, LiveAPIStatus.masterInfo, liveType).catch(() => {
|
|
1590
|
-
flag = false;
|
|
1591
|
-
return null;
|
|
1592
|
-
});
|
|
1593
|
-
return flag;
|
|
1594
|
-
};
|
|
1595
|
-
const uids = [];
|
|
1596
|
-
for (const [uid] of this.liveAPIManager.entries()) uids.push(uid);
|
|
1597
|
-
const useLiveInfo = async () => {
|
|
1598
|
-
const { data: data$1 } = await withRetry(async () => await this.ctx["bilibili-notify-api"].getLiveRoomInfoByUids(uids), 3).catch(async () => {});
|
|
1599
|
-
if (!data$1) {
|
|
1600
|
-
await this.sendPrivateMsgAndStopService();
|
|
1601
|
-
return;
|
|
1602
|
-
}
|
|
1603
|
-
return data$1;
|
|
1604
|
-
};
|
|
1605
|
-
const data = await useLiveInfo();
|
|
1606
|
-
for (const item of Object.values(data)) {
|
|
1607
|
-
const uid = item.uid.toString();
|
|
1608
|
-
const LiveAPIStatus = this.liveAPIManager.get(uid);
|
|
1609
|
-
const liveMsgObj = this.liveMsgManager.get(uid);
|
|
1610
|
-
const sub = this.subManager.get(uid);
|
|
1611
|
-
if (item.live_status === 1) {
|
|
1612
|
-
LiveAPIStatus.live = true;
|
|
1613
|
-
await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast, LiveAPIStatus);
|
|
1614
|
-
if (!LiveAPIStatus.liveStartTimeInit) {
|
|
1615
|
-
LiveAPIStatus.liveStartTime = LiveAPIStatus.liveRoomInfo.live_time;
|
|
1616
|
-
LiveAPIStatus.liveStartTimeInit = true;
|
|
1617
|
-
}
|
|
1618
|
-
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}`);
|
|
1619
|
-
await this.sendLiveNotifyCard(LiveType.LiveBroadcast, { watchedNum: "API" }, {
|
|
1620
|
-
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1621
|
-
masterInfo: LiveAPIStatus.masterInfo,
|
|
1622
|
-
cardStyle: sub.customCardStyle
|
|
1623
|
-
}, uid, liveMsg);
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
const handler = async () => {
|
|
1627
|
-
const data$1 = await useLiveInfo();
|
|
1628
|
-
for (const item of Object.values(data$1)) {
|
|
1629
|
-
const uid = item.uid.toString();
|
|
1630
|
-
const LiveAPIStatus = this.liveAPIManager.get(uid);
|
|
1631
|
-
const liveMsgObj = this.liveMsgManager.get(uid);
|
|
1632
|
-
const sub = this.subManager.get(uid);
|
|
1633
|
-
if (!sub) return;
|
|
1634
|
-
switch (item.live_status) {
|
|
1635
|
-
case 0:
|
|
1636
|
-
case 2:
|
|
1637
|
-
if (LiveAPIStatus.live === true) {
|
|
1638
|
-
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, LiveAPIStatus)) {
|
|
1639
|
-
await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
|
|
1640
|
-
return await this.sendPrivateMsgAndStopService();
|
|
1641
|
-
}
|
|
1642
|
-
if (LiveAPIStatus.liveStartTimeInit) {
|
|
1643
|
-
LiveAPIStatus.liveRoomInfo.live_time = LiveAPIStatus.liveStartTime;
|
|
1644
|
-
LiveAPIStatus.liveStartTimeInit = false;
|
|
1645
|
-
}
|
|
1646
|
-
const followerChange = (() => {
|
|
1647
|
-
const liveFollowerChangeNum = LiveAPIStatus.masterInfo.liveFollowerChange;
|
|
1648
|
-
if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
|
|
1649
|
-
return liveFollowerChangeNum <= -1e4 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1650
|
-
})();
|
|
1651
|
-
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");
|
|
1652
|
-
await this.sendLiveNotifyCard(LiveType.StopBroadcast, { fansChanged: followerChange }, {
|
|
1653
|
-
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1654
|
-
masterInfo: LiveAPIStatus.masterInfo,
|
|
1655
|
-
cardStyle: sub.customCardStyle
|
|
1656
|
-
}, uid, liveEndMsg);
|
|
1657
|
-
LiveAPIStatus.live = false;
|
|
1658
|
-
}
|
|
1659
|
-
break;
|
|
1660
|
-
case 1:
|
|
1661
|
-
if (LiveAPIStatus.live === false) {
|
|
1662
|
-
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, LiveAPIStatus)) {
|
|
1663
|
-
await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
|
|
1664
|
-
return await this.sendPrivateMsgAndStopService();
|
|
1665
|
-
}
|
|
1666
|
-
LiveAPIStatus.liveStartTime = LiveAPIStatus.liveRoomInfo.live_time;
|
|
1667
|
-
LiveAPIStatus.liveStartTimeInit = true;
|
|
1668
|
-
const followerNum = LiveAPIStatus.masterInfo.liveOpenFollowerNum >= 1e4 ? `${(LiveAPIStatus.masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : LiveAPIStatus.masterInfo.liveOpenFollowerNum.toString();
|
|
1669
|
-
const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", LiveAPIStatus.masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(LiveAPIStatus.liveStartTime)).replace("-follower", followerNum).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${LiveAPIStatus.liveRoomInfo.short_id === 0 ? LiveAPIStatus.liveRoomInfo.room_id : LiveAPIStatus.liveRoomInfo.short_id}`);
|
|
1670
|
-
await this.sendLiveNotifyCard(LiveType.StartBroadcasting, { fansNum: followerNum }, {
|
|
1671
|
-
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1672
|
-
masterInfo: LiveAPIStatus.masterInfo,
|
|
1673
|
-
cardStyle: sub.customCardStyle
|
|
1674
|
-
}, uid, liveStartMsg);
|
|
1675
|
-
LiveAPIStatus.live = true;
|
|
1676
|
-
}
|
|
1677
|
-
if (LiveAPIStatus.live === true) {
|
|
1678
|
-
if (LiveAPIStatus.push < this.config.pushTime * 60 * 60 / 30) {
|
|
1679
|
-
LiveAPIStatus.push++;
|
|
1680
|
-
break;
|
|
1681
|
-
}
|
|
1682
|
-
if (!await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast, LiveAPIStatus)) {
|
|
1683
|
-
await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
|
|
1684
|
-
return await this.sendPrivateMsgAndStopService();
|
|
1685
|
-
}
|
|
1686
|
-
if (!LiveAPIStatus.liveStartTimeInit) {
|
|
1687
|
-
LiveAPIStatus.liveStartTime = LiveAPIStatus.liveRoomInfo.live_time;
|
|
1688
|
-
LiveAPIStatus.liveStartTimeInit = true;
|
|
1689
|
-
}
|
|
1690
|
-
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}`);
|
|
1691
|
-
await this.sendLiveNotifyCard(LiveType.LiveBroadcast, { watchedNum: "API" }, {
|
|
1692
|
-
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1693
|
-
masterInfo: LiveAPIStatus.masterInfo,
|
|
1694
|
-
cardStyle: sub.customCardStyle
|
|
1695
|
-
}, uid, liveMsg);
|
|
1696
|
-
LiveAPIStatus.push = 0;
|
|
1697
|
-
}
|
|
1698
|
-
break;
|
|
1699
|
-
default: break;
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
};
|
|
1703
|
-
return withLock(handler);
|
|
1704
|
-
}
|
|
1705
1613
|
subShow() {
|
|
1706
1614
|
let table = "";
|
|
1707
1615
|
for (const [uid, sub] of this.subManager) table += `UID:${uid} ${sub.dynamic ? "已订阅动态" : ""} ${sub.live ? "已订阅直播" : ""}\n`;
|
|
@@ -1920,7 +1828,7 @@ var ComRegister = class ComRegister {
|
|
|
1920
1828
|
}
|
|
1921
1829
|
sub.roomid = userInfoData.live_room?.roomid;
|
|
1922
1830
|
}
|
|
1923
|
-
if (sub.live && sub.roomid
|
|
1831
|
+
if (sub.live && sub.roomid) await this.liveDetectWithListener(sub);
|
|
1924
1832
|
this.logger.info(`UID:${sub.uid} 订阅加载完毕!`);
|
|
1925
1833
|
if (sub !== Object.values(subs).pop()) {
|
|
1926
1834
|
const randomDelay = Math.floor(Math.random() * 3) + 1;
|
|
@@ -1936,21 +1844,11 @@ var ComRegister = class ComRegister {
|
|
|
1936
1844
|
checkIfDynamicDetectIsNeeded() {
|
|
1937
1845
|
if (this.dynamicTimelineManager.size > 0) this.enableDynamicDetect();
|
|
1938
1846
|
}
|
|
1939
|
-
checkIfLiveDetectIsNeeded() {
|
|
1940
|
-
if (this.config.liveDetectType === "API") {
|
|
1941
|
-
if (this.liveAPIManager.size > 0) this.enableLiveDetect();
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
1847
|
enableDynamicDetect() {
|
|
1945
1848
|
this.dynamicJob = new cron.CronJob(this.config.dynamicCron, this.config.dynamicDebugMode ? this.debug_dynamicDetect() : this.dynamicDetect());
|
|
1946
1849
|
this.logger.info("动态监测已开启");
|
|
1947
1850
|
this.dynamicJob.start();
|
|
1948
1851
|
}
|
|
1949
|
-
async enableLiveDetect() {
|
|
1950
|
-
this.liveAPIJob = new cron.CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
|
|
1951
|
-
this.logger.info("直播监测已开启");
|
|
1952
|
-
this.liveAPIJob.start();
|
|
1953
|
-
}
|
|
1954
1852
|
async checkIfIsLogin() {
|
|
1955
1853
|
if ((await this.ctx.database.get("loginBili", 1)).length !== 0) {
|
|
1956
1854
|
if (this.ctx["bilibili-notify-api"].getCookies() !== "[]") return true;
|
|
@@ -1981,7 +1879,6 @@ var ComRegister = class ComRegister {
|
|
|
1981
1879
|
masterAccount: koishi.Schema.string(),
|
|
1982
1880
|
masterAccountGuildId: koishi.Schema.string()
|
|
1983
1881
|
}),
|
|
1984
|
-
liveDetectType: koishi.Schema.string(),
|
|
1985
1882
|
wordcloudStopWords: koishi.Schema.string(),
|
|
1986
1883
|
liveSummary: koishi.Schema.array(String),
|
|
1987
1884
|
restartPush: koishi.Schema.boolean().required(),
|
|
@@ -2007,6 +1904,12 @@ var ComRegister = class ComRegister {
|
|
|
2007
1904
|
baseURL: koishi.Schema.string().default("https://api.siliconflow.cn/v1"),
|
|
2008
1905
|
model: koishi.Schema.string().default("gpt-3.5-turbo"),
|
|
2009
1906
|
persona: koishi.Schema.string()
|
|
1907
|
+
}),
|
|
1908
|
+
customGuardBuyImg: koishi.Schema.object({
|
|
1909
|
+
enable: koishi.Schema.boolean().default(false).description("是否启用自定义舰长购买图片"),
|
|
1910
|
+
captainImgUrl: koishi.Schema.string().description("舰长图片链接"),
|
|
1911
|
+
supervisorImgUrl: koishi.Schema.string().description("提督图片链接"),
|
|
1912
|
+
governorImgUrl: koishi.Schema.string().description("总督图片链接")
|
|
2010
1913
|
})
|
|
2011
1914
|
});
|
|
2012
1915
|
})(ComRegister || (ComRegister = {}));
|
|
@@ -2356,6 +2259,10 @@ var GenerateImg = class GenerateImg extends koishi.Service {
|
|
|
2356
2259
|
}
|
|
2357
2260
|
|
|
2358
2261
|
.accompany span {
|
|
2262
|
+
max-width: 85px;
|
|
2263
|
+
white-space: nowrap;
|
|
2264
|
+
text-overflow: ellipsis;
|
|
2265
|
+
overflow: hidden;
|
|
2359
2266
|
color: white;
|
|
2360
2267
|
font-size: 10px;
|
|
2361
2268
|
font-weight: bold;
|
|
@@ -2392,7 +2299,7 @@ var GenerateImg = class GenerateImg extends koishi.Service {
|
|
|
2392
2299
|
<span>${uname}</span>
|
|
2393
2300
|
</div>
|
|
2394
2301
|
<div class="accompany">
|
|
2395
|
-
<div class="master-avatar"></div><span>${
|
|
2302
|
+
<div class="master-avatar"></div><span>${isAdmin ? "房管" : masterName}</span>
|
|
2396
2303
|
</div>
|
|
2397
2304
|
</div>
|
|
2398
2305
|
</div>
|
|
@@ -4599,13 +4506,13 @@ var ServerManager = class extends koishi.Service {
|
|
|
4599
4506
|
master: globalConfig.master,
|
|
4600
4507
|
wordcloudStopWords: globalConfig.wordcloudStopWords,
|
|
4601
4508
|
liveSummary: globalConfig.liveSummary,
|
|
4602
|
-
liveDetectType: globalConfig.liveDetectType,
|
|
4603
4509
|
restartPush: globalConfig.restartPush,
|
|
4604
4510
|
pushTime: globalConfig.pushTime,
|
|
4605
4511
|
pushImgsInDynamic: globalConfig.pushImgsInDynamic,
|
|
4606
4512
|
customLiveStart: globalConfig.customLiveStart,
|
|
4607
4513
|
customLive: globalConfig.customLive,
|
|
4608
4514
|
customLiveEnd: globalConfig.customLiveEnd,
|
|
4515
|
+
customGuardBuyImg: globalConfig.customGuardBuyImg,
|
|
4609
4516
|
dynamicUrl: globalConfig.dynamicUrl,
|
|
4610
4517
|
dynamicCron: globalConfig.dynamicCron,
|
|
4611
4518
|
dynamicVideoUrlToBV: globalConfig.dynamicVideoUrlToBV,
|
package/lib/index.d.cts
CHANGED
|
@@ -36,9 +36,14 @@ interface BAConfig {
|
|
|
36
36
|
dynamicVideoUrlToBV: boolean;
|
|
37
37
|
pushImgsInDynamic: boolean;
|
|
38
38
|
live: {};
|
|
39
|
-
liveDetectType: "WS" | "API";
|
|
40
39
|
wordcloudStopWords: string;
|
|
41
40
|
liveSummary: Array<string>;
|
|
41
|
+
customGuardBuyImg: {
|
|
42
|
+
enable: boolean;
|
|
43
|
+
captainImgUrl?: string;
|
|
44
|
+
supervisorImgUrl?: string;
|
|
45
|
+
governorImgUrl?: string;
|
|
46
|
+
};
|
|
42
47
|
restartPush: boolean;
|
|
43
48
|
pushTime: number;
|
|
44
49
|
customLiveStart: string;
|
|
@@ -90,6 +95,12 @@ type CustomLiveMsg = {
|
|
|
90
95
|
customLive?: string;
|
|
91
96
|
customLiveEnd?: string;
|
|
92
97
|
};
|
|
98
|
+
type CustomGuardBuyImg = {
|
|
99
|
+
enable: boolean;
|
|
100
|
+
captainImgUrl?: string;
|
|
101
|
+
supervisorImgUrl?: string;
|
|
102
|
+
governorImgUrl?: string;
|
|
103
|
+
};
|
|
93
104
|
type CustomLiveSummary = {
|
|
94
105
|
enable: boolean;
|
|
95
106
|
liveSummary?: string;
|
|
@@ -104,6 +115,7 @@ type Subscription = {
|
|
|
104
115
|
customCardStyle: CustomCardStyle;
|
|
105
116
|
customLiveMsg: CustomLiveMsg;
|
|
106
117
|
customLiveSummary: CustomLiveSummary;
|
|
118
|
+
customGuardBuyImg: CustomGuardBuyImg;
|
|
107
119
|
};
|
|
108
120
|
type Subscriptions = Record<string, Subscription>;
|
|
109
121
|
//#endregion
|
package/lib/index.d.mts
CHANGED
|
@@ -36,9 +36,14 @@ interface BAConfig {
|
|
|
36
36
|
dynamicVideoUrlToBV: boolean;
|
|
37
37
|
pushImgsInDynamic: boolean;
|
|
38
38
|
live: {};
|
|
39
|
-
liveDetectType: "WS" | "API";
|
|
40
39
|
wordcloudStopWords: string;
|
|
41
40
|
liveSummary: Array<string>;
|
|
41
|
+
customGuardBuyImg: {
|
|
42
|
+
enable: boolean;
|
|
43
|
+
captainImgUrl?: string;
|
|
44
|
+
supervisorImgUrl?: string;
|
|
45
|
+
governorImgUrl?: string;
|
|
46
|
+
};
|
|
42
47
|
restartPush: boolean;
|
|
43
48
|
pushTime: number;
|
|
44
49
|
customLiveStart: string;
|
|
@@ -90,6 +95,12 @@ type CustomLiveMsg = {
|
|
|
90
95
|
customLive?: string;
|
|
91
96
|
customLiveEnd?: string;
|
|
92
97
|
};
|
|
98
|
+
type CustomGuardBuyImg = {
|
|
99
|
+
enable: boolean;
|
|
100
|
+
captainImgUrl?: string;
|
|
101
|
+
supervisorImgUrl?: string;
|
|
102
|
+
governorImgUrl?: string;
|
|
103
|
+
};
|
|
93
104
|
type CustomLiveSummary = {
|
|
94
105
|
enable: boolean;
|
|
95
106
|
liveSummary?: string;
|
|
@@ -104,6 +115,7 @@ type Subscription = {
|
|
|
104
115
|
customCardStyle: CustomCardStyle;
|
|
105
116
|
customLiveMsg: CustomLiveMsg;
|
|
106
117
|
customLiveSummary: CustomLiveSummary;
|
|
118
|
+
customGuardBuyImg: CustomGuardBuyImg;
|
|
107
119
|
};
|
|
108
120
|
type Subscriptions = Record<string, Subscription>;
|
|
109
121
|
//#endregion
|
package/lib/index.mjs
CHANGED
|
@@ -22,12 +22,17 @@ import OpenAI from "openai";
|
|
|
22
22
|
|
|
23
23
|
//#region rolldown:runtime
|
|
24
24
|
var __defProp = Object.defineProperty;
|
|
25
|
-
var __export = (all) => {
|
|
25
|
+
var __export = (all, symbols) => {
|
|
26
26
|
let target = {};
|
|
27
|
-
for (var name$2 in all)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
for (var name$2 in all) {
|
|
28
|
+
__defProp(target, name$2, {
|
|
29
|
+
get: all[name$2],
|
|
30
|
+
enumerable: true
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (symbols) {
|
|
34
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
35
|
+
}
|
|
31
36
|
return target;
|
|
32
37
|
};
|
|
33
38
|
|
|
@@ -83,7 +88,6 @@ const BAConfigSchema = Schema.object({
|
|
|
83
88
|
dynamicVideoUrlToBV: Schema.boolean().default(false).description("如果推送的动态是视频动态,且开启了发送链接选项,开启此选项则会将链接转换为BV号以便其他用途"),
|
|
84
89
|
pushImgsInDynamic: Schema.boolean().default(false).description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
|
|
85
90
|
live: Schema.object({}).description("直播推送设置"),
|
|
86
|
-
liveDetectType: Schema.union([Schema.const("WS").description("使用WebSocket连接到B站消息服务器进行直播检测,推荐使用"), Schema.const("API").description("通过轮询API发送请求监测直播状态,此模式理论可无限订阅,但容易产生其他问题,功能没有WS模式全面").experimental()]).role("radio").default("WS").description("直播检测方式,WS为连接到B站消息服务器,API为通过轮询发送请求监测,默认使用WS检测"),
|
|
87
91
|
wordcloudStopWords: Schema.string().description("词云生成时的停用词,多个停用词请使用英文逗号分隔,例如:哔哩哔哩,弹幕,直播,词云"),
|
|
88
92
|
liveSummary: Schema.array(String).default([
|
|
89
93
|
"🔍【弹幕情报站】本场直播数据如下:",
|
|
@@ -97,6 +101,12 @@ const BAConfigSchema = Schema.object({
|
|
|
97
101
|
"🎖️ 特别嘉奖:-un4 & -un5",
|
|
98
102
|
"你们的弹幕,我们都记录在案!🕵️♀️"
|
|
99
103
|
]).role("table").description("自定义直播总结语,开启弹幕词云自动发送。变量解释:-dmc代表总弹幕发送人数,-mdn代表主播粉丝牌子名,-dca代表总弹幕数,-un1到-un5代表弹幕发送条数前五名用户的用户名,-dc1到-dc5代表弹幕发送条数前五名的弹幕发送数量,数组每一行代表换行"),
|
|
104
|
+
customGuardBuyImg: Schema.intersect([Schema.object({ enable: Schema.boolean().default(false).description("是否开启自定义上舰图片功能").experimental() }), Schema.union([Schema.object({
|
|
105
|
+
enable: Schema.const(true).required(),
|
|
106
|
+
captainImgUrl: Schema.string().default("https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/captain-Bjw5Byb5.png").description("舰长图片链接"),
|
|
107
|
+
supervisorImgUrl: Schema.string().default("https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/supervisor-u43ElIjU.png").description("提督图片链接"),
|
|
108
|
+
governorImgUrl: Schema.string().default("https://s1.hdslb.com/bfs/static/blive/live-pay-mono/relation/relation/assets/governor-DpDXKEdA.png").description("总督图片链接")
|
|
109
|
+
}), Schema.object({})])]),
|
|
100
110
|
restartPush: Schema.boolean().default(true).description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
|
|
101
111
|
pushTime: Schema.number().min(0).max(12).step(.5).default(1).description("设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时"),
|
|
102
112
|
customLiveStart: Schema.string().default("-name开播啦,当前粉丝数:-follower\\n-link").description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
|
|
@@ -367,7 +377,6 @@ var ComRegister = class ComRegister {
|
|
|
367
377
|
dynamicTimelineManager;
|
|
368
378
|
liveAPIManager;
|
|
369
379
|
liveWSManager;
|
|
370
|
-
liveMsgManager;
|
|
371
380
|
pushArrMap;
|
|
372
381
|
loginDBData;
|
|
373
382
|
privateBot;
|
|
@@ -770,7 +779,6 @@ var ComRegister = class ComRegister {
|
|
|
770
779
|
}
|
|
771
780
|
this.initManagerAfterLoadSub();
|
|
772
781
|
this.checkIfDynamicDetectIsNeeded();
|
|
773
|
-
this.checkIfLiveDetectIsNeeded();
|
|
774
782
|
this.updateSubNotifier();
|
|
775
783
|
this.logger.info("插件初始化完毕!");
|
|
776
784
|
}
|
|
@@ -802,7 +810,6 @@ var ComRegister = class ComRegister {
|
|
|
802
810
|
this.dynamicTimelineManager = /* @__PURE__ */ new Map();
|
|
803
811
|
this.liveAPIManager = /* @__PURE__ */ new Map();
|
|
804
812
|
this.liveWSManager = /* @__PURE__ */ new Map();
|
|
805
|
-
this.liveMsgManager = /* @__PURE__ */ new Map();
|
|
806
813
|
this.pushArrMap = /* @__PURE__ */ new Map();
|
|
807
814
|
}
|
|
808
815
|
configSubsToSubscription(sub) {
|
|
@@ -832,7 +839,8 @@ var ComRegister = class ComRegister {
|
|
|
832
839
|
target,
|
|
833
840
|
customCardStyle: { enable: false },
|
|
834
841
|
customLiveMsg: { enable: false },
|
|
835
|
-
customLiveSummary: { enable: false }
|
|
842
|
+
customLiveSummary: { enable: false },
|
|
843
|
+
customGuardBuyImg: { enable: false }
|
|
836
844
|
};
|
|
837
845
|
});
|
|
838
846
|
return subs;
|
|
@@ -886,19 +894,32 @@ var ComRegister = class ComRegister {
|
|
|
886
894
|
}
|
|
887
895
|
preInitConfig(subs) {
|
|
888
896
|
for (const sub of Object.values(subs)) {
|
|
889
|
-
const liveMsg = {
|
|
890
|
-
customLiveStart: this.config.customLiveStart || "",
|
|
891
|
-
customLive: this.config.customLive || "",
|
|
892
|
-
customLiveEnd: this.config.customLiveEnd || "",
|
|
893
|
-
liveSummary: this.config.liveSummary.join("\n") || ""
|
|
894
|
-
};
|
|
895
897
|
if (sub.customLiveMsg.enable) {
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
898
|
+
if (!sub.customLiveMsg.customLiveStart.trim()) sub.customLiveMsg.customLiveStart = this.config.customLiveStart;
|
|
899
|
+
if (!sub.customLiveMsg.customLiveEnd.trim()) sub.customLiveMsg.customLiveEnd = this.config.customLiveEnd;
|
|
900
|
+
if (!sub.customLiveMsg.customLive.trim()) sub.customLiveMsg.customLive = this.config.customLive;
|
|
901
|
+
} else {
|
|
902
|
+
sub.customLiveMsg.enable = false;
|
|
903
|
+
sub.customLiveMsg.customLiveStart = this.config.customLiveStart;
|
|
904
|
+
sub.customLiveMsg.customLiveEnd = this.config.customLiveEnd;
|
|
905
|
+
sub.customLiveMsg.customLive = this.config.customLive;
|
|
906
|
+
}
|
|
907
|
+
if (sub.customGuardBuyImg.enable) {
|
|
908
|
+
if (!sub.customGuardBuyImg.captainImgUrl.trim()) sub.customGuardBuyImg.captainImgUrl = this.config.customGuardBuyImg.captainImgUrl;
|
|
909
|
+
if (!sub.customGuardBuyImg.supervisorImgUrl.trim()) sub.customGuardBuyImg.supervisorImgUrl = this.config.customGuardBuyImg.supervisorImgUrl;
|
|
910
|
+
if (!sub.customGuardBuyImg.governorImgUrl.trim()) sub.customGuardBuyImg.governorImgUrl = this.config.customGuardBuyImg.governorImgUrl;
|
|
911
|
+
} else if (this.config.customGuardBuyImg.enable) {
|
|
912
|
+
sub.customGuardBuyImg.enable = true;
|
|
913
|
+
sub.customGuardBuyImg.captainImgUrl = this.config.customGuardBuyImg.captainImgUrl;
|
|
914
|
+
sub.customGuardBuyImg.supervisorImgUrl = this.config.customGuardBuyImg.supervisorImgUrl;
|
|
915
|
+
sub.customGuardBuyImg.governorImgUrl = this.config.customGuardBuyImg.governorImgUrl;
|
|
916
|
+
}
|
|
917
|
+
if (sub.customLiveSummary.enable) {
|
|
918
|
+
if (!sub.customLiveSummary.liveSummary.trim()) sub.customLiveSummary.liveSummary = this.config.liveSummary.join("\n");
|
|
919
|
+
} else {
|
|
920
|
+
sub.customLiveSummary.enable = false;
|
|
921
|
+
sub.customLiveSummary.liveSummary = this.config.liveSummary.join("\n");
|
|
899
922
|
}
|
|
900
|
-
if (sub.customLiveSummary.enable) liveMsg.liveSummary = sub.customLiveSummary.liveSummary || this.config.liveSummary.join("\n");
|
|
901
|
-
this.liveMsgManager.set(sub.uid, liveMsg);
|
|
902
923
|
const dynamicArr = [];
|
|
903
924
|
const dynamicAtAllArr = [];
|
|
904
925
|
const liveArr = [];
|
|
@@ -1303,7 +1324,6 @@ var ComRegister = class ComRegister {
|
|
|
1303
1324
|
let liveRoomInfo;
|
|
1304
1325
|
let masterInfo;
|
|
1305
1326
|
const liveData = { likedNum: "0" };
|
|
1306
|
-
const liveMsgObj = this.liveMsgManager.get(sub.uid);
|
|
1307
1327
|
const sendDanmakuWordCloudAndLiveSummary = async (customLiveSummary) => {
|
|
1308
1328
|
this.logger.info("开始制作弹幕词云");
|
|
1309
1329
|
this.logger.info("正在获取前90热词");
|
|
@@ -1380,7 +1400,7 @@ var ComRegister = class ComRegister {
|
|
|
1380
1400
|
liveTime = liveRoomInfo.live_time;
|
|
1381
1401
|
const watched = liveData.watchedNum || "暂未获取到";
|
|
1382
1402
|
liveData.watchedNum = watched;
|
|
1383
|
-
const liveMsg =
|
|
1403
|
+
const liveMsg = sub.customLiveMsg.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1384
1404
|
await this.sendLiveNotifyCard(LiveType.LiveBroadcast, liveData, {
|
|
1385
1405
|
liveRoomInfo,
|
|
1386
1406
|
masterInfo,
|
|
@@ -1439,24 +1459,35 @@ var ComRegister = class ComRegister {
|
|
|
1439
1459
|
liveData.likedNum = body.count.toString();
|
|
1440
1460
|
},
|
|
1441
1461
|
onGuardBuy: async ({ body }) => {
|
|
1442
|
-
const
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1462
|
+
const msg = await (async () => {
|
|
1463
|
+
if (sub.customGuardBuyImg.enable) {
|
|
1464
|
+
const guardImg = {
|
|
1465
|
+
[GuardLevel.Jianzhang]: sub.customGuardBuyImg.captainImgUrl,
|
|
1466
|
+
[GuardLevel.Tidu]: sub.customGuardBuyImg.supervisorImgUrl,
|
|
1467
|
+
[GuardLevel.Zongdu]: sub.customGuardBuyImg.governorImgUrl
|
|
1468
|
+
};
|
|
1469
|
+
return h("message", [h.image(guardImg[body.guard_level]), h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`)]);
|
|
1470
|
+
} else {
|
|
1471
|
+
const guardImg = ComRegister.GUARD_LEVEL_IMG[body.guard_level];
|
|
1472
|
+
const data = await this.ctx["bilibili-notify-api"].getUserInfoInLive(body.user.uid.toString(), sub.uid);
|
|
1473
|
+
if (data.code !== 0) {
|
|
1474
|
+
const content = h("message", [h.image(guardImg), h.text(`【${masterInfo.username}的直播间】${body.user.uname}加入了大航海(${body.gift_name})`)]);
|
|
1475
|
+
return this.broadcastToTargets(sub.uid, content, PushType.LiveGuardBuy);
|
|
1476
|
+
}
|
|
1477
|
+
const userInfo = data.data;
|
|
1478
|
+
const buffer = await this.ctx["bilibili-notify-generate-img"].generateBoardingImg(guardImg, {
|
|
1479
|
+
guardLevel: body.guard_level,
|
|
1480
|
+
uname: userInfo.uname,
|
|
1481
|
+
face: userInfo.face,
|
|
1482
|
+
isAdmin: userInfo.is_admin
|
|
1483
|
+
}, {
|
|
1484
|
+
masterName: masterInfo.username,
|
|
1485
|
+
masterAvatarUrl: masterInfo.userface
|
|
1486
|
+
});
|
|
1487
|
+
return h.image(buffer, "image/jpeg");
|
|
1488
|
+
}
|
|
1489
|
+
})();
|
|
1490
|
+
this.broadcastToTargets(sub.uid, msg, PushType.LiveGuardBuy);
|
|
1460
1491
|
},
|
|
1461
1492
|
onLiveStart: async () => {
|
|
1462
1493
|
const now = Date.now();
|
|
@@ -1480,7 +1511,7 @@ var ComRegister = class ComRegister {
|
|
|
1480
1511
|
const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
|
|
1481
1512
|
const followerNum = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
|
|
1482
1513
|
liveData.fansNum = followerNum;
|
|
1483
|
-
const liveStartMsg =
|
|
1514
|
+
const liveStartMsg = sub.customLiveMsg.customLiveStart.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower", followerNum).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1484
1515
|
await this.sendLiveNotifyCard(LiveType.StartBroadcasting, liveData, {
|
|
1485
1516
|
liveRoomInfo,
|
|
1486
1517
|
masterInfo,
|
|
@@ -1517,7 +1548,7 @@ var ComRegister = class ComRegister {
|
|
|
1517
1548
|
return liveFollowerChangeNum <= -1e4 ? `${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1518
1549
|
})();
|
|
1519
1550
|
liveData.fansChanged = followerChange;
|
|
1520
|
-
const liveEndMsg =
|
|
1551
|
+
const liveEndMsg = sub.customLiveMsg.customLiveEnd.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
|
|
1521
1552
|
await this.sendLiveNotifyCard(LiveType.StopBroadcast, liveData, {
|
|
1522
1553
|
liveRoomInfo,
|
|
1523
1554
|
masterInfo,
|
|
@@ -1528,7 +1559,7 @@ var ComRegister = class ComRegister {
|
|
|
1528
1559
|
pushAtTimeTimer = null;
|
|
1529
1560
|
this.liveWSManager.delete(sub.roomid);
|
|
1530
1561
|
}
|
|
1531
|
-
await sendDanmakuWordCloudAndLiveSummary(
|
|
1562
|
+
await sendDanmakuWordCloudAndLiveSummary(sub.customLiveSummary.liveSummary);
|
|
1532
1563
|
}
|
|
1533
1564
|
});
|
|
1534
1565
|
if (!await useLiveRoomInfo(LiveType.FirstLiveBroadcast) && !await useMasterInfo(LiveType.FirstLiveBroadcast)) return this.sendPrivateMsg("获取直播间信息失败,启动直播间弹幕检测失败!");
|
|
@@ -1537,7 +1568,7 @@ var ComRegister = class ComRegister {
|
|
|
1537
1568
|
liveTime = liveRoomInfo.live_time;
|
|
1538
1569
|
const watched = liveData.watchedNum || "暂未获取到";
|
|
1539
1570
|
liveData.watchedNum = watched;
|
|
1540
|
-
const liveMsg =
|
|
1571
|
+
const liveMsg = sub.customLiveMsg.customLive.replace("-name", masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime)).replace("-watched", watched).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1541
1572
|
if (this.config.restartPush) this.sendLiveNotifyCard(LiveType.LiveBroadcast, liveData, {
|
|
1542
1573
|
liveRoomInfo,
|
|
1543
1574
|
masterInfo,
|
|
@@ -1550,133 +1581,6 @@ var ComRegister = class ComRegister {
|
|
|
1550
1581
|
liveStatus = true;
|
|
1551
1582
|
}
|
|
1552
1583
|
}
|
|
1553
|
-
async liveDetectWithAPI() {
|
|
1554
|
-
const useMasterAndLiveRoomInfo = async (liveType, LiveAPIStatus) => {
|
|
1555
|
-
let flag = true;
|
|
1556
|
-
LiveAPIStatus.liveRoomInfo = await this.getLiveRoomInfo(LiveAPIStatus.roomId).catch(() => {
|
|
1557
|
-
flag = false;
|
|
1558
|
-
return null;
|
|
1559
|
-
});
|
|
1560
|
-
if (!flag || !LiveAPIStatus.liveRoomInfo?.uid) {
|
|
1561
|
-
flag = false;
|
|
1562
|
-
return flag;
|
|
1563
|
-
}
|
|
1564
|
-
LiveAPIStatus.masterInfo = await this.getMasterInfo(LiveAPIStatus.liveRoomInfo.uid, LiveAPIStatus.masterInfo, liveType).catch(() => {
|
|
1565
|
-
flag = false;
|
|
1566
|
-
return null;
|
|
1567
|
-
});
|
|
1568
|
-
return flag;
|
|
1569
|
-
};
|
|
1570
|
-
const uids = [];
|
|
1571
|
-
for (const [uid] of this.liveAPIManager.entries()) uids.push(uid);
|
|
1572
|
-
const useLiveInfo = async () => {
|
|
1573
|
-
const { data: data$1 } = await withRetry(async () => await this.ctx["bilibili-notify-api"].getLiveRoomInfoByUids(uids), 3).catch(async () => {});
|
|
1574
|
-
if (!data$1) {
|
|
1575
|
-
await this.sendPrivateMsgAndStopService();
|
|
1576
|
-
return;
|
|
1577
|
-
}
|
|
1578
|
-
return data$1;
|
|
1579
|
-
};
|
|
1580
|
-
const data = await useLiveInfo();
|
|
1581
|
-
for (const item of Object.values(data)) {
|
|
1582
|
-
const uid = item.uid.toString();
|
|
1583
|
-
const LiveAPIStatus = this.liveAPIManager.get(uid);
|
|
1584
|
-
const liveMsgObj = this.liveMsgManager.get(uid);
|
|
1585
|
-
const sub = this.subManager.get(uid);
|
|
1586
|
-
if (item.live_status === 1) {
|
|
1587
|
-
LiveAPIStatus.live = true;
|
|
1588
|
-
await useMasterAndLiveRoomInfo(LiveType.FirstLiveBroadcast, LiveAPIStatus);
|
|
1589
|
-
if (!LiveAPIStatus.liveStartTimeInit) {
|
|
1590
|
-
LiveAPIStatus.liveStartTime = LiveAPIStatus.liveRoomInfo.live_time;
|
|
1591
|
-
LiveAPIStatus.liveStartTimeInit = true;
|
|
1592
|
-
}
|
|
1593
|
-
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}`);
|
|
1594
|
-
await this.sendLiveNotifyCard(LiveType.LiveBroadcast, { watchedNum: "API" }, {
|
|
1595
|
-
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1596
|
-
masterInfo: LiveAPIStatus.masterInfo,
|
|
1597
|
-
cardStyle: sub.customCardStyle
|
|
1598
|
-
}, uid, liveMsg);
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
const handler = async () => {
|
|
1602
|
-
const data$1 = await useLiveInfo();
|
|
1603
|
-
for (const item of Object.values(data$1)) {
|
|
1604
|
-
const uid = item.uid.toString();
|
|
1605
|
-
const LiveAPIStatus = this.liveAPIManager.get(uid);
|
|
1606
|
-
const liveMsgObj = this.liveMsgManager.get(uid);
|
|
1607
|
-
const sub = this.subManager.get(uid);
|
|
1608
|
-
if (!sub) return;
|
|
1609
|
-
switch (item.live_status) {
|
|
1610
|
-
case 0:
|
|
1611
|
-
case 2:
|
|
1612
|
-
if (LiveAPIStatus.live === true) {
|
|
1613
|
-
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, LiveAPIStatus)) {
|
|
1614
|
-
await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
|
|
1615
|
-
return await this.sendPrivateMsgAndStopService();
|
|
1616
|
-
}
|
|
1617
|
-
if (LiveAPIStatus.liveStartTimeInit) {
|
|
1618
|
-
LiveAPIStatus.liveRoomInfo.live_time = LiveAPIStatus.liveStartTime;
|
|
1619
|
-
LiveAPIStatus.liveStartTimeInit = false;
|
|
1620
|
-
}
|
|
1621
|
-
const followerChange = (() => {
|
|
1622
|
-
const liveFollowerChangeNum = LiveAPIStatus.masterInfo.liveFollowerChange;
|
|
1623
|
-
if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
|
|
1624
|
-
return liveFollowerChangeNum <= -1e4 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1625
|
-
})();
|
|
1626
|
-
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");
|
|
1627
|
-
await this.sendLiveNotifyCard(LiveType.StopBroadcast, { fansChanged: followerChange }, {
|
|
1628
|
-
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1629
|
-
masterInfo: LiveAPIStatus.masterInfo,
|
|
1630
|
-
cardStyle: sub.customCardStyle
|
|
1631
|
-
}, uid, liveEndMsg);
|
|
1632
|
-
LiveAPIStatus.live = false;
|
|
1633
|
-
}
|
|
1634
|
-
break;
|
|
1635
|
-
case 1:
|
|
1636
|
-
if (LiveAPIStatus.live === false) {
|
|
1637
|
-
if (!await useMasterAndLiveRoomInfo(LiveType.StopBroadcast, LiveAPIStatus)) {
|
|
1638
|
-
await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
|
|
1639
|
-
return await this.sendPrivateMsgAndStopService();
|
|
1640
|
-
}
|
|
1641
|
-
LiveAPIStatus.liveStartTime = LiveAPIStatus.liveRoomInfo.live_time;
|
|
1642
|
-
LiveAPIStatus.liveStartTimeInit = true;
|
|
1643
|
-
const followerNum = LiveAPIStatus.masterInfo.liveOpenFollowerNum >= 1e4 ? `${(LiveAPIStatus.masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : LiveAPIStatus.masterInfo.liveOpenFollowerNum.toString();
|
|
1644
|
-
const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", LiveAPIStatus.masterInfo.username).replace("-time", await this.ctx["bilibili-notify-generate-img"].getTimeDifference(LiveAPIStatus.liveStartTime)).replace("-follower", followerNum).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${LiveAPIStatus.liveRoomInfo.short_id === 0 ? LiveAPIStatus.liveRoomInfo.room_id : LiveAPIStatus.liveRoomInfo.short_id}`);
|
|
1645
|
-
await this.sendLiveNotifyCard(LiveType.StartBroadcasting, { fansNum: followerNum }, {
|
|
1646
|
-
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1647
|
-
masterInfo: LiveAPIStatus.masterInfo,
|
|
1648
|
-
cardStyle: sub.customCardStyle
|
|
1649
|
-
}, uid, liveStartMsg);
|
|
1650
|
-
LiveAPIStatus.live = true;
|
|
1651
|
-
}
|
|
1652
|
-
if (LiveAPIStatus.live === true) {
|
|
1653
|
-
if (LiveAPIStatus.push < this.config.pushTime * 60 * 60 / 30) {
|
|
1654
|
-
LiveAPIStatus.push++;
|
|
1655
|
-
break;
|
|
1656
|
-
}
|
|
1657
|
-
if (!await useMasterAndLiveRoomInfo(LiveType.LiveBroadcast, LiveAPIStatus)) {
|
|
1658
|
-
await this.sendPrivateMsg("获取直播间信息失败,推送直播卡片失败!");
|
|
1659
|
-
return await this.sendPrivateMsgAndStopService();
|
|
1660
|
-
}
|
|
1661
|
-
if (!LiveAPIStatus.liveStartTimeInit) {
|
|
1662
|
-
LiveAPIStatus.liveStartTime = LiveAPIStatus.liveRoomInfo.live_time;
|
|
1663
|
-
LiveAPIStatus.liveStartTimeInit = true;
|
|
1664
|
-
}
|
|
1665
|
-
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}`);
|
|
1666
|
-
await this.sendLiveNotifyCard(LiveType.LiveBroadcast, { watchedNum: "API" }, {
|
|
1667
|
-
liveRoomInfo: LiveAPIStatus.liveRoomInfo,
|
|
1668
|
-
masterInfo: LiveAPIStatus.masterInfo,
|
|
1669
|
-
cardStyle: sub.customCardStyle
|
|
1670
|
-
}, uid, liveMsg);
|
|
1671
|
-
LiveAPIStatus.push = 0;
|
|
1672
|
-
}
|
|
1673
|
-
break;
|
|
1674
|
-
default: break;
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
};
|
|
1678
|
-
return withLock(handler);
|
|
1679
|
-
}
|
|
1680
1584
|
subShow() {
|
|
1681
1585
|
let table = "";
|
|
1682
1586
|
for (const [uid, sub] of this.subManager) table += `UID:${uid} ${sub.dynamic ? "已订阅动态" : ""} ${sub.live ? "已订阅直播" : ""}\n`;
|
|
@@ -1895,7 +1799,7 @@ var ComRegister = class ComRegister {
|
|
|
1895
1799
|
}
|
|
1896
1800
|
sub.roomid = userInfoData.live_room?.roomid;
|
|
1897
1801
|
}
|
|
1898
|
-
if (sub.live && sub.roomid
|
|
1802
|
+
if (sub.live && sub.roomid) await this.liveDetectWithListener(sub);
|
|
1899
1803
|
this.logger.info(`UID:${sub.uid} 订阅加载完毕!`);
|
|
1900
1804
|
if (sub !== Object.values(subs).pop()) {
|
|
1901
1805
|
const randomDelay = Math.floor(Math.random() * 3) + 1;
|
|
@@ -1911,21 +1815,11 @@ var ComRegister = class ComRegister {
|
|
|
1911
1815
|
checkIfDynamicDetectIsNeeded() {
|
|
1912
1816
|
if (this.dynamicTimelineManager.size > 0) this.enableDynamicDetect();
|
|
1913
1817
|
}
|
|
1914
|
-
checkIfLiveDetectIsNeeded() {
|
|
1915
|
-
if (this.config.liveDetectType === "API") {
|
|
1916
|
-
if (this.liveAPIManager.size > 0) this.enableLiveDetect();
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
1818
|
enableDynamicDetect() {
|
|
1920
1819
|
this.dynamicJob = new CronJob(this.config.dynamicCron, this.config.dynamicDebugMode ? this.debug_dynamicDetect() : this.dynamicDetect());
|
|
1921
1820
|
this.logger.info("动态监测已开启");
|
|
1922
1821
|
this.dynamicJob.start();
|
|
1923
1822
|
}
|
|
1924
|
-
async enableLiveDetect() {
|
|
1925
|
-
this.liveAPIJob = new CronJob("*/30 * * * * *", await this.liveDetectWithAPI());
|
|
1926
|
-
this.logger.info("直播监测已开启");
|
|
1927
|
-
this.liveAPIJob.start();
|
|
1928
|
-
}
|
|
1929
1823
|
async checkIfIsLogin() {
|
|
1930
1824
|
if ((await this.ctx.database.get("loginBili", 1)).length !== 0) {
|
|
1931
1825
|
if (this.ctx["bilibili-notify-api"].getCookies() !== "[]") return true;
|
|
@@ -1956,7 +1850,6 @@ var ComRegister = class ComRegister {
|
|
|
1956
1850
|
masterAccount: Schema.string(),
|
|
1957
1851
|
masterAccountGuildId: Schema.string()
|
|
1958
1852
|
}),
|
|
1959
|
-
liveDetectType: Schema.string(),
|
|
1960
1853
|
wordcloudStopWords: Schema.string(),
|
|
1961
1854
|
liveSummary: Schema.array(String),
|
|
1962
1855
|
restartPush: Schema.boolean().required(),
|
|
@@ -1982,6 +1875,12 @@ var ComRegister = class ComRegister {
|
|
|
1982
1875
|
baseURL: Schema.string().default("https://api.siliconflow.cn/v1"),
|
|
1983
1876
|
model: Schema.string().default("gpt-3.5-turbo"),
|
|
1984
1877
|
persona: Schema.string()
|
|
1878
|
+
}),
|
|
1879
|
+
customGuardBuyImg: Schema.object({
|
|
1880
|
+
enable: Schema.boolean().default(false).description("是否启用自定义舰长购买图片"),
|
|
1881
|
+
captainImgUrl: Schema.string().description("舰长图片链接"),
|
|
1882
|
+
supervisorImgUrl: Schema.string().description("提督图片链接"),
|
|
1883
|
+
governorImgUrl: Schema.string().description("总督图片链接")
|
|
1985
1884
|
})
|
|
1986
1885
|
});
|
|
1987
1886
|
})(ComRegister || (ComRegister = {}));
|
|
@@ -2331,6 +2230,10 @@ var GenerateImg = class GenerateImg extends Service {
|
|
|
2331
2230
|
}
|
|
2332
2231
|
|
|
2333
2232
|
.accompany span {
|
|
2233
|
+
max-width: 85px;
|
|
2234
|
+
white-space: nowrap;
|
|
2235
|
+
text-overflow: ellipsis;
|
|
2236
|
+
overflow: hidden;
|
|
2334
2237
|
color: white;
|
|
2335
2238
|
font-size: 10px;
|
|
2336
2239
|
font-weight: bold;
|
|
@@ -2367,7 +2270,7 @@ var GenerateImg = class GenerateImg extends Service {
|
|
|
2367
2270
|
<span>${uname}</span>
|
|
2368
2271
|
</div>
|
|
2369
2272
|
<div class="accompany">
|
|
2370
|
-
<div class="master-avatar"></div><span>${
|
|
2273
|
+
<div class="master-avatar"></div><span>${isAdmin ? "房管" : masterName}</span>
|
|
2371
2274
|
</div>
|
|
2372
2275
|
</div>
|
|
2373
2276
|
</div>
|
|
@@ -4574,13 +4477,13 @@ var ServerManager = class extends Service {
|
|
|
4574
4477
|
master: globalConfig.master,
|
|
4575
4478
|
wordcloudStopWords: globalConfig.wordcloudStopWords,
|
|
4576
4479
|
liveSummary: globalConfig.liveSummary,
|
|
4577
|
-
liveDetectType: globalConfig.liveDetectType,
|
|
4578
4480
|
restartPush: globalConfig.restartPush,
|
|
4579
4481
|
pushTime: globalConfig.pushTime,
|
|
4580
4482
|
pushImgsInDynamic: globalConfig.pushImgsInDynamic,
|
|
4581
4483
|
customLiveStart: globalConfig.customLiveStart,
|
|
4582
4484
|
customLive: globalConfig.customLive,
|
|
4583
4485
|
customLiveEnd: globalConfig.customLiveEnd,
|
|
4486
|
+
customGuardBuyImg: globalConfig.customGuardBuyImg,
|
|
4584
4487
|
dynamicUrl: globalConfig.dynamicUrl,
|
|
4585
4488
|
dynamicCron: globalConfig.dynamicCron,
|
|
4586
4489
|
dynamicVideoUrlToBV: globalConfig.dynamicVideoUrlToBV,
|