koishi-plugin-bilibili-notify 3.0.0-alpha.8 → 3.0.0-alpha.9
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/comRegister.js +58 -16
- package/package.json +1 -1
- package/readme.md +1 -0
package/lib/comRegister.js
CHANGED
|
@@ -1398,6 +1398,9 @@ class ComRegister {
|
|
|
1398
1398
|
// 处理target
|
|
1399
1399
|
// 定义channelIdArr总长度
|
|
1400
1400
|
let channelIdArrLen = 0;
|
|
1401
|
+
// 定义数据
|
|
1402
|
+
let liveRoomInfo;
|
|
1403
|
+
let masterInfo;
|
|
1401
1404
|
// 找到频道/群组对应的
|
|
1402
1405
|
const danmakuPushTargetArr = target.map(channel => {
|
|
1403
1406
|
// 获取符合条件的target
|
|
@@ -1412,10 +1415,13 @@ class ComRegister {
|
|
|
1412
1415
|
});
|
|
1413
1416
|
// 定义定时推送函数
|
|
1414
1417
|
const pushAtTimeFunc = async () => {
|
|
1415
|
-
//
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1418
|
+
// 判断是否信息是否获取成功
|
|
1419
|
+
if (!(await useMasterAndLiveRoomInfo())) {
|
|
1420
|
+
// 未获取成功,直接返回
|
|
1421
|
+
return this.sendPrivateMsg('获取直播间信息失败,推送直播卡片失败!');
|
|
1422
|
+
}
|
|
1423
|
+
// 设置开播时间
|
|
1424
|
+
liveTime = liveRoomInfo.live_time;
|
|
1419
1425
|
// 设置直播中消息
|
|
1420
1426
|
const liveMsg = this.config.customLive ? this.config.customLive
|
|
1421
1427
|
.replace('-name', masterInfo.username)
|
|
@@ -1439,10 +1445,44 @@ class ComRegister {
|
|
|
1439
1445
|
temporaryLiveDanmakuArr.length = 0;
|
|
1440
1446
|
}
|
|
1441
1447
|
};
|
|
1442
|
-
//
|
|
1443
|
-
const
|
|
1444
|
-
|
|
1445
|
-
|
|
1448
|
+
// 定义直播间信息获取函数
|
|
1449
|
+
const useMasterAndLiveRoomInfo = async () => {
|
|
1450
|
+
// 定义flag
|
|
1451
|
+
let flag = true;
|
|
1452
|
+
// 判断是否已存在值
|
|
1453
|
+
if (liveRoomInfo && masterInfo && liveTime) {
|
|
1454
|
+
// 所有值均已存在,不需要再获取信息
|
|
1455
|
+
return flag;
|
|
1456
|
+
}
|
|
1457
|
+
// 获取直播间信息
|
|
1458
|
+
liveRoomInfo = await this.useLiveRoomInfo(roomId).catch(() => {
|
|
1459
|
+
// 设置flag为false
|
|
1460
|
+
flag = false;
|
|
1461
|
+
// 返回空
|
|
1462
|
+
return null;
|
|
1463
|
+
});
|
|
1464
|
+
// 判断是否成功获取信息
|
|
1465
|
+
if (!flag || !liveRoomInfo || !liveRoomInfo.uid) {
|
|
1466
|
+
// 上一步未成功
|
|
1467
|
+
flag = false;
|
|
1468
|
+
// 返回flag
|
|
1469
|
+
return flag;
|
|
1470
|
+
}
|
|
1471
|
+
// 获取主播信息(需要满足flag为true,liveRoomInfo.uid有值)
|
|
1472
|
+
masterInfo = await this.useMasterInfo(liveRoomInfo.uid).catch(() => {
|
|
1473
|
+
// 设置flag为false
|
|
1474
|
+
flag = false;
|
|
1475
|
+
// 返回空
|
|
1476
|
+
return null;
|
|
1477
|
+
});
|
|
1478
|
+
// 返回信息
|
|
1479
|
+
return flag;
|
|
1480
|
+
};
|
|
1481
|
+
// 判断是否信息是否获取成功
|
|
1482
|
+
if (!(await useMasterAndLiveRoomInfo())) {
|
|
1483
|
+
// 未获取成功,直接返回
|
|
1484
|
+
return this.sendPrivateMsg('获取直播间信息失败,启动直播间弹幕检测失败!');
|
|
1485
|
+
}
|
|
1446
1486
|
// 构建消息处理函数
|
|
1447
1487
|
const handler = {
|
|
1448
1488
|
onOpen: () => {
|
|
@@ -1475,10 +1515,11 @@ class ComRegister {
|
|
|
1475
1515
|
// 判断是否已经开播
|
|
1476
1516
|
if (liveStatus)
|
|
1477
1517
|
return;
|
|
1478
|
-
//
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1518
|
+
// 判断是否信息是否获取成功
|
|
1519
|
+
if (!(await useMasterAndLiveRoomInfo())) {
|
|
1520
|
+
// 未获取成功,直接返回
|
|
1521
|
+
return this.sendPrivateMsg('获取直播间信息失败,推送直播开播卡片失败!');
|
|
1522
|
+
}
|
|
1482
1523
|
// 设置开播时间
|
|
1483
1524
|
liveTime = liveRoomInfo.live_time;
|
|
1484
1525
|
// 定义开播通知语
|
|
@@ -1502,10 +1543,11 @@ class ComRegister {
|
|
|
1502
1543
|
liveStatus = true;
|
|
1503
1544
|
},
|
|
1504
1545
|
onLiveEnd: async () => {
|
|
1505
|
-
//
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1546
|
+
// 判断是否信息是否获取成功
|
|
1547
|
+
if (!(await useMasterAndLiveRoomInfo())) {
|
|
1548
|
+
// 未获取成功,直接返回
|
|
1549
|
+
return this.sendPrivateMsg('获取直播间信息失败,推送直播下播卡片失败!');
|
|
1550
|
+
}
|
|
1509
1551
|
// 更改直播时长
|
|
1510
1552
|
liveRoomInfo.live_time = liveTime;
|
|
1511
1553
|
// 定义下播播通知语
|
package/package.json
CHANGED
package/readme.md
CHANGED