koishi-plugin-bilibili-notify 3.2.5-alpha.4 → 3.2.5-alpha.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.
package/lib/index.js CHANGED
@@ -791,24 +791,43 @@ var ComRegister = class {
791
791
  }
792
792
  getGroupsThatMeetCriteria(targets, type) {
793
793
  const pushArr = [];
794
- if (type === PushType.Live || type === PushType.StartBroadcasting) {
794
+ if (type === PushType.StartBroadcasting) {
795
+ const atAllArr = [];
796
+ for (const target of targets) for (const channel of target.channelArr) {
797
+ if (channel.atAll && channel.dynamic) {
798
+ atAllArr.push(`${target.platform}:${channel.channelId}`);
799
+ continue;
800
+ }
801
+ if (channel.dynamic) pushArr.push(`${target.platform}:${channel.channelId}`);
802
+ }
803
+ return [pushArr, atAllArr];
804
+ }
805
+ if (type === PushType.Live) {
795
806
  for (const target of targets) for (const channel of target.channelArr) if (channel.live) pushArr.push(`${target.platform}:${channel.channelId}`);
796
- return pushArr;
807
+ return [pushArr];
797
808
  }
798
809
  if (type === PushType.Dynamic) {
799
810
  for (const target of targets) for (const channel of target.channelArr) if (channel.dynamic) pushArr.push(`${target.platform}:${channel.channelId}`);
800
- return pushArr;
811
+ return [pushArr];
801
812
  }
802
813
  if (type === PushType.LiveGuardBuy) {
803
814
  for (const target of targets) for (const channel of target.channelArr) if (channel.liveGuardBuy) pushArr.push(`${target.platform}:${channel.channelId}`);
804
- return pushArr;
815
+ return [pushArr];
805
816
  }
806
817
  }
807
818
  async broadcastToTargets(targets, content, type) {
808
819
  if (targets.length !== 1 || targets[0].channelArr.length !== 1) {
809
- const pushArr = this.getGroupsThatMeetCriteria(targets, type);
820
+ const [pushArr, atAllArr] = this.getGroupsThatMeetCriteria(targets, type);
810
821
  this.logger.info(`推送消息到 ${pushArr.length} 个目标频道,目标频道为:${pushArr.join(", ")}`);
811
- await withRetry(async () => {
822
+ if (type === PushType.StartBroadcasting && atAllArr?.length >= 1) {
823
+ await withRetry(async () => {
824
+ await this.ctx.broadcast(atAllArr, koishi.h.at("all"));
825
+ }, 1);
826
+ await withRetry(async () => {
827
+ await this.ctx.broadcast(atAllArr, content);
828
+ }, 1);
829
+ }
830
+ if (pushArr?.length >= 1) await withRetry(async () => {
812
831
  await this.ctx.broadcast(pushArr, content);
813
832
  }, 1);
814
833
  return;
package/lib/index.mjs CHANGED
@@ -793,24 +793,43 @@ var ComRegister = class {
793
793
  }
794
794
  getGroupsThatMeetCriteria(targets, type) {
795
795
  const pushArr = [];
796
- if (type === PushType.Live || type === PushType.StartBroadcasting) {
796
+ if (type === PushType.StartBroadcasting) {
797
+ const atAllArr = [];
798
+ for (const target of targets) for (const channel of target.channelArr) {
799
+ if (channel.atAll && channel.dynamic) {
800
+ atAllArr.push(`${target.platform}:${channel.channelId}`);
801
+ continue;
802
+ }
803
+ if (channel.dynamic) pushArr.push(`${target.platform}:${channel.channelId}`);
804
+ }
805
+ return [pushArr, atAllArr];
806
+ }
807
+ if (type === PushType.Live) {
797
808
  for (const target of targets) for (const channel of target.channelArr) if (channel.live) pushArr.push(`${target.platform}:${channel.channelId}`);
798
- return pushArr;
809
+ return [pushArr];
799
810
  }
800
811
  if (type === PushType.Dynamic) {
801
812
  for (const target of targets) for (const channel of target.channelArr) if (channel.dynamic) pushArr.push(`${target.platform}:${channel.channelId}`);
802
- return pushArr;
813
+ return [pushArr];
803
814
  }
804
815
  if (type === PushType.LiveGuardBuy) {
805
816
  for (const target of targets) for (const channel of target.channelArr) if (channel.liveGuardBuy) pushArr.push(`${target.platform}:${channel.channelId}`);
806
- return pushArr;
817
+ return [pushArr];
807
818
  }
808
819
  }
809
820
  async broadcastToTargets(targets, content, type) {
810
821
  if (targets.length !== 1 || targets[0].channelArr.length !== 1) {
811
- const pushArr = this.getGroupsThatMeetCriteria(targets, type);
822
+ const [pushArr, atAllArr] = this.getGroupsThatMeetCriteria(targets, type);
812
823
  this.logger.info(`推送消息到 ${pushArr.length} 个目标频道,目标频道为:${pushArr.join(", ")}`);
813
- await withRetry(async () => {
824
+ if (type === PushType.StartBroadcasting && atAllArr?.length >= 1) {
825
+ await withRetry(async () => {
826
+ await this.ctx.broadcast(atAllArr, h.at("all"));
827
+ }, 1);
828
+ await withRetry(async () => {
829
+ await this.ctx.broadcast(atAllArr, content);
830
+ }, 1);
831
+ }
832
+ if (pushArr?.length >= 1) await withRetry(async () => {
814
833
  await this.ctx.broadcast(pushArr, content);
815
834
  }, 1);
816
835
  return;
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.2.5-alpha.4",
4
+ "version": "3.2.5-alpha.5",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -283,6 +283,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
283
283
  > - ver 3.2.5-alpha.2 测试版本
284
284
  > - ver 3.2.5-alpha.3 更新依赖版本
285
285
  > - ver 3.2.5-alpha.4 测试版本
286
+ > - ver 3.2.5-alpha.5 测试版本
286
287
 
287
288
  ## 交流群
288
289