koishi-plugin-bilibili-notify 1.2.3-alpha.0 → 1.2.3-beta.0

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.
@@ -26,8 +26,8 @@ declare class ComRegister {
26
26
  satoriBot: Bot<Context>;
27
27
  chronocatBot: Bot<Context>;
28
28
  constructor(ctx: Context, config: ComRegister.Config);
29
- sendErr(guildId: Array<string>, bot: Bot<Context>, content: string): Promise<void>;
30
- sendErrAndRebootService(guildId: Array<string>, bot: Bot<Context>, ctx: Context, content: string): void;
29
+ sendPrivateMsg(bot: Bot<Context>, content: string): Promise<void>;
30
+ sendPrivateMsgAndRebootService(bot: Bot<Context>, ctx: Context, content: string): Promise<void>;
31
31
  dynamicDetect(ctx: Context, bot: Bot<Context>, uid: string, guildId: Array<string>): () => Promise<void>;
32
32
  sendMsg(targets: Array<string>, bot: Bot<Context>, content: any): Promise<void>;
33
33
  liveDetect(ctx: Context, bot: Bot<Context>, roomId: string, guildId: Array<string>): () => Promise<void>;
@@ -652,8 +652,14 @@ class ComRegister {
652
652
  this.logger.info('--------------------------------');
653
653
  });
654
654
  });
655
+ biliCom
656
+ .subcommand('.private', '向主人账号发送一条测试消息', { hidden: true })
657
+ .usage('向主人账号发送一条测试消息')
658
+ .example('bili private 向主人账号发送一条测试消息')
659
+ .action(() => {
660
+ });
655
661
  }
656
- async sendErr(guildId, bot, content) {
662
+ async sendPrivateMsg(bot, content) {
657
663
  if (this.config.master.enable) {
658
664
  if (this.config.master.masterAccountGuildId) {
659
665
  // 向机器人主人发送消息
@@ -664,12 +670,9 @@ class ComRegister {
664
670
  await bot.sendPrivateMessage(this.config.master.masterAccount, content);
665
671
  }
666
672
  }
667
- else {
668
- await this.sendMsg(guildId, bot, content);
669
- }
670
673
  }
671
- sendErrAndRebootService(guildId, bot, ctx, content) {
672
- this.sendErr(guildId, bot, content);
674
+ async sendPrivateMsgAndRebootService(bot, ctx, content) {
675
+ await this.sendPrivateMsg(bot, content);
673
676
  // 停用插件
674
677
  ctx.sm.disposePlugin();
675
678
  // 隔一秒启动插件
@@ -701,11 +704,10 @@ class ComRegister {
701
704
  if (content.code !== 0) {
702
705
  switch (content.code) {
703
706
  case -101: { // 账号未登录
704
- await this.sendMsg(guildId, bot, '账号未登录,请登录后重新订阅动态');
705
- }
706
- default: { // 未知错误
707
- await this.sendMsg(guildId, bot, '未知错误,请重新订阅动态');
707
+ await this.sendPrivateMsg(bot, '账号未登录,请登录后重新订阅动态');
708
+ break;
708
709
  }
710
+ default: await this.sendPrivateMsg(bot, '未知错误,请重新订阅动态'); // 未知错误
709
711
  }
710
712
  // 取消订阅
711
713
  this.unsubSingle(ctx, uid, 1); /* 1为取消动态订阅 */
@@ -773,7 +775,7 @@ class ComRegister {
773
775
  bot,
774
776
  '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈'
775
777
  ) */
776
- this.sendErrAndRebootService(guildId, bot, ctx, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
778
+ return await this.sendPrivateMsgAndRebootService(bot, ctx, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
777
779
  }
778
780
  }
779
781
  }
@@ -844,7 +846,7 @@ class ComRegister {
844
846
  bot,
845
847
  '插件可能出现某些未知错误,已自动重启插件,如果仍然发生该错误,请带着日志向作者反馈'
846
848
  ) */
847
- this.sendErrAndRebootService(guildId, bot, ctx, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
849
+ return await this.sendPrivateMsgAndRebootService(bot, ctx, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
848
850
  }
849
851
  }
850
852
  }
@@ -873,7 +875,7 @@ class ComRegister {
873
875
  bot,
874
876
  '你的网络可能出现了某些问题,请检查后重启插件',
875
877
  ) */
876
- this.sendErrAndRebootService(guildId, bot, ctx, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
878
+ return await this.sendPrivateMsgAndRebootService(bot, ctx, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
877
879
  }
878
880
  }
879
881
  }
@@ -900,7 +902,7 @@ class ComRegister {
900
902
  bot,
901
903
  '你的网络可能出现了某些问题,请检查后重启插件',
902
904
  ) */
903
- this.sendErrAndRebootService(guildId, bot, ctx, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
905
+ return await this.sendPrivateMsgAndRebootService(bot, ctx, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
904
906
  }
905
907
  }
906
908
  }
@@ -961,7 +963,7 @@ class ComRegister {
961
963
  bot,
962
964
  '你的网络可能出现了某些问题,请检查后重启插件',
963
965
  ) */
964
- this.sendErrAndRebootService(guildId, bot, ctx, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
966
+ return await this.sendPrivateMsgAndRebootService(bot, ctx, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
965
967
  }
966
968
  }
967
969
  }
@@ -1149,7 +1151,7 @@ class ComRegister {
1149
1151
  // 不支持的协议
1150
1152
  this.logger.info(`UID:${sub.uid} 出现不支持的协议,该条数据被篡改,自动取消订阅`);
1151
1153
  // 发送消息
1152
- await this.sendErr(targetArr, bot, `UID:${sub.uid} 出现不支持的协议,该条数据被篡改,自动取消订阅`);
1154
+ await this.sendPrivateMsg(bot, `UID:${sub.uid} 出现不支持的协议,该条数据被篡改,自动取消订阅`);
1153
1155
  // 继续下个循环
1154
1156
  continue;
1155
1157
  }
@@ -1173,7 +1175,7 @@ class ComRegister {
1173
1175
  bot,
1174
1176
  '你的网络可能出现了某些问题,请检查后重启插件'
1175
1177
  ) */
1176
- this.sendErrAndRebootService(targetArr, bot, ctx, '你的网络可能出现了某些问题,请检查后重启插件');
1178
+ return await this.sendPrivateMsgAndRebootService(bot, ctx, '你的网络可能出现了某些问题,请检查后重启插件');
1177
1179
  }
1178
1180
  }
1179
1181
  }
@@ -1184,7 +1186,7 @@ class ComRegister {
1184
1186
  // 从数据库删除该条数据
1185
1187
  await ctx.database.remove('bilibili', { id: sub.id });
1186
1188
  // 给用户发送提示
1187
- await this.sendErr(targetArr, bot, `UID:${sub.uid} 数据库内容被篡改,已取消对该UP主的订阅`);
1189
+ await this.sendPrivateMsg(bot, `UID:${sub.uid} 数据库内容被篡改,已取消对该UP主的订阅`);
1188
1190
  /* await this.sendMsg(
1189
1191
  targetArr,
1190
1192
  bot,
@@ -1196,7 +1198,7 @@ class ComRegister {
1196
1198
  switch (content.code) {
1197
1199
  case -352:
1198
1200
  case -403: {
1199
- await this.sendErr(targetArr, bot, '你的登录信息已过期,请重新登录Bilibili');
1201
+ await this.sendPrivateMsg(bot, '你的登录信息已过期,请重新登录Bilibili');
1200
1202
  /* this.sendMsg(
1201
1203
  targetArr,
1202
1204
  bot,
@@ -1208,6 +1210,8 @@ class ComRegister {
1208
1210
  case -404:
1209
1211
  default: {
1210
1212
  await deleteSub();
1213
+ // PrivateMsg
1214
+ await this.sendPrivateMsg(bot, `UID:${sub.uid} 数据出现问题,自动取消订阅`);
1211
1215
  // log
1212
1216
  this.logger.info(`UID:${sub.uid} 数据出现问题,自动取消订阅`);
1213
1217
  return;
@@ -1221,7 +1225,7 @@ class ComRegister {
1221
1225
  // log
1222
1226
  this.logger.info(`UID:${sub.uid} 房间号被篡改,自动取消订阅`);
1223
1227
  // Send msg
1224
- await this.sendErr(targetArr, bot, `UID:${sub.uid} 房间号被篡改,自动取消订阅`);
1228
+ await this.sendPrivateMsg(bot, `UID:${sub.uid} 房间号被篡改,自动取消订阅`);
1225
1229
  return;
1226
1230
  }
1227
1231
  // 构建订阅对象
package/lib/index.js CHANGED
@@ -51,7 +51,7 @@ exports.Config = koishi_1.Schema.object({
51
51
  koishi_1.Schema.object({
52
52
  enable: koishi_1.Schema.boolean()
53
53
  .default(false)
54
- .description('是否开启主人账号功能')
54
+ .description('是否开启主人账号功能,如果您的机器人没有私聊权限请不要开启此功能。开启后如果机器人运行错误会向您进行报告')
55
55
  .experimental()
56
56
  }).description('主人账号'),
57
57
  koishi_1.Schema.union([
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.3-alpha.0",
4
+ "version": "1.2.3-beta.0",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
File without changes
File without changes