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 CHANGED
@@ -298,6 +298,7 @@ class BiliAPI extends koishi_1.Service {
298
298
  return data;
299
299
  }
300
300
  catch (e) {
301
+ console.warn(e);
301
302
  throw new Error('网络异常,本次请求失败!');
302
303
  }
303
304
  }
@@ -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 newTarget = target.map(channel => {
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: newTarget,
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(newTarget, temporaryLiveDanmakuArr.join('\n'));
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: newTarget,
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: newTarget,
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: newTarget,
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('getSubFromDatabase() getUserInfo() 发生了错误,错误为:' + e.message);
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-bilibili-notify",
3
3
  "description": "Koishi bilibili notify plugin",
4
- "version": "3.0.0-alpha.2",
4
+ "version": "3.0.0-alpha.4",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -214,6 +214,8 @@
214
214
  - ver 3.0.0-alpha.0 重构:直播 新增:直播弹幕推送到群
215
215
  - ver 3.0.0-alpha.1 测试版本
216
216
  - ver 3.0.0-alpha.2 修复:只订阅直播也会将该UP主的动态进行推送、推送过的动态过一段时间又会再次推送
217
+ - ver 3.0.0-alpha.3 修复:未开启弹幕推送也不会推送直播通知卡片
218
+ - ver 3.0.0-alpha.4 修复:使用了手动订阅,数据库中的订阅不会加载
217
219
 
218
220
  ## 交流群
219
221