koishi-plugin-bilibili-notify 3.3.6-alpha.0 → 3.3.6
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 +19 -8
- package/lib/index.mjs +19 -8
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -490,7 +490,8 @@ var ComRegister = class {
|
|
|
490
490
|
});
|
|
491
491
|
}
|
|
492
492
|
let table = "";
|
|
493
|
-
|
|
493
|
+
if (subLiveUsers.length === 0) table += "当前没有正在直播的订阅对象";
|
|
494
|
+
else for (const user of subLiveUsers) table += `[UID:${user.uid}] 「${user.uname}」 ${user.onLive ? "正在直播" : "未开播"}\n`;
|
|
494
495
|
return table;
|
|
495
496
|
});
|
|
496
497
|
biliCom.subcommand(".dyn <uid:string> [index:number]", "手动推送一条动态信息", { hidden: true }).usage("手动推送一条动态信息").example("bili dyn 233 1 手动推送UID为233用户空间的第一条动态信息").action(async ({ session }, uid, index) => {
|
|
@@ -663,6 +664,7 @@ var ComRegister = class {
|
|
|
663
664
|
return;
|
|
664
665
|
}
|
|
665
666
|
this.mergeStopWords(config.wordcloudStopWords);
|
|
667
|
+
this.initAllManager();
|
|
666
668
|
this.registeringForEvents();
|
|
667
669
|
if (config.advancedSub) {
|
|
668
670
|
this.logger.info("开启高级订阅,等待加载订阅...");
|
|
@@ -693,7 +695,6 @@ var ComRegister = class {
|
|
|
693
695
|
});
|
|
694
696
|
}
|
|
695
697
|
async initAsyncPart(subs) {
|
|
696
|
-
this.initAllManager();
|
|
697
698
|
this.logger.info("获取到订阅信息,开始加载订阅...");
|
|
698
699
|
const { code, message } = await this.loadSubFromConfig(subs);
|
|
699
700
|
if (code !== 0) {
|
|
@@ -702,7 +703,7 @@ var ComRegister = class {
|
|
|
702
703
|
await this.sendPrivateMsg("订阅对象加载失败,插件初始化失败!");
|
|
703
704
|
return;
|
|
704
705
|
}
|
|
705
|
-
this.
|
|
706
|
+
this.initManagerAfterLoadSub();
|
|
706
707
|
this.checkIfDynamicDetectIsNeeded();
|
|
707
708
|
this.checkIfLiveDetectIsNeeded();
|
|
708
709
|
this.updateSubNotifier();
|
|
@@ -716,7 +717,7 @@ var ComRegister = class {
|
|
|
716
717
|
const additionalStopWords = stopWordsStr.split(",").map((word) => word.trim()).filter((word) => word !== "");
|
|
717
718
|
this.stopwords = new Set([...stop_words_default, ...additionalStopWords]);
|
|
718
719
|
}
|
|
719
|
-
|
|
720
|
+
initManagerAfterLoadSub() {
|
|
720
721
|
for (const [uid, sub] of this.subManager) {
|
|
721
722
|
if (sub.dynamic) this.dynamicTimelineManager.set(uid, Math.floor(luxon.DateTime.now().toSeconds()));
|
|
722
723
|
if (sub.live) this.liveAPIManager.set(uid, {
|
|
@@ -1293,6 +1294,10 @@ var ComRegister = class {
|
|
|
1293
1294
|
const now = Date.now();
|
|
1294
1295
|
if (now - lastLiveStart < LIVE_EVENT_COOLDOWN) {
|
|
1295
1296
|
this.logger.warn(`[${sub.roomid}] 开播事件冷却期内被忽略`);
|
|
1297
|
+
if (!liveTime) {
|
|
1298
|
+
await useMasterAndLiveRoomInfo(LiveType.StartBroadcasting);
|
|
1299
|
+
liveTime = liveRoomInfo?.live_time || Date.now();
|
|
1300
|
+
}
|
|
1296
1301
|
return;
|
|
1297
1302
|
}
|
|
1298
1303
|
lastLiveStart = now;
|
|
@@ -1306,9 +1311,10 @@ var ComRegister = class {
|
|
|
1306
1311
|
await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
|
|
1307
1312
|
return await this.sendPrivateMsgAndStopService();
|
|
1308
1313
|
}
|
|
1309
|
-
liveTime = liveRoomInfo.
|
|
1314
|
+
liveTime = liveRoomInfo?.live_time || Date.now();
|
|
1315
|
+
const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
|
|
1310
1316
|
const follower = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
|
|
1311
|
-
const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", masterInfo.username).replace("-time",
|
|
1317
|
+
const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower", follower).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1312
1318
|
await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
|
|
1313
1319
|
liveRoomInfo,
|
|
1314
1320
|
masterInfo,
|
|
@@ -1323,6 +1329,10 @@ var ComRegister = class {
|
|
|
1323
1329
|
const now = Date.now();
|
|
1324
1330
|
if (now - lastLiveEnd < LIVE_EVENT_COOLDOWN) {
|
|
1325
1331
|
this.logger.warn(`[${sub.roomid}] 下播事件冷却期内被忽略`);
|
|
1332
|
+
if (!liveTime) {
|
|
1333
|
+
await useMasterAndLiveRoomInfo(LiveType.StopBroadcast);
|
|
1334
|
+
liveTime = liveRoomInfo?.live_time || Date.now();
|
|
1335
|
+
}
|
|
1326
1336
|
return;
|
|
1327
1337
|
}
|
|
1328
1338
|
lastLiveEnd = now;
|
|
@@ -1335,13 +1345,14 @@ var ComRegister = class {
|
|
|
1335
1345
|
await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
|
|
1336
1346
|
return await this.sendPrivateMsgAndStopService();
|
|
1337
1347
|
}
|
|
1338
|
-
liveRoomInfo
|
|
1348
|
+
liveTime = liveTime || liveRoomInfo?.live_time || Date.now();
|
|
1349
|
+
const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
|
|
1339
1350
|
const followerChange = (() => {
|
|
1340
1351
|
const liveFollowerChangeNum = masterInfo.liveFollowerChange;
|
|
1341
1352
|
if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : `+${liveFollowerChangeNum}`;
|
|
1342
1353
|
return liveFollowerChangeNum <= -1e4 ? `${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1343
1354
|
})();
|
|
1344
|
-
const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name", masterInfo.username).replace("-time",
|
|
1355
|
+
const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
|
|
1345
1356
|
await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
|
|
1346
1357
|
liveRoomInfo,
|
|
1347
1358
|
masterInfo,
|
package/lib/index.mjs
CHANGED
|
@@ -472,7 +472,8 @@ var ComRegister = class {
|
|
|
472
472
|
});
|
|
473
473
|
}
|
|
474
474
|
let table = "";
|
|
475
|
-
|
|
475
|
+
if (subLiveUsers.length === 0) table += "当前没有正在直播的订阅对象";
|
|
476
|
+
else for (const user of subLiveUsers) table += `[UID:${user.uid}] 「${user.uname}」 ${user.onLive ? "正在直播" : "未开播"}\n`;
|
|
476
477
|
return table;
|
|
477
478
|
});
|
|
478
479
|
biliCom.subcommand(".dyn <uid:string> [index:number]", "手动推送一条动态信息", { hidden: true }).usage("手动推送一条动态信息").example("bili dyn 233 1 手动推送UID为233用户空间的第一条动态信息").action(async ({ session }, uid, index) => {
|
|
@@ -645,6 +646,7 @@ var ComRegister = class {
|
|
|
645
646
|
return;
|
|
646
647
|
}
|
|
647
648
|
this.mergeStopWords(config.wordcloudStopWords);
|
|
649
|
+
this.initAllManager();
|
|
648
650
|
this.registeringForEvents();
|
|
649
651
|
if (config.advancedSub) {
|
|
650
652
|
this.logger.info("开启高级订阅,等待加载订阅...");
|
|
@@ -675,7 +677,6 @@ var ComRegister = class {
|
|
|
675
677
|
});
|
|
676
678
|
}
|
|
677
679
|
async initAsyncPart(subs) {
|
|
678
|
-
this.initAllManager();
|
|
679
680
|
this.logger.info("获取到订阅信息,开始加载订阅...");
|
|
680
681
|
const { code, message } = await this.loadSubFromConfig(subs);
|
|
681
682
|
if (code !== 0) {
|
|
@@ -684,7 +685,7 @@ var ComRegister = class {
|
|
|
684
685
|
await this.sendPrivateMsg("订阅对象加载失败,插件初始化失败!");
|
|
685
686
|
return;
|
|
686
687
|
}
|
|
687
|
-
this.
|
|
688
|
+
this.initManagerAfterLoadSub();
|
|
688
689
|
this.checkIfDynamicDetectIsNeeded();
|
|
689
690
|
this.checkIfLiveDetectIsNeeded();
|
|
690
691
|
this.updateSubNotifier();
|
|
@@ -698,7 +699,7 @@ var ComRegister = class {
|
|
|
698
699
|
const additionalStopWords = stopWordsStr.split(",").map((word) => word.trim()).filter((word) => word !== "");
|
|
699
700
|
this.stopwords = new Set([...stop_words_default, ...additionalStopWords]);
|
|
700
701
|
}
|
|
701
|
-
|
|
702
|
+
initManagerAfterLoadSub() {
|
|
702
703
|
for (const [uid, sub] of this.subManager) {
|
|
703
704
|
if (sub.dynamic) this.dynamicTimelineManager.set(uid, Math.floor(DateTime.now().toSeconds()));
|
|
704
705
|
if (sub.live) this.liveAPIManager.set(uid, {
|
|
@@ -1275,6 +1276,10 @@ var ComRegister = class {
|
|
|
1275
1276
|
const now = Date.now();
|
|
1276
1277
|
if (now - lastLiveStart < LIVE_EVENT_COOLDOWN) {
|
|
1277
1278
|
this.logger.warn(`[${sub.roomid}] 开播事件冷却期内被忽略`);
|
|
1279
|
+
if (!liveTime) {
|
|
1280
|
+
await useMasterAndLiveRoomInfo(LiveType.StartBroadcasting);
|
|
1281
|
+
liveTime = liveRoomInfo?.live_time || Date.now();
|
|
1282
|
+
}
|
|
1278
1283
|
return;
|
|
1279
1284
|
}
|
|
1280
1285
|
lastLiveStart = now;
|
|
@@ -1288,9 +1293,10 @@ var ComRegister = class {
|
|
|
1288
1293
|
await this.sendPrivateMsg("获取直播间信息失败,推送直播开播卡片失败!");
|
|
1289
1294
|
return await this.sendPrivateMsgAndStopService();
|
|
1290
1295
|
}
|
|
1291
|
-
liveTime = liveRoomInfo.
|
|
1296
|
+
liveTime = liveRoomInfo?.live_time || Date.now();
|
|
1297
|
+
const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
|
|
1292
1298
|
const follower = masterInfo.liveOpenFollowerNum >= 1e4 ? `${(masterInfo.liveOpenFollowerNum / 1e4).toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
|
|
1293
|
-
const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", masterInfo.username).replace("-time",
|
|
1299
|
+
const liveStartMsg = liveMsgObj.customLiveStart.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower", follower).replaceAll("\\n", "\n").replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`);
|
|
1294
1300
|
await this.sendLiveNotifyCard(LiveType.StartBroadcasting, follower, {
|
|
1295
1301
|
liveRoomInfo,
|
|
1296
1302
|
masterInfo,
|
|
@@ -1305,6 +1311,10 @@ var ComRegister = class {
|
|
|
1305
1311
|
const now = Date.now();
|
|
1306
1312
|
if (now - lastLiveEnd < LIVE_EVENT_COOLDOWN) {
|
|
1307
1313
|
this.logger.warn(`[${sub.roomid}] 下播事件冷却期内被忽略`);
|
|
1314
|
+
if (!liveTime) {
|
|
1315
|
+
await useMasterAndLiveRoomInfo(LiveType.StopBroadcast);
|
|
1316
|
+
liveTime = liveRoomInfo?.live_time || Date.now();
|
|
1317
|
+
}
|
|
1308
1318
|
return;
|
|
1309
1319
|
}
|
|
1310
1320
|
lastLiveEnd = now;
|
|
@@ -1317,13 +1327,14 @@ var ComRegister = class {
|
|
|
1317
1327
|
await this.sendPrivateMsg("获取直播间信息失败,推送直播下播卡片失败!");
|
|
1318
1328
|
return await this.sendPrivateMsgAndStopService();
|
|
1319
1329
|
}
|
|
1320
|
-
liveRoomInfo
|
|
1330
|
+
liveTime = liveTime || liveRoomInfo?.live_time || Date.now();
|
|
1331
|
+
const diffTime = await this.ctx["bilibili-notify-generate-img"].getTimeDifference(liveTime);
|
|
1321
1332
|
const followerChange = (() => {
|
|
1322
1333
|
const liveFollowerChangeNum = masterInfo.liveFollowerChange;
|
|
1323
1334
|
if (liveFollowerChangeNum > 0) return liveFollowerChangeNum >= 1e4 ? `+${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : `+${liveFollowerChangeNum}`;
|
|
1324
1335
|
return liveFollowerChangeNum <= -1e4 ? `${(liveFollowerChangeNum / 1e4).toFixed(1)}万` : liveFollowerChangeNum.toString();
|
|
1325
1336
|
})();
|
|
1326
|
-
const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name", masterInfo.username).replace("-time",
|
|
1337
|
+
const liveEndMsg = liveMsgObj.customLiveEnd.replace("-name", masterInfo.username).replace("-time", diffTime).replace("-follower_change", followerChange).replaceAll("\\n", "\n");
|
|
1327
1338
|
await this.sendLiveNotifyCard(LiveType.StopBroadcast, followerChange, {
|
|
1328
1339
|
liveRoomInfo,
|
|
1329
1340
|
masterInfo,
|