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

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.cjs CHANGED
@@ -478,7 +478,7 @@ var ComRegister = class ComRegister {
478
478
  return this.subShow();
479
479
  });
480
480
  biliCom.subcommand(".private", "向主人账号发送一条测试消息", { hidden: true }).usage("向主人账号发送一条测试消息").example("bili private 向主人账号发送一条测试消息").action(async ({ session }) => {
481
- await this.sendPrivateMsg(`主人~女仆向您问好啦!Ciallo~(∠・ω< )⌒★乖乖打招呼呀 (>ω<)♡`);
481
+ await this.sendPrivateMsg("主人~女仆向您问好啦!Ciallo~(∠・ω< )⌒★乖乖打招呼呀 (>ω<)♡");
482
482
  await session.send("主人~女仆已经发送消息啦~如果主人没收到,可能是机器人不支持发送私聊消息,或者主人填写的信息有误哦 (>ω<)♡");
483
483
  });
484
484
  biliCom.subcommand(".ll").usage("展示当前正在直播的订阅对象").example("bili ll").action(async () => {
@@ -503,7 +503,16 @@ var ComRegister = class ComRegister {
503
503
  });
504
504
  biliCom.subcommand(".dyn <uid:string> [index:number]", "手动推送一条动态信息", { hidden: true }).usage("手动推送一条动态信息").example("bili dyn 233 1 手动推送UID为233用户空间的第一条动态信息").action(async ({ session }, uid, index) => {
505
505
  const i = index && index - 1 || 0;
506
- const item = (await this.ctx["bilibili-notify-api"].getUserSpaceDynamic(uid)).data.items[i];
506
+ const content = await this.ctx["bilibili-notify-api"].getUserSpaceDynamic(uid);
507
+ if (!content || !content.data) {
508
+ this.logger.error("主人呜呜 (;>_<) 女仆获取动态内容失败啦~请主人帮女仆看看呀 (>ω<)♡");
509
+ return;
510
+ }
511
+ if (content.code !== 0) {
512
+ this.logger.error(`主人呜呜 (;>_<) 女仆获取动态内容失败啦~请主人帮女仆看看呀 (>ω<)♡ 错误码: ${content.code}`);
513
+ return;
514
+ }
515
+ const item = content.data.items[i];
507
516
  const buffer = await withRetry(async () => {
508
517
  return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item);
509
518
  }, 1).catch(async (e) => {
@@ -1175,7 +1184,10 @@ var ComRegister = class ComRegister {
1175
1184
  }, 1).catch((e) => {
1176
1185
  this.logger.error(`主人呜呜 (;>_<) 女仆在执行 dynamicDetect getAllDynamic() 时发生了错误~错误信息:${e.message},请主人帮女仆看看呀 (>ω<)♡`);
1177
1186
  });
1178
- if (!content) return;
1187
+ if (!content || !content.data) {
1188
+ this.logger.error("主人呜呜 (;>_<) 女仆在执行 dynamicDetect 时获取动态内容失败啦~请主人帮女仆看看呀 (>ω<)♡");
1189
+ return;
1190
+ }
1179
1191
  if (content.code !== 0) switch (content.code) {
1180
1192
  case -101:
1181
1193
  this.logger.error("主人…呜呜,女仆发现您还没登录账号呢 (;>_<)插件已经乖乖停止工作啦…请主人快点登录,让女仆可以继续努力为您服务~ (>ω<)♡");
@@ -4537,6 +4549,10 @@ var BLive = class extends koishi.Service {
4537
4549
  }
4538
4550
  const cookiesStr = await this.ctx["bilibili-notify-api"].getCookiesForHeader();
4539
4551
  const mySelfInfo = await this.ctx["bilibili-notify-api"].getMyselfInfo();
4552
+ if (mySelfInfo.code !== 0) {
4553
+ this.logger.warn(`主人~女仆获取个人信息失败啦~无法创建 [${roomId}] 直播间连接呢~请主人帮女仆看看呀 (>ω<)♡`);
4554
+ return;
4555
+ }
4540
4556
  this.listenerRecord[roomId] = (0, blive_message_listener.startListen)(Number.parseInt(roomId, 10), handler, { ws: {
4541
4557
  headers: { Cookie: cookiesStr },
4542
4558
  uid: mySelfInfo.data.mid
package/lib/index.mjs CHANGED
@@ -449,7 +449,7 @@ var ComRegister = class ComRegister {
449
449
  return this.subShow();
450
450
  });
451
451
  biliCom.subcommand(".private", "向主人账号发送一条测试消息", { hidden: true }).usage("向主人账号发送一条测试消息").example("bili private 向主人账号发送一条测试消息").action(async ({ session }) => {
452
- await this.sendPrivateMsg(`主人~女仆向您问好啦!Ciallo~(∠・ω< )⌒★乖乖打招呼呀 (>ω<)♡`);
452
+ await this.sendPrivateMsg("主人~女仆向您问好啦!Ciallo~(∠・ω< )⌒★乖乖打招呼呀 (>ω<)♡");
453
453
  await session.send("主人~女仆已经发送消息啦~如果主人没收到,可能是机器人不支持发送私聊消息,或者主人填写的信息有误哦 (>ω<)♡");
454
454
  });
455
455
  biliCom.subcommand(".ll").usage("展示当前正在直播的订阅对象").example("bili ll").action(async () => {
@@ -474,7 +474,16 @@ var ComRegister = class ComRegister {
474
474
  });
475
475
  biliCom.subcommand(".dyn <uid:string> [index:number]", "手动推送一条动态信息", { hidden: true }).usage("手动推送一条动态信息").example("bili dyn 233 1 手动推送UID为233用户空间的第一条动态信息").action(async ({ session }, uid, index) => {
476
476
  const i = index && index - 1 || 0;
477
- const item = (await this.ctx["bilibili-notify-api"].getUserSpaceDynamic(uid)).data.items[i];
477
+ const content = await this.ctx["bilibili-notify-api"].getUserSpaceDynamic(uid);
478
+ if (!content || !content.data) {
479
+ this.logger.error("主人呜呜 (;>_<) 女仆获取动态内容失败啦~请主人帮女仆看看呀 (>ω<)♡");
480
+ return;
481
+ }
482
+ if (content.code !== 0) {
483
+ this.logger.error(`主人呜呜 (;>_<) 女仆获取动态内容失败啦~请主人帮女仆看看呀 (>ω<)♡ 错误码: ${content.code}`);
484
+ return;
485
+ }
486
+ const item = content.data.items[i];
478
487
  const buffer = await withRetry(async () => {
479
488
  return await this.ctx["bilibili-notify-generate-img"].generateDynamicImg(item);
480
489
  }, 1).catch(async (e) => {
@@ -1146,7 +1155,10 @@ var ComRegister = class ComRegister {
1146
1155
  }, 1).catch((e) => {
1147
1156
  this.logger.error(`主人呜呜 (;>_<) 女仆在执行 dynamicDetect getAllDynamic() 时发生了错误~错误信息:${e.message},请主人帮女仆看看呀 (>ω<)♡`);
1148
1157
  });
1149
- if (!content) return;
1158
+ if (!content || !content.data) {
1159
+ this.logger.error("主人呜呜 (;>_<) 女仆在执行 dynamicDetect 时获取动态内容失败啦~请主人帮女仆看看呀 (>ω<)♡");
1160
+ return;
1161
+ }
1150
1162
  if (content.code !== 0) switch (content.code) {
1151
1163
  case -101:
1152
1164
  this.logger.error("主人…呜呜,女仆发现您还没登录账号呢 (;>_<)插件已经乖乖停止工作啦…请主人快点登录,让女仆可以继续努力为您服务~ (>ω<)♡");
@@ -4508,6 +4520,10 @@ var BLive = class extends Service {
4508
4520
  }
4509
4521
  const cookiesStr = await this.ctx["bilibili-notify-api"].getCookiesForHeader();
4510
4522
  const mySelfInfo = await this.ctx["bilibili-notify-api"].getMyselfInfo();
4523
+ if (mySelfInfo.code !== 0) {
4524
+ this.logger.warn(`主人~女仆获取个人信息失败啦~无法创建 [${roomId}] 直播间连接呢~请主人帮女仆看看呀 (>ω<)♡`);
4525
+ return;
4526
+ }
4511
4527
  this.listenerRecord[roomId] = startListen(Number.parseInt(roomId, 10), handler, { ws: {
4512
4528
  headers: { Cookie: cookiesStr },
4513
4529
  uid: mySelfInfo.data.mid
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.6.0-alpha.4",
4
+ "version": "3.6.0",
5
5
  "main": "./lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [