koishi-plugin-bilibili-notify 3.2.5-alpha.6 → 3.2.5-alpha.8

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
@@ -728,7 +728,6 @@ var ComRegister = class {
728
728
  }
729
729
  }
730
730
  this.initManager();
731
- this.initPushRecord(this.subManager);
732
731
  this.checkIfDynamicDetectIsNeeded();
733
732
  this.checkIfLiveDetectIsNeeded();
734
733
  this.updateSubNotifier();
@@ -821,34 +820,48 @@ var ComRegister = class {
821
820
  this.logger.info("初始化推送群组/频道信息:");
822
821
  this.logger.info(this.pushRecord);
823
822
  }
824
- async broadcastToTargets(uid, content, type) {
823
+ checkAllBotsAreReady() {
824
+ const bot = this.ctx.bots.some((bot$1) => !bot$1.isActive);
825
+ return !bot;
826
+ }
827
+ async broadcastToTargets(uid, content, type, retry = 3e3) {
828
+ if (!this.checkAllBotsAreReady()) {
829
+ this.logger.error(`有机器人未准备好,无法进行推送,${retry / 1e3}秒后重试`);
830
+ this.ctx.setTimeout(() => {
831
+ this.broadcastToTargets(uid, content, type, retry * 2);
832
+ }, retry);
833
+ return;
834
+ }
825
835
  this.logger.info(`本次推送对象:${uid},推送类型:${PushTypeMsg[type]}`);
826
836
  const record = this.pushRecord[uid];
827
837
  this.logger.info("本次推送目标:");
828
- this.logger.info(record);
829
838
  if (type === PushType.StartBroadcasting && record.atAllArr?.length >= 1) {
839
+ this.logger.info(record.atAllArr);
830
840
  const success = await withRetry(async () => {
831
841
  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 })] }));
832
842
  }, 1);
833
843
  this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
834
844
  }
835
845
  if (type === PushType.Dynamic && record.dynamicArr?.length >= 1) {
846
+ this.logger.info(record.dynamicArr);
836
847
  const success = await withRetry(async () => {
837
848
  return await this.ctx.broadcast(record.dynamicArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
838
849
  }, 1);
839
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
850
+ this.logger.info(`成功推送动态消息群组/频道:${success}`);
840
851
  }
841
852
  if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length >= 1) {
853
+ this.logger.info(record.liveArr);
842
854
  const success = await withRetry(async () => {
843
855
  return await this.ctx.broadcast(record.liveArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
844
856
  }, 1);
845
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
857
+ this.logger.info(`成功推送直播消息群组/频道:${success}`);
846
858
  }
847
859
  if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length >= 1) {
860
+ this.logger.info(record.liveGuardBuyArr);
848
861
  const success = await withRetry(async () => {
849
862
  return await this.ctx.broadcast(record.liveGuardBuyArr, /* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: content }));
850
863
  }, 1);
851
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
864
+ this.logger.info(`成功推送上舰消息群组/频道:${success}`);
852
865
  }
853
866
  return;
854
867
  }
@@ -1513,6 +1526,7 @@ var ComRegister = class {
1513
1526
  return await subUserMatchPattern[subUserData.code]();
1514
1527
  }
1515
1528
  async loadSubFromConfig(subs) {
1529
+ this.initPushRecord(subs);
1516
1530
  for (const sub of subs) {
1517
1531
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1518
1532
  const { code: userInfoCode, msg: userInfoMsg, data: userInfoData } = await withRetry(async () => {
package/lib/index.mjs CHANGED
@@ -730,7 +730,6 @@ var ComRegister = class {
730
730
  }
731
731
  }
732
732
  this.initManager();
733
- this.initPushRecord(this.subManager);
734
733
  this.checkIfDynamicDetectIsNeeded();
735
734
  this.checkIfLiveDetectIsNeeded();
736
735
  this.updateSubNotifier();
@@ -823,34 +822,48 @@ var ComRegister = class {
823
822
  this.logger.info("初始化推送群组/频道信息:");
824
823
  this.logger.info(this.pushRecord);
825
824
  }
826
- async broadcastToTargets(uid, content, type) {
825
+ checkAllBotsAreReady() {
826
+ const bot = this.ctx.bots.some((bot$1) => !bot$1.isActive);
827
+ return !bot;
828
+ }
829
+ async broadcastToTargets(uid, content, type, retry = 3e3) {
830
+ if (!this.checkAllBotsAreReady()) {
831
+ this.logger.error(`有机器人未准备好,无法进行推送,${retry / 1e3}秒后重试`);
832
+ this.ctx.setTimeout(() => {
833
+ this.broadcastToTargets(uid, content, type, retry * 2);
834
+ }, retry);
835
+ return;
836
+ }
827
837
  this.logger.info(`本次推送对象:${uid},推送类型:${PushTypeMsg[type]}`);
828
838
  const record = this.pushRecord[uid];
829
839
  this.logger.info("本次推送目标:");
830
- this.logger.info(record);
831
840
  if (type === PushType.StartBroadcasting && record.atAllArr?.length >= 1) {
841
+ this.logger.info(record.atAllArr);
832
842
  const success = await withRetry(async () => {
833
843
  return await this.ctx.broadcast(record.atAllArr, /* @__PURE__ */ jsxs("message", { children: [/* @__PURE__ */ jsx("at", { type: "all" }), /* @__PURE__ */ jsx("message", { children: content })] }));
834
844
  }, 1);
835
845
  this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
836
846
  }
837
847
  if (type === PushType.Dynamic && record.dynamicArr?.length >= 1) {
848
+ this.logger.info(record.dynamicArr);
838
849
  const success = await withRetry(async () => {
839
850
  return await this.ctx.broadcast(record.dynamicArr, /* @__PURE__ */ jsx("message", { children: content }));
840
851
  }, 1);
841
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
852
+ this.logger.info(`成功推送动态消息群组/频道:${success}`);
842
853
  }
843
854
  if ((type === PushType.Live || type === PushType.StartBroadcasting) && record.liveArr?.length >= 1) {
855
+ this.logger.info(record.liveArr);
844
856
  const success = await withRetry(async () => {
845
857
  return await this.ctx.broadcast(record.liveArr, /* @__PURE__ */ jsx("message", { children: content }));
846
858
  }, 1);
847
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
859
+ this.logger.info(`成功推送直播消息群组/频道:${success}`);
848
860
  }
849
861
  if (type === PushType.LiveGuardBuy && record.liveGuardBuyArr?.length >= 1) {
862
+ this.logger.info(record.liveGuardBuyArr);
850
863
  const success = await withRetry(async () => {
851
864
  return await this.ctx.broadcast(record.liveGuardBuyArr, /* @__PURE__ */ jsx("message", { children: content }));
852
865
  }, 1);
853
- this.logger.info(`成功推送全体成员消息群组/频道:${success}`);
866
+ this.logger.info(`成功推送上舰消息群组/频道:${success}`);
854
867
  }
855
868
  return;
856
869
  }
@@ -1515,6 +1528,7 @@ var ComRegister = class {
1515
1528
  return await subUserMatchPattern[subUserData.code]();
1516
1529
  }
1517
1530
  async loadSubFromConfig(subs) {
1531
+ this.initPushRecord(subs);
1518
1532
  for (const sub of subs) {
1519
1533
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1520
1534
  const { code: userInfoCode, msg: userInfoMsg, data: userInfoData } = await withRetry(async () => {
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.6",
4
+ "version": "3.2.5-alpha.8",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -284,6 +284,9 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
284
284
  > - ver 3.2.5-alpha.3 更新依赖版本
285
285
  > - ver 3.2.5-alpha.4 测试版本
286
286
  > - ver 3.2.5-alpha.5 测试版本
287
+ > - ver 3.2.5-alpha.6 测试版本
288
+ > - ver 3.2.5-alpha.7 测试版本
289
+ > - ver 3.2.5-alpha.8 测试版本
287
290
 
288
291
  ## 交流群
289
292