koishi-plugin-bilibili-notify 3.1.0-alpha.0 → 3.1.0-alpha.1

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.
@@ -23,7 +23,7 @@ declare class ComRegister {
23
23
  sendPrivateMsg(content: string): Promise<void>;
24
24
  sendPrivateMsgAndRebootService(): Promise<void>;
25
25
  sendPrivateMsgAndStopService(): Promise<void>;
26
- sendMessageWithRetry(broadcastTarget: string[], content: any): Promise<void>;
26
+ sendMessageWithRetry(bot: Bot<Context>, channelId: string, content: any): Promise<void>;
27
27
  broadcastToTargets(targets: Target, content: any, live?: boolean): Promise<void>;
28
28
  dynamicDetect(): (...args: any[]) => void;
29
29
  debug_dynamicDetect(): (...args: any[]) => void;
@@ -50,7 +50,7 @@ declare namespace ComRegister {
50
50
  dynamic: boolean;
51
51
  live: boolean;
52
52
  target: Array<{
53
- channelIdArr: Array<{
53
+ channelArr: Array<{
54
54
  channelId: string;
55
55
  dynamic: boolean;
56
56
  live: boolean;
@@ -339,7 +339,7 @@ class ComRegister {
339
339
  // Test
340
340
  const testTarget = [
341
341
  {
342
- channelIdArr: [
342
+ channelArr: [
343
343
  {
344
344
  channelId: "635762054",
345
345
  dynamic: true,
@@ -405,71 +405,71 @@ class ComRegister {
405
405
  // 结束
406
406
  return;
407
407
  }
408
- async sendMessageWithRetry(broadcastTarget,
408
+ async sendMessageWithRetry(bot, channelId,
409
409
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
410
410
  content) {
411
- (0, utils_1.withRetry)(async () => await this.ctx.broadcast(broadcastTarget, content), 1).catch(async (e) => {
411
+ (0, utils_1.withRetry)(async () => await bot.sendMessage(channelId, content), 1).catch(async (e) => {
412
412
  if (e.message === "this._request is not a function") {
413
413
  // 2S之后重新发送消息
414
414
  this.ctx.setTimeout(async () => {
415
- await this.sendMessageWithRetry(broadcastTarget, content);
415
+ await this.sendMessageWithRetry(bot, channelId, content);
416
416
  }, 2000);
417
417
  // 返回
418
418
  return;
419
419
  }
420
420
  // 打印错误信息
421
- this.logger.error(`发送群组ID:${broadcastTarget[0]}消息失败!原因: ${e.message}`);
422
- await this.sendPrivateMsg(`发送群组ID:${broadcastTarget[0]}消息失败,请查看日志`);
421
+ this.logger.error(`发送群组ID:${channelId}消息失败!原因: ${e.message}`);
422
+ await this.sendPrivateMsg(`发送群组ID:${channelId}消息失败,请查看日志`);
423
423
  });
424
424
  }
425
- ;
426
425
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
427
426
  async broadcastToTargets(targets, content, live) {
428
427
  for (const target of targets) {
429
428
  // 获取机器人实例
430
429
  const bot = this.getBot(target.platform);
431
430
  // 定义需要发送的数组
432
- let sendArr = [];
431
+ let channelArr = [];
433
432
  // 判断是否需要推送所有机器人加入的群
434
- if (target.channelIdArr[0].channelId === "all") {
433
+ if (target.channelArr[0].channelId === "all") {
435
434
  // 获取所有guild
436
435
  for (const guild of (await bot.getGuildList()).data) {
437
- sendArr.push({
436
+ channelArr.push({
438
437
  channelId: guild.id,
439
- dynamic: target.channelIdArr[0].dynamic,
440
- live: target.channelIdArr[0].live,
441
- liveGuardBuy: target.channelIdArr[0].liveGuardBuy,
442
- atAll: target.channelIdArr[0].atAll,
438
+ dynamic: target.channelArr[0].dynamic,
439
+ live: target.channelArr[0].live,
440
+ liveGuardBuy: target.channelArr[0].liveGuardBuy,
441
+ atAll: target.channelArr[0].atAll,
443
442
  });
444
443
  }
445
444
  }
446
445
  else {
447
- sendArr = target.channelIdArr;
446
+ channelArr = target.channelArr;
448
447
  }
449
448
  // 判断是否是直播开播推送,如果是则需要进一步判断是否需要艾特群体成员
450
449
  if (live) {
451
450
  // 直播开播推送,判断是否需要艾特全体成员
452
- for (const channel of sendArr) {
453
- // 构建广播目标
454
- const broadcastTarget = [`${target.platform}:${channel.channelId}`];
451
+ for (const channel of channelArr) {
455
452
  // 判断是否需要推送直播消息
456
453
  if (channel.live) {
457
- await this.sendMessageWithRetry(broadcastTarget, content);
454
+ await this.sendMessageWithRetry(bot, channel.channelId, content);
458
455
  }
459
456
  // 判断是否需要艾特全体成员
460
457
  if (channel.atAll) {
461
- await this.sendMessageWithRetry(broadcastTarget, (0, jsx_runtime_1.jsx)("at", { type: "all" }));
458
+ await this.sendMessageWithRetry(bot, channel.channelId, (0, jsx_runtime_1.jsx)("at", { type: "all" }));
462
459
  }
460
+ // 延迟发送
461
+ await this.ctx.sleep(500);
463
462
  }
464
463
  }
465
464
  else {
466
- for (const channel of sendArr) {
467
- // 构建广播目标
468
- const broadcastTarget = [`${target.platform}:${channel.channelId}`];
465
+ // 不是直播开播推送
466
+ for (const channel of channelArr) {
469
467
  // 判断是否需要推送动态消息
470
468
  if (channel.dynamic || channel.live) {
471
- await this.sendMessageWithRetry(broadcastTarget, content);
469
+ await this.sendMessageWithRetry(bot, channel.channelId, content);
472
470
  }
471
+ // 延迟发送
472
+ await this.ctx.sleep(500);
473
473
  }
474
474
  }
475
475
  }
@@ -953,7 +953,7 @@ class ComRegister {
953
953
  let liveStatus = false;
954
954
  // 处理target
955
955
  // 定义channelIdArr总长度
956
- let channelIdArrLen = 0;
956
+ let channelArrLen = 0;
957
957
  // 定义数据
958
958
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
959
959
  let liveRoomInfo;
@@ -979,12 +979,12 @@ class ComRegister {
979
979
  // 找到频道/群组对应的
980
980
  const liveGuardBuyPushTargetArr = target.map((channel) => {
981
981
  // 获取符合条件的target
982
- const liveGuardBuyArr = channel.channelIdArr.filter((channelId) => channelId.liveGuardBuy);
982
+ const liveGuardBuyArr = channel.channelArr.filter((channelId) => channelId.liveGuardBuy);
983
983
  // 将当前liveDanmakuArr的长度+到channelIdArrLen中
984
- channelIdArrLen += liveGuardBuyArr.length;
984
+ channelArrLen += liveGuardBuyArr.length;
985
985
  // 返回符合的target
986
986
  return {
987
- channelIdArr: liveGuardBuyArr,
987
+ channelArr: liveGuardBuyArr,
988
988
  platform: channel.platform,
989
989
  };
990
990
  });
@@ -1057,7 +1057,8 @@ class ComRegister {
1057
1057
  // 定义消息
1058
1058
  const content = `[${masterInfo.username}的直播间]「${body.user.uname}」加入了大航海(${body.gift_name})`;
1059
1059
  // 直接发送消息
1060
- channelIdArrLen > 0 && this.broadcastToTargets(liveGuardBuyPushTargetArr, content);
1060
+ channelArrLen > 0 &&
1061
+ this.broadcastToTargets(liveGuardBuyPushTargetArr, content);
1061
1062
  },
1062
1063
  onLiveStart: async () => {
1063
1064
  // 判断是否已经开播
@@ -1502,7 +1503,7 @@ class ComRegister {
1502
1503
  dynamic: koishi_1.Schema.boolean().description("是否订阅用户动态"),
1503
1504
  live: koishi_1.Schema.boolean().description("是否订阅用户直播"),
1504
1505
  target: koishi_1.Schema.array(koishi_1.Schema.object({
1505
- channelIdArr: koishi_1.Schema.array(koishi_1.Schema.object({
1506
+ channelArr: koishi_1.Schema.array(koishi_1.Schema.object({
1506
1507
  channelId: koishi_1.Schema.string().description("频道/群组号"),
1507
1508
  dynamic: koishi_1.Schema.boolean().description("该频道/群组是否推送动态信息"),
1508
1509
  live: koishi_1.Schema.boolean().description("该频道/群组是否推送直播通知"),
package/lib/index.d.ts CHANGED
@@ -30,7 +30,7 @@ export interface Config {
30
30
  live: boolean;
31
31
  card: {};
32
32
  target: Array<{
33
- channelIdArr: Array<{
33
+ channelArr: Array<{
34
34
  channelId: string;
35
35
  dynamic: boolean;
36
36
  live: boolean;
package/lib/index.js CHANGED
@@ -196,12 +196,13 @@ function apply(ctx, config) {
196
196
  // 设置提示
197
197
  ctx.notifier.create({
198
198
  type: "danger",
199
- content: "3.0.0-alpha.16 全面从指令订阅迁移到配置订阅,以前使用指令的订阅需要全部重新填写到订阅配置中",
199
+ content: "3.1.0-alpha.0及以前版本升级到3.1.0-alpha.1版本必定报错,请重新填写订阅配置中sub.target.channelArr的内容",
200
200
  });
201
201
  ctx.notifier.create({
202
202
  type: "warning",
203
203
  content: "请使用Auth插件创建超级管理员账号,没有权限将无法使用该插件提供的指令",
204
204
  });
205
+ ctx.logger.warn("从3.1.0-alpha.0及以前版本升级到3.1.0-alpha.1版本必定报错,请重新填写订阅配置中sub.target.channelArr的内容");
205
206
  // load database
206
207
  ctx.plugin(Database);
207
208
  // Register ServerManager
@@ -269,7 +270,7 @@ exports.Config = koishi_1.Schema.object({
269
270
  platform: koishi_1.Schema.string()
270
271
  .required()
271
272
  .description("推送平台,例如onebot、qq、discord"),
272
- channelIdArr: koishi_1.Schema.array(koishi_1.Schema.object({
273
+ channelArr: koishi_1.Schema.array(koishi_1.Schema.object({
273
274
  channelId: koishi_1.Schema.string().required().description("频道/群组号"),
274
275
  dynamic: koishi_1.Schema.boolean()
275
276
  .default(false)
@@ -5,7 +5,7 @@ export declare enum LiveType {
5
5
  StopBroadcast = 3,
6
6
  FirstLiveBroadcast = 4
7
7
  }
8
- export type ChannelIdArr = Array<{
8
+ export type ChannelArr = Array<{
9
9
  channelId: string;
10
10
  dynamic: boolean;
11
11
  live: boolean;
@@ -13,7 +13,7 @@ export type ChannelIdArr = Array<{
13
13
  atAll: boolean;
14
14
  }>;
15
15
  export type TargetItem = {
16
- channelIdArr: ChannelIdArr;
16
+ channelArr: ChannelArr;
17
17
  platform: string;
18
18
  };
19
19
  export type Target = Array<TargetItem>;
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.1.0-alpha.0",
4
+ "version": "3.1.0-alpha.1",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -231,6 +231,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
231
231
  - ver 3.0.5-alpha.1 优化:推送卡片渲染,调整渲染图片格式为 `jpeg`
232
232
  - ver 3.0.5-alpha.2 优化:移除多余依赖
233
233
  - ver 3.1.0-alpha.0 修复:新插件在第一次订阅时提示 `订阅失败,错误信息:该分组已经存在`; 移除:消息重发功能; 重构:将消息发送模式改为 `broadcast`
234
+ - ver 3.1.0-alpha.1 修复:无法发送 `@全体成员` 消息,将消息发送模式改回
234
235
 
235
236
  ## 交流群
236
237