koishi-plugin-bilibili-notify 3.2.5-alpha.7 → 3.2.5-alpha.9

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
@@ -820,34 +820,47 @@ var ComRegister = class {
820
820
  this.logger.info("初始化推送群组/频道信息:");
821
821
  this.logger.info(this.pushRecord);
822
822
  }
823
- async broadcastToTargets(uid, content, type) {
823
+ checkAllBotsAreReady() {
824
+ return !this.ctx.bots.some((bot) => bot.status !== koishi.Universal.Status.ONLINE);
825
+ }
826
+ async broadcastToTargets(uid, content, type, retry = 3e3) {
827
+ if (!this.checkAllBotsAreReady()) {
828
+ this.logger.error(`有机器人未准备好,无法进行推送,${retry / 1e3}秒后重试`);
829
+ this.ctx.setTimeout(() => {
830
+ this.broadcastToTargets(uid, content, type, retry * 2);
831
+ }, retry);
832
+ return;
833
+ }
824
834
  this.logger.info(`本次推送对象:${uid},推送类型:${PushTypeMsg[type]}`);
825
835
  const record = this.pushRecord[uid];
826
836
  this.logger.info("本次推送目标:");
827
- this.logger.info(record);
828
837
  if (type === PushType.StartBroadcasting && record.atAllArr?.length >= 1) {
838
+ this.logger.info(record.atAllArr);
829
839
  const success = await withRetry(async () => {
830
840
  return await this.ctx.broadcast(record.atAllArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsxs)("message", { children: [/* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("at", { type: "all" }), /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content })] }));
831
841
  }, 1);
832
842
  this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
833
843
  }
834
844
  if (type === PushType.Dynamic && record.dynamicArr?.length >= 1) {
845
+ this.logger.info(record.dynamicArr);
835
846
  const success = await withRetry(async () => {
836
847
  return await this.ctx.broadcast(record.dynamicArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
837
848
  }, 1);
838
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
849
+ this.logger.info(`成功推送动态消息群组/频道:${success}`);
839
850
  }
840
851
  if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length >= 1) {
852
+ this.logger.info(record.liveArr);
841
853
  const success = await withRetry(async () => {
842
854
  return await this.ctx.broadcast(record.liveArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
843
855
  }, 1);
844
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
856
+ this.logger.info(`成功推送直播消息群组/频道:${success}`);
845
857
  }
846
858
  if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length >= 1) {
859
+ this.logger.info(record.liveGuardBuyArr);
847
860
  const success = await withRetry(async () => {
848
861
  return await this.ctx.broadcast(record.liveGuardBuyArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
849
862
  }, 1);
850
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
863
+ this.logger.info(`成功推送上舰消息群组/频道:${success}`);
851
864
  }
852
865
  return;
853
866
  }
package/lib/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
- import { Schema, Service, h, isNullable, remove } from "koishi";
2
+ import { Schema, Service, Universal, h, isNullable, remove } from "koishi";
3
3
  import { resolve } from "path";
4
4
  import QRCode from "qrcode";
5
5
  import { CronJob } from "cron";
@@ -822,34 +822,47 @@ var ComRegister = class {
822
822
  this.logger.info("初始化推送群组/频道信息:");
823
823
  this.logger.info(this.pushRecord);
824
824
  }
825
- async broadcastToTargets(uid, content, type) {
825
+ checkAllBotsAreReady() {
826
+ return !this.ctx.bots.some((bot) => bot.status !== Universal.Status.ONLINE);
827
+ }
828
+ async broadcastToTargets(uid, content, type, retry = 3e3) {
829
+ if (!this.checkAllBotsAreReady()) {
830
+ this.logger.error(`有机器人未准备好,无法进行推送,${retry / 1e3}秒后重试`);
831
+ this.ctx.setTimeout(() => {
832
+ this.broadcastToTargets(uid, content, type, retry * 2);
833
+ }, retry);
834
+ return;
835
+ }
826
836
  this.logger.info(`本次推送对象:${uid},推送类型:${PushTypeMsg[type]}`);
827
837
  const record = this.pushRecord[uid];
828
838
  this.logger.info("本次推送目标:");
829
- this.logger.info(record);
830
839
  if (type === PushType.StartBroadcasting && record.atAllArr?.length >= 1) {
840
+ this.logger.info(record.atAllArr);
831
841
  const success = await withRetry(async () => {
832
842
  return await this.ctx.broadcast(record.atAllArr, /* @__PURE__ */ jsxs("message", { children: [/* @__PURE__ */ jsx("at", { type: "all" }), /* @__PURE__ */ jsx("message", { children: content })] }));
833
843
  }, 1);
834
844
  this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
835
845
  }
836
846
  if (type === PushType.Dynamic && record.dynamicArr?.length >= 1) {
847
+ this.logger.info(record.dynamicArr);
837
848
  const success = await withRetry(async () => {
838
849
  return await this.ctx.broadcast(record.dynamicArr, /* @__PURE__ */ jsx("message", { children: content }));
839
850
  }, 1);
840
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
851
+ this.logger.info(`成功推送动态消息群组/频道:${success}`);
841
852
  }
842
853
  if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length >= 1) {
854
+ this.logger.info(record.liveArr);
843
855
  const success = await withRetry(async () => {
844
856
  return await this.ctx.broadcast(record.liveArr, /* @__PURE__ */ jsx("message", { children: content }));
845
857
  }, 1);
846
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
858
+ this.logger.info(`成功推送直播消息群组/频道:${success}`);
847
859
  }
848
860
  if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length >= 1) {
861
+ this.logger.info(record.liveGuardBuyArr);
849
862
  const success = await withRetry(async () => {
850
863
  return await this.ctx.broadcast(record.liveGuardBuyArr, /* @__PURE__ */ jsx("message", { children: content }));
851
864
  }, 1);
852
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
865
+ this.logger.info(`成功推送上舰消息群组/频道:${success}`);
853
866
  }
854
867
  return;
855
868
  }
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.7",
4
+ "version": "3.2.5-alpha.9",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -286,6 +286,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
286
286
  > - ver 3.2.5-alpha.5 测试版本
287
287
  > - ver 3.2.5-alpha.6 测试版本
288
288
  > - ver 3.2.5-alpha.7 测试版本
289
+ > - ver 3.2.5-alpha.8 测试版本
290
+ > - ver 3.2.5-alpha.9 测试版本
289
291
 
290
292
  ## 交流群
291
293