koishi-plugin-bilibili-notify 3.0.0-alpha.2 → 3.0.0-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/biliAPI.js +1 -0
- package/lib/comRegister.js +15 -18
- package/package.json +1 -1
- package/readme.md +2 -0
package/lib/biliAPI.js
CHANGED
package/lib/comRegister.js
CHANGED
|
@@ -583,6 +583,14 @@ class ComRegister {
|
|
|
583
583
|
}
|
|
584
584
|
// 检查登录数据库是否有数据
|
|
585
585
|
this.loginDBData = (await this.ctx.database.get('loginBili', 1, ['dynamic_group_id']))[0];
|
|
586
|
+
// 判断登录信息是否已加载完毕
|
|
587
|
+
await this.checkIfLoginInfoIsLoaded();
|
|
588
|
+
// 如果未登录,则直接返回
|
|
589
|
+
if (!(await this.checkIfIsLogin())) {
|
|
590
|
+
// log
|
|
591
|
+
this.logger.info(`账号未登录,请登录`);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
586
594
|
// 从配置获取订阅
|
|
587
595
|
config.sub && await this.loadSubFromConfig(config.sub);
|
|
588
596
|
// 从数据库获取订阅
|
|
@@ -1368,7 +1376,7 @@ class ComRegister {
|
|
|
1368
1376
|
const temporaryLiveDanmakuArr = [];
|
|
1369
1377
|
// 处理target
|
|
1370
1378
|
// 找到频道/群组对应的
|
|
1371
|
-
const
|
|
1379
|
+
const danmakuPushTargetArr = target.map(channel => {
|
|
1372
1380
|
const liveDanmakuArr = channel.channelIdArr.filter(channelId => channelId.liveDanmaku);
|
|
1373
1381
|
return {
|
|
1374
1382
|
channelIdArr: liveDanmakuArr,
|
|
@@ -1390,7 +1398,7 @@ class ComRegister {
|
|
|
1390
1398
|
await this.sendLiveNotifyCard({
|
|
1391
1399
|
username: masterInfo.username,
|
|
1392
1400
|
userface: masterInfo.userface,
|
|
1393
|
-
target
|
|
1401
|
+
target,
|
|
1394
1402
|
data: liveRoomInfo
|
|
1395
1403
|
}, LiveType.LiveBroadcast, liveMsg);
|
|
1396
1404
|
};
|
|
@@ -1399,7 +1407,7 @@ class ComRegister {
|
|
|
1399
1407
|
// 判断数组是否有内容
|
|
1400
1408
|
if (temporaryLiveDanmakuArr.length > 0) {
|
|
1401
1409
|
// 发送消息
|
|
1402
|
-
this.sendMsg(
|
|
1410
|
+
this.sendMsg(danmakuPushTargetArr, temporaryLiveDanmakuArr.join('\n'));
|
|
1403
1411
|
// 将临时消息数组清空
|
|
1404
1412
|
temporaryLiveDanmakuArr.length = 0;
|
|
1405
1413
|
}
|
|
@@ -1451,7 +1459,7 @@ class ComRegister {
|
|
|
1451
1459
|
await this.sendLiveNotifyCard({
|
|
1452
1460
|
username: masterInfo.username,
|
|
1453
1461
|
userface: masterInfo.userface,
|
|
1454
|
-
target
|
|
1462
|
+
target,
|
|
1455
1463
|
data: liveRoomInfo
|
|
1456
1464
|
}, LiveType.StopBroadcast, liveEndMsg);
|
|
1457
1465
|
},
|
|
@@ -1473,7 +1481,7 @@ class ComRegister {
|
|
|
1473
1481
|
await this.sendLiveNotifyCard({
|
|
1474
1482
|
username: masterInfo.username,
|
|
1475
1483
|
userface: masterInfo.userface,
|
|
1476
|
-
target
|
|
1484
|
+
target,
|
|
1477
1485
|
data: liveRoomInfo
|
|
1478
1486
|
}, LiveType.StartBroadcasting, liveEndMsg);
|
|
1479
1487
|
}
|
|
@@ -1494,7 +1502,7 @@ class ComRegister {
|
|
|
1494
1502
|
await this.sendLiveNotifyCard({
|
|
1495
1503
|
username: masterInfo.username,
|
|
1496
1504
|
userface: masterInfo.userface,
|
|
1497
|
-
target
|
|
1505
|
+
target,
|
|
1498
1506
|
data: liveRoomInfo
|
|
1499
1507
|
}, LiveType.LiveBroadcast, liveMsg);
|
|
1500
1508
|
}
|
|
@@ -1683,7 +1691,7 @@ class ComRegister {
|
|
|
1683
1691
|
break;
|
|
1684
1692
|
}
|
|
1685
1693
|
catch (e) {
|
|
1686
|
-
this.logger.error('
|
|
1694
|
+
this.logger.error('loadSubFromConfig() getUserInfo() 发生了错误,错误为:' + e.message);
|
|
1687
1695
|
if (i === attempts - 1) { // 已尝试三次
|
|
1688
1696
|
// 发送私聊消息并重启服务
|
|
1689
1697
|
return await this.sendPrivateMsgAndStopService();
|
|
@@ -1723,17 +1731,6 @@ class ComRegister {
|
|
|
1723
1731
|
}
|
|
1724
1732
|
}
|
|
1725
1733
|
async loadSubFromDatabase() {
|
|
1726
|
-
// 判断登录信息是否已加载完毕
|
|
1727
|
-
await this.checkIfLoginInfoIsLoaded();
|
|
1728
|
-
// 如果未登录,则直接返回
|
|
1729
|
-
if (!(await this.checkIfIsLogin())) {
|
|
1730
|
-
// log
|
|
1731
|
-
this.logger.info(`账号未登录,请登录`);
|
|
1732
|
-
return;
|
|
1733
|
-
}
|
|
1734
|
-
// 已存在订阅管理对象,不再进行订阅操作
|
|
1735
|
-
if (this.subManager.length !== 0)
|
|
1736
|
-
return;
|
|
1737
1734
|
// 从数据库中获取数据
|
|
1738
1735
|
const subData = await this.ctx.database.get('bilibili', { id: { $gt: 0 } });
|
|
1739
1736
|
// 定义变量:订阅直播数
|
package/package.json
CHANGED
package/readme.md
CHANGED