koishi-plugin-bilibili-notify 1.2.0-rc.3 → 1.2.0-rc.5

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.
@@ -12,6 +12,7 @@ declare class ComRegister {
12
12
  uid: string;
13
13
  roomId: string;
14
14
  targetId: string;
15
+ platform: string;
15
16
  live: boolean;
16
17
  dynamic: boolean;
17
18
  liveDispose: Function;
@@ -43,6 +44,12 @@ declare namespace ComRegister {
43
44
  customLiveEnd: string;
44
45
  dynamicLoopTime: number;
45
46
  dynamicCheckNumber: number;
47
+ filter: {
48
+ enable: boolean;
49
+ regex: string;
50
+ keywords: Array<string>;
51
+ notify: boolean;
52
+ };
46
53
  }
47
54
  const Config: Schema<Config>;
48
55
  }
@@ -440,6 +440,7 @@ class ComRegister {
440
440
  uid: mid,
441
441
  targetId,
442
442
  roomId,
443
+ platform: session.event.platform,
443
444
  live: liveMsg,
444
445
  dynamic: dynamicMsg,
445
446
  liveDispose: null,
@@ -454,16 +455,15 @@ class ComRegister {
454
455
  catch (e) {
455
456
  return 'bili sub指令 getMasterInfo() 网络请求失败,请重试';
456
457
  }
457
- this.logger.info(session.event.platform);
458
458
  // 需要订阅直播
459
459
  if (liveMsg) {
460
- await session.execute(`bili live ${roomId} ${targetId.split(',').join(' ')} -b ${session.event.platform}`);
460
+ await session.execute(`bili live ${roomId} ${targetId.split(',').join(' ')}`);
461
461
  // 发送订阅消息通知
462
462
  await session.send(`订阅${userData.info.uname}直播通知`);
463
463
  }
464
464
  // 需要订阅动态
465
465
  if (dynamicMsg) {
466
- await session.execute(`bili dynamic ${mid} ${targetId.split(',').join(' ')} -b ${session.event.platform}`);
466
+ await session.execute(`bili dynamic ${mid} ${targetId.split(',').join(' ')}`);
467
467
  // 发送订阅消息通知
468
468
  await session.send(`订阅${userData.info.uname}动态通知`);
469
469
  }
@@ -472,31 +472,28 @@ class ComRegister {
472
472
  });
473
473
  biliCom
474
474
  .subcommand('.dynamic <uid:string> <...guildId:string>', '订阅用户动态推送', { hidden: true })
475
- .option('bot', '-b <type:string>')
475
+ // .option('bot', '-b <type:string>')
476
476
  .usage('订阅用户动态推送')
477
477
  .example('bili dynamic 1194210119 订阅UID为1194210119的动态')
478
- .action(async ({ session, options }, uid, ...guildId) => {
478
+ .action(async ({ session }, uid, ...guildId) => {
479
479
  this.logger.info('调用bili.dynamic指令');
480
- this.logger.info('Platform:', options.bot);
481
480
  // 如果uid为空则返回
482
481
  if (!uid)
483
482
  return `${uid}非法调用 dynamic 指令`; // 用户uid不能为空
484
483
  if (!guildId)
485
484
  return `${uid}非法调用 dynamic 指令`; // 目标群组或频道不能为空
486
- if (!options.bot) {
487
- this.logger.warn(`${uid}非法调用 dynamic 指令,未传入订阅平台`);
488
- return `${uid}非法调用 dynamic 指令`;
489
- }
485
+ /* if (!options.bot) {
486
+ this.logger.warn(`${uid}非法调用 dynamic 指令,未传入订阅平台`)
487
+ return `${uid}非法调用 dynamic 指令`
488
+ } */
490
489
  // 寻找对应订阅管理对象
491
490
  const index = this.subManager.findIndex(sub => sub.uid === uid);
492
491
  // 不存在则直接返回
493
- if (index === -1) {
494
- session.send('请勿直接调用该指令');
495
- return;
496
- }
492
+ if (index === -1)
493
+ return '请勿直接调用该指令';
497
494
  // 获取对应Bot
498
495
  let bot;
499
- switch (options.bot) {
496
+ switch (session.event.platform) {
500
497
  case 'qq':
501
498
  bot = this.qqBot;
502
499
  break;
@@ -524,29 +521,27 @@ class ComRegister {
524
521
  });
525
522
  biliCom
526
523
  .subcommand('.live <roomId:string> <...guildId:string>', '订阅主播开播通知', { hidden: true })
527
- .option('bot', '-b <type:string>')
524
+ // .option('bot', '-b <type:string>')
528
525
  .usage('订阅主播开播通知')
529
526
  .example('bili live 26316137 订阅房间号为26316137的直播间')
530
- .action(async ({ options }, roomId, ...guildId) => {
527
+ .action(async ({ session }, roomId, ...guildId) => {
531
528
  this.logger.info('调用bili.live指令');
532
- this.logger.info('Platform:', options.bot);
533
529
  // 如果room_id为空则返回
534
530
  if (!roomId)
535
531
  return `${roomId}非法调用 dynamic 指令`; // 订阅主播房间号不能为空
536
532
  if (!guildId)
537
533
  return `${roomId}非法调用 dynamic 指令`; // 目标群组或频道不能为空
538
- if (!options.bot) {
539
- this.logger.warn(`${roomId}非法调用 dynamic 指令,未传入推送平台`);
540
- return `${roomId}非法调用 dynamic 指令`;
541
- }
542
- // 保存到订阅管理对象
543
- const index = this.subManager.findIndex(sub => sub.roomId === roomId);
534
+ /* if (!options.bot) {
535
+ this.logger.warn(`${roomId}非法调用 dynamic 指令,未传入推送平台`)
536
+ return `${roomId}非法调用 dynamic 指令`
537
+ } */
544
538
  // 要订阅的对象不在订阅管理对象中,直接返回
539
+ const index = this.subManager.findIndex(sub => sub.roomId === roomId);
545
540
  if (index === -1)
546
541
  return '请勿直接调用该指令';
547
542
  // 获取对应Bot
548
543
  let bot;
549
- switch (options.bot) {
544
+ switch (session.event.platform) {
550
545
  case 'qq':
551
546
  bot = this.qqBot;
552
547
  break;
@@ -678,7 +673,8 @@ class ComRegister {
678
673
  if (e.message === '直播开播动态,不做处理')
679
674
  break;
680
675
  if (e.message === '出现关键词,屏蔽该动态') {
681
- await this.sendMsg(guildId, bot, `UID:${uid} 发布了一条含有屏蔽关键字的动态`);
676
+ // 如果需要发送才发送
677
+ this.config.filter.notify && await this.sendMsg(guildId, bot, `UID:${uid} 发布了一条含有屏蔽关键字的动态`);
682
678
  break;
683
679
  }
684
680
  }
@@ -1065,6 +1061,7 @@ class ComRegister {
1065
1061
  uid: sub.uid,
1066
1062
  roomId: sub.room_id,
1067
1063
  targetId: sub.targetId,
1064
+ platform: sub.platform,
1068
1065
  live: +sub.live === 1 ? true : false,
1069
1066
  dynamic: +sub.dynamic === 1 ? true : false,
1070
1067
  liveDispose: null,
@@ -1171,7 +1168,13 @@ class ComRegister {
1171
1168
  customLiveStart: koishi_1.Schema.string().required(),
1172
1169
  customLiveEnd: koishi_1.Schema.string().required(),
1173
1170
  dynamicLoopTime: koishi_1.Schema.number().default(60),
1174
- dynamicCheckNumber: koishi_1.Schema.number().required()
1171
+ dynamicCheckNumber: koishi_1.Schema.number().required(),
1172
+ filter: koishi_1.Schema.object({
1173
+ enable: koishi_1.Schema.boolean(),
1174
+ regex: koishi_1.Schema.string(),
1175
+ keywords: koishi_1.Schema.array(String),
1176
+ notify: koishi_1.Schema.boolean(),
1177
+ }),
1175
1178
  });
1176
1179
  })(ComRegister || (ComRegister = {}));
1177
1180
  exports.default = ComRegister;
@@ -37,7 +37,6 @@ declare namespace GenerateImg {
37
37
  enable: boolean;
38
38
  regex: string;
39
39
  keywords: Array<string>;
40
- filter: boolean;
41
40
  };
42
41
  removeBorder: boolean;
43
42
  cardColorStart: string;
@@ -1367,7 +1367,7 @@ class GenerateImg extends koishi_1.Service {
1367
1367
  enable: koishi_1.Schema.boolean(),
1368
1368
  regex: koishi_1.Schema.string(),
1369
1369
  keywords: koishi_1.Schema.array(String),
1370
- filter: koishi_1.Schema.boolean()
1370
+ notify: koishi_1.Schema.boolean(),
1371
1371
  }),
1372
1372
  removeBorder: koishi_1.Schema.boolean(),
1373
1373
  cardColorStart: koishi_1.Schema.string(),
package/lib/index.js CHANGED
@@ -114,7 +114,9 @@ exports.Config = koishi_1.Schema.object({
114
114
  regex: koishi_1.Schema.string()
115
115
  .description('正则表达式屏蔽'),
116
116
  keywords: koishi_1.Schema.array(String)
117
- .description('关键字屏蔽,一个关键字为一项')
117
+ .description('关键字屏蔽,一个关键字为一项'),
118
+ notify: koishi_1.Schema.boolean()
119
+ .description('动态被屏蔽是否发送提示')
118
120
  }),
119
121
  koishi_1.Schema.object({})
120
122
  ])
@@ -182,12 +184,13 @@ function apply(ctx, config) {
182
184
  customLiveStart: config.customLiveStart,
183
185
  customLiveEnd: config.customLiveEnd,
184
186
  dynamicCheckNumber: config.dynamicCheckNumber,
185
- dynamicLoopTime
187
+ dynamicLoopTime,
188
+ filter: config.filter
186
189
  });
187
190
  // 当用户输入“恶魔兔,启动!”时,执行 help 指令
188
191
  ctx.middleware((session, next) => {
189
192
  if (session.content === '恶魔兔,启动!') {
190
- return session.execute('help', next);
193
+ return session.send('启动不了一点');
191
194
  }
192
195
  else {
193
196
  return next();
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.3",
4
+ "version": "1.2.0-rc.5",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -111,6 +111,8 @@
111
111
  - ver 1.2.0-rc.1 现已支持Telegram平台(实验性)
112
112
  - ver 1.2.0-rc.2 添加更多日志输出
113
113
  - ver 1.2.0-rc.3 针对Telegram的Bug测试版本
114
+ - ver 1.2.0-rc.4 修复了一个订阅指令的bug
115
+ - ver 1.2.0-rc.5 屏蔽动态设置新增是否发送动态被屏蔽消息的选项
114
116
 
115
117
  ## 交流群
116
118
  801338523 使用问题或bug都可以在群里提出