koishi-plugin-bilibili-notify 1.2.3-rc.6 → 1.2.3-rc.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.
@@ -29,8 +29,8 @@ declare class ComRegister {
29
29
  getTheCorrespondingBotBasedOnTheSession(session: Session): Bot<Context, any>;
30
30
  sendPrivateMsg(bot: Bot<Context>, content: string): Promise<void>;
31
31
  sendPrivateMsgAndRebootService(ctx: Context, bot: Bot<Context>, content: string): Promise<void>;
32
+ sendMsg(ctx: Context, targets: Array<string>, bot: Bot<Context>, content: any): Promise<void>;
32
33
  dynamicDetect(ctx: Context, bot: Bot<Context>, uid: string, guildId: Array<string>): () => Promise<void>;
33
- sendMsg(ctx: Context, targets: Array<string>, bot: Bot<Context>, content: any): Promise<string[]>;
34
34
  liveDetect(ctx: Context, bot: Bot<Context>, roomId: string, guildId: Array<string>): () => Promise<void>;
35
35
  subShow(): string;
36
36
  checkIfNeedSub(comNeed: boolean, subType: string, session: Session, data?: any): Promise<boolean>;
@@ -715,6 +715,40 @@ class ComRegister {
715
715
  ctx.sm.registerPlugin();
716
716
  }, 1000);
717
717
  }
718
+ async sendMsg(ctx, targets, bot, content) {
719
+ // 定义需要发送的数组
720
+ let sendArr = [];
721
+ // 判断是否需要推送所有机器人加入的群
722
+ if (targets[0] === 'all') {
723
+ // 获取所有guild
724
+ for (let guild of (await bot.getGuildList()).data) {
725
+ sendArr.push(guild.id);
726
+ }
727
+ }
728
+ else {
729
+ sendArr = targets;
730
+ }
731
+ // 循环给每个群组发送
732
+ for (let guildId of sendArr) {
733
+ // 多次尝试发送消息
734
+ let attempts = 3;
735
+ for (let i = 0; i < attempts; i++) {
736
+ try {
737
+ // 发送消息
738
+ await bot.sendMessage(guildId, content);
739
+ // 防止消息发送速度过快被忽略
740
+ await ctx.sleep(500);
741
+ // 成功发送消息,跳出循环
742
+ break;
743
+ }
744
+ catch (e) {
745
+ if (i === attempts - 1) { // 已尝试三次
746
+ throw new Error(`发送群组ID:${guildId}消息失败!原因: ` + e.toString());
747
+ }
748
+ }
749
+ }
750
+ }
751
+ }
718
752
  dynamicDetect(ctx, bot, uid, guildId) {
719
753
  let firstSubscription = true;
720
754
  let timePoint;
@@ -823,37 +857,6 @@ class ComRegister {
823
857
  }
824
858
  };
825
859
  }
826
- async sendMsg(ctx, targets, bot, content) {
827
- // 定义需要发送的数组
828
- let sendArr = [];
829
- // 判断是否需要推送所有机器人加入的群
830
- if (targets[0] === 'all') {
831
- // 获取所有guild
832
- for (let guild of (await bot.getGuildList()).data) {
833
- sendArr.push(guild.id);
834
- }
835
- }
836
- else {
837
- sendArr = targets;
838
- }
839
- // 循环给每个群组发送
840
- for (let guildId of sendArr) {
841
- // 多次尝试发送消息
842
- let attempts = 3;
843
- for (let i = 0; i < attempts; i++) {
844
- try {
845
- return await bot.sendMessage(guildId, content);
846
- }
847
- catch (e) {
848
- if (i === attempts - 1) { // 已尝试三次
849
- throw new Error(`发送群组ID:${guildId}消息失败!原因: ` + e.toString());
850
- }
851
- }
852
- }
853
- // 防止消息发送速度过快被忽略
854
- await ctx.sleep(500);
855
- }
856
- }
857
860
  liveDetect(ctx, bot, roomId, guildId) {
858
861
  let firstSubscription = true;
859
862
  let timer = 0;
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-rc.6",
4
+ "version": "1.2.3-rc.8",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -130,7 +130,9 @@
130
130
  - ver 1.2.3-rc.3 bug测试版本,请跳过
131
131
  - ver 1.2.3-rc.4 bug测试版本,请跳过
132
132
  - ver 1.2.3-rc.5 修复了第一次使用插件时,扫码登录后没有任何反应,并且仍提示没有登录的bug
133
- - ver 1.2.3-rc.6 尝试修复多群推送时部分群未推送的bug
133
+ - ver 1.2.3-rc.6 bug测试版本,请跳过
134
+ - ver 1.2.3-rc.7 尝试修复多群推送时部分群未推送的bug
135
+ - ver 1.2.3-rc.8 修复在 `1.2.3-rc.7` 版本引入的连续推送三次的bug
134
136
 
135
137
  ## 交流群
136
138