koishi-plugin-bilibili-notify 1.2.0-rc.0 → 1.2.0-rc.2

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.
@@ -21,6 +21,7 @@ declare class ComRegister {
21
21
  qqguildBot: Bot<Context>;
22
22
  oneBot: Bot<Context>;
23
23
  redBot: Bot<Context>;
24
+ telegramBot: Bot<Context>;
24
25
  constructor(ctx: Context, config: ComRegister.Config);
25
26
  dynamicDetect(ctx: Context, bot: Bot<Context>, uid: string, guildId: Array<string>): () => Promise<void>;
26
27
  sendMsg(targets: Array<string>, bot: Bot<Context>, content: any): Promise<void>;
@@ -29,6 +29,8 @@ class ComRegister {
29
29
  oneBot;
30
30
  // Red机器人
31
31
  redBot;
32
+ // Telegram机器人
33
+ telegramBot;
32
34
  constructor(ctx, config) {
33
35
  this.logger = ctx.logger('commandRegister');
34
36
  this.config = config;
@@ -44,7 +46,12 @@ class ComRegister {
44
46
  case 'onebot':
45
47
  this.oneBot = bot;
46
48
  break;
47
- case 'red': this.redBot = bot;
49
+ case 'red':
50
+ this.redBot = bot;
51
+ break;
52
+ case 'telegram':
53
+ this.telegramBot = bot;
54
+ break;
48
55
  }
49
56
  });
50
57
  // 从数据库获取订阅
@@ -297,6 +304,7 @@ class ComRegister {
297
304
  switch (session.event.platform) {
298
305
  case 'red':
299
306
  case 'onebot':
307
+ case 'telegram':
300
308
  case 'qq':
301
309
  case 'qqguild': break;
302
310
  default: return '暂不支持该平台';
@@ -444,7 +452,7 @@ class ComRegister {
444
452
  userData = data;
445
453
  }
446
454
  catch (e) {
447
- return 'bili sub指令 getMasterInfo() 网络请求失败';
455
+ return 'bili sub指令 getMasterInfo() 网络请求失败,请重试';
448
456
  }
449
457
  // 需要订阅直播
450
458
  if (liveMsg) {
@@ -470,12 +478,14 @@ class ComRegister {
470
478
  this.logger.info('调用bili.dynamic指令');
471
479
  // 如果uid为空则返回
472
480
  if (!uid)
473
- return '用户uid不能为空';
481
+ return `${uid}非法调用 dynamic 指令`; // 用户uid不能为空
474
482
  if (!guildId)
475
- return '目标群组或频道不能为空';
476
- if (!options.bot)
477
- return '非法调用';
478
- // 保存到订阅管理对象
483
+ return `${uid}非法调用 dynamic 指令`; // 目标群组或频道不能为空
484
+ if (!options.bot) {
485
+ this.logger.warn(`${uid}非法调用 dynamic 指令,未传入订阅平台`);
486
+ return `${uid}非法调用 dynamic 指令`;
487
+ }
488
+ // 寻找对应订阅管理对象
479
489
  const index = this.subManager.findIndex(sub => sub.uid === uid);
480
490
  // 不存在则直接返回
481
491
  if (index === -1) {
@@ -497,7 +507,13 @@ class ComRegister {
497
507
  case 'red':
498
508
  bot = this.redBot;
499
509
  break;
500
- default: return '非法调用';
510
+ case 'telegram':
511
+ bot = this.telegramBot;
512
+ break;
513
+ default: {
514
+ this.logger.warn(`${uid}非法调用 dynamic 指令,不支持该平台`);
515
+ return '非法调用';
516
+ }
501
517
  }
502
518
  // 开始循环检测
503
519
  const dispose = ctx.setInterval(this.dynamicDetect(ctx, bot, uid, guildId), config.dynamicLoopTime * 1000);
@@ -513,11 +529,13 @@ class ComRegister {
513
529
  this.logger.info('调用bili.live指令');
514
530
  // 如果room_id为空则返回
515
531
  if (!roomId)
516
- return '订阅主播房间号不能为空';
532
+ return `${roomId}非法调用 dynamic 指令`; // 订阅主播房间号不能为空
517
533
  if (!guildId)
518
- return '目标群组或频道不能为空';
519
- if (!options.bot)
520
- return '非法调用';
534
+ return `${roomId}非法调用 dynamic 指令`; // 目标群组或频道不能为空
535
+ if (!options.bot) {
536
+ this.logger.warn(`${roomId}非法调用 dynamic 指令,未传入推送平台`);
537
+ return `${roomId}非法调用 dynamic 指令`;
538
+ }
521
539
  // 保存到订阅管理对象
522
540
  const index = this.subManager.findIndex(sub => sub.roomId === roomId);
523
541
  // 要订阅的对象不在订阅管理对象中,直接返回
@@ -538,7 +556,13 @@ class ComRegister {
538
556
  case 'red':
539
557
  bot = this.redBot;
540
558
  break;
541
- default: return '非法调用';
559
+ case 'telegram':
560
+ bot = this.telegramBot;
561
+ break;
562
+ default: {
563
+ this.logger.warn(`${roomId}非法调用 dynamic 指令,不支持该平台`);
564
+ return `${roomId}非法调用 dynamic 指令`;
565
+ }
542
566
  }
543
567
  // 开始循环检测
544
568
  const dispose = ctx.setInterval(this.liveDetect(ctx, bot, roomId, guildId), config.liveLoopTime * 1000);
@@ -930,20 +954,15 @@ class ComRegister {
930
954
  }
931
955
  async getSubFromDatabase(ctx) {
932
956
  // 如果未登录,则直接返回
933
- this.logger.info('Login info:', await this.checkIfIsLogin(ctx));
934
957
  if (!(await this.checkIfIsLogin(ctx)))
935
958
  return;
936
959
  // 已存在订阅管理对象,不再进行订阅操作
937
- this.logger.info('Sub Manager num:', this.subManager.length);
938
960
  if (this.subManager.length !== 0)
939
961
  return;
940
962
  // 从数据库中获取数据
941
963
  const subData = await ctx.database.get('bilibili', { id: { $gt: 0 } });
942
- this.logger.info('Sub object:');
943
- this.logger.info(subData);
944
964
  // 设定订阅数量
945
965
  this.num = subData.length;
946
- this.logger.info('Sub number:' + this.num);
947
966
  // 如果订阅数量超过三个则数据库被非法修改
948
967
  if (!this.config.unlockSubLimits && this.num > 3) {
949
968
  // 在控制台提示重新订阅
@@ -955,8 +974,6 @@ class ComRegister {
955
974
  }
956
975
  // 循环遍历
957
976
  for (const sub of subData) {
958
- this.logger.info('Single sub obj:');
959
- this.logger.info(sub);
960
977
  // 定义Bot
961
978
  let bot;
962
979
  // 判断是否存在没有任何订阅的数据
@@ -980,6 +997,9 @@ class ComRegister {
980
997
  case 'red':
981
998
  bot = this.redBot;
982
999
  break;
1000
+ case 'telegram':
1001
+ bot = this.telegramBot;
1002
+ break;
983
1003
  default: {
984
1004
  // 本条数据被篡改,删除该条订阅
985
1005
  ctx.database.remove('bilibili', { id: sub.id });
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": "1.2.0-rc.0",
4
+ "version": "1.2.0-rc.2",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- # Bilibili-Botify
1
+ # Bilibili-Notify
2
2
 
3
3
  基于 [koishi](../../../../koishijs/koishi) 框架的B站推送插件
4
4
 
@@ -10,6 +10,7 @@
10
10
  - [使用方法](#使用方法)
11
11
  - [注意事项](#注意事项)
12
12
  - [更新日志](#更新日志)
13
+ - [交流群](#交流群)
13
14
  - [感谢](#感谢)
14
15
  - [License](#License)
15
16
 
@@ -106,7 +107,11 @@
106
107
  - ver 1.2.0-alpha.3 修复了指定QQ群订阅时的一个bug
107
108
  - ver 1.2.0-alpha.4 对时间获取进行了优化,能够适应不同环境下的时间获取,修复了一些bug
108
109
  - ver 1.2.0-alpha.5 修复了与PostgreSQL不兼容的问题,优化了图片推送,增强了推送容错
109
- - ver 1.2.0-rc.0 现在可以自定义开播和下播提示语了(实验性)
110
+ - ver 1.2.0-rc.0 现已支持自定义开播和下播提示语(实验性)
111
+ - ver 1.2.0-rc.1 现已支持Telegram平台(实验性)
112
+
113
+ ## 交流群
114
+ 801338523 使用问题或bug都可以在群里提出
110
115
 
111
116
  ## 感谢
112
117