koishi-plugin-bilibili-notify 3.3.11-alpha.4 → 3.3.11

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
@@ -710,6 +710,7 @@ var ComRegister = class {
710
710
  for (const uname of Object.keys(subs)) subs[uname].uname = uname;
711
711
  }
712
712
  async initAsyncPart(subs) {
713
+ this.ctx["bilibili-notify-live"].clearListeners();
713
714
  this.logger.info("获取到订阅信息,开始加载订阅...");
714
715
  const groupInfoResult = await this.getGroupInfo();
715
716
  if (groupInfoResult.code !== 0) {
@@ -4164,9 +4165,13 @@ var BLive = class extends koishi.Service {
4164
4165
  super(ctx, "bilibili-notify-live");
4165
4166
  }
4166
4167
  stop() {
4167
- for (const key of Object.keys(this.listenerRecord)) this.closeListener(key);
4168
+ this.clearListeners();
4168
4169
  }
4169
4170
  async startLiveRoomListener(roomId, handler) {
4171
+ if (this.listenerRecord[roomId]) {
4172
+ this.logger.warn(`[${roomId}]直播间连接已存在,无法重复创建!`);
4173
+ return;
4174
+ }
4170
4175
  const cookiesStr = await this.ctx["bilibili-notify-api"].getCookiesForHeader();
4171
4176
  const mySelfInfo = await this.ctx["bilibili-notify-api"].getMyselfInfo();
4172
4177
  this.listenerRecord[roomId] = (0, blive_message_listener.startListen)(Number.parseInt(roomId), handler, { ws: {
@@ -4185,6 +4190,12 @@ var BLive = class extends koishi.Service {
4185
4190
  }
4186
4191
  this.logger.warn(`${roomId}直播间连接未成功关闭`);
4187
4192
  }
4193
+ clearListeners() {
4194
+ for (const key of Object.keys(this.listenerRecord)) {
4195
+ this.closeListener(key);
4196
+ delete this.listenerRecord[key];
4197
+ }
4198
+ }
4188
4199
  };
4189
4200
  var bili_live_default = BLive;
4190
4201
 
package/lib/index.mjs CHANGED
@@ -692,6 +692,7 @@ var ComRegister = class {
692
692
  for (const uname of Object.keys(subs)) subs[uname].uname = uname;
693
693
  }
694
694
  async initAsyncPart(subs) {
695
+ this.ctx["bilibili-notify-live"].clearListeners();
695
696
  this.logger.info("获取到订阅信息,开始加载订阅...");
696
697
  const groupInfoResult = await this.getGroupInfo();
697
698
  if (groupInfoResult.code !== 0) {
@@ -4146,9 +4147,13 @@ var BLive = class extends Service {
4146
4147
  super(ctx, "bilibili-notify-live");
4147
4148
  }
4148
4149
  stop() {
4149
- for (const key of Object.keys(this.listenerRecord)) this.closeListener(key);
4150
+ this.clearListeners();
4150
4151
  }
4151
4152
  async startLiveRoomListener(roomId, handler) {
4153
+ if (this.listenerRecord[roomId]) {
4154
+ this.logger.warn(`[${roomId}]直播间连接已存在,无法重复创建!`);
4155
+ return;
4156
+ }
4152
4157
  const cookiesStr = await this.ctx["bilibili-notify-api"].getCookiesForHeader();
4153
4158
  const mySelfInfo = await this.ctx["bilibili-notify-api"].getMyselfInfo();
4154
4159
  this.listenerRecord[roomId] = startListen(Number.parseInt(roomId), handler, { ws: {
@@ -4167,6 +4172,12 @@ var BLive = class extends Service {
4167
4172
  }
4168
4173
  this.logger.warn(`${roomId}直播间连接未成功关闭`);
4169
4174
  }
4175
+ clearListeners() {
4176
+ for (const key of Object.keys(this.listenerRecord)) {
4177
+ this.closeListener(key);
4178
+ delete this.listenerRecord[key];
4179
+ }
4180
+ }
4170
4181
  };
4171
4182
  var bili_live_default = BLive;
4172
4183
 
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.3.11-alpha.4",
4
+ "version": "3.3.11",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [