koishi-plugin-bilibili-notify 3.2.9-rc.3 → 3.2.10-alpha.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.js CHANGED
@@ -113,8 +113,8 @@ const BAConfigSchema = koishi.Schema.object({
113
113
  pushImgsInDynamic: koishi.Schema.boolean().default(false).description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
114
114
  live: koishi.Schema.object({}).description("直播推送设置"),
115
115
  liveDetectType: koishi.Schema.union([koishi.Schema.const("WS").description("使用WebSocket连接到B站消息服务器进行直播检测,推荐使用"), koishi.Schema.const("API").description("通过轮询API发送请求监测直播状态,此模式理论可无限订阅,但容易产生其他问题,功能没有WS模式全面").experimental()]).role("radio").default("WS").description("直播检测方式,WS为连接到B站消息服务器,API为通过轮询发送请求监测,默认使用WS检测"),
116
- wordcloud: koishi.Schema.boolean().default(false).description("直播结束后,是否生成本场直播弹幕词云"),
117
- liveSummary: koishi.Schema.string().default("🔍【弹幕情报站】本场直播数据如下:\\n🧍‍♂️ 总共 -dmc 位特工上线\\n💬 共计 -dca 条弹幕飞驰而过\\n📊 热词云图已生成,快来看看你有没有上榜!\\n\\n👑 本场顶级输出选手:\\n🥇 -un1 - 弹幕输出 -dc1 条\\n🥈 -un2 - 弹幕 -dc2 条,萌力惊人\\n🥉 -un3 - -dc3 条精准狙击\\n\\n🎖️ 特别嘉奖:-un4 & -un5\\n你们的弹幕,我们都记录在案!🕵️‍♀️").description("自定义直播总结语,开启弹幕词云自动发送。变量解释:-dmc代表总弹幕发送人数,-dca代表总弹幕数,-un1到-un5代表弹幕发送条数前五名用户的用户名,-dc1到-dc5代表弹幕发送条数前五名的弹幕发送数量"),
116
+ wordcloud: koishi.Schema.boolean().default(false).description("直播结束后,是否生成本场直播弹幕词云").experimental(),
117
+ liveSummary: koishi.Schema.string().default("🔍【弹幕情报站】本场直播数据如下:\\n🧍‍♂️ 总共 -dmc 位-mdn上线\\n💬 共计 -dca 条弹幕飞驰而过\\n📊 热词云图已生成,快来看看你有没有上榜!\\n\\n👑 本场顶级输出选手:\\n🥇 -un1 - 弹幕输出 -dc1 条\\n🥈 -un2 - 弹幕 -dc2 条,萌力惊人\\n🥉 -un3 - -dc3 条精准狙击\\n\\n🎖️ 特别嘉奖:-un4 & -un5\\n你们的弹幕,我们都记录在案!🕵️‍♀️").description("自定义直播总结语,开启弹幕词云自动发送。变量解释:-dmc代表总弹幕发送人数,-mdn代表主播粉丝牌子名,-dca代表总弹幕数,-un1到-un5代表弹幕发送条数前五名用户的用户名,-dc1到-dc5代表弹幕发送条数前五名的弹幕发送数量"),
118
118
  restartPush: koishi.Schema.boolean().default(true).description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
119
119
  pushTime: koishi.Schema.number().min(0).max(12).step(.5).default(1).description("设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时"),
120
120
  customLiveStart: koishi.Schema.string().default("-name开播啦,当前粉丝数:-follower\\n-link").description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
@@ -936,9 +936,9 @@ var ComRegister = class {
936
936
  });
937
937
  biliCom.subcommand(".wc").action(async ({ session }) => {
938
938
  const words = [
939
- ["摆烂", 60],
940
- ["可以", 42],
941
- ["可以", 42],
939
+ ["摆烂", 91],
940
+ ["可以", 82],
941
+ ["可以", 72],
942
942
  ["可以", 42],
943
943
  ["dog", 40],
944
944
  ["dog", 40],
@@ -1035,9 +1035,32 @@ var ComRegister = class {
1035
1035
  ["赵六", 27],
1036
1036
  ["田七", 25]
1037
1037
  ];
1038
- const danmakerRankMsg = this.config.liveSummary.replace("-dmc", "114").replace("-dca", "514").replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
1038
+ const danmakerRankMsg = this.config.liveSummary.replace("-dmc", "114").replace("-mdn", "特工").replace("-dca", "514").replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
1039
1039
  await session.send(danmakerRankMsg);
1040
1040
  });
1041
+ biliCom.subcommand(".cap").action(async ({ session }) => {
1042
+ const { code: userInfoCode, data: userInfoData } = await withRetry(async () => {
1043
+ const data$2 = await this.ctx.ba.getUserInfo("114514");
1044
+ return {
1045
+ code: 0,
1046
+ data: data$2
1047
+ };
1048
+ }).then((content) => content.data);
1049
+ if (userInfoCode !== -352 || !userInfoData.v_voucher) return "不满足风控条件,不需要执行该命令";
1050
+ const { data: data$1 } = await ctx.ba.v_voucherCaptcha(userInfoData.v_voucher);
1051
+ if (!data$1.geetest) return "当前风控无法通过该验证解除,或许考虑人工申诉?";
1052
+ await session.send("请到该网站进行验证操作:https://kuresaru.github.io/geetest-validator/");
1053
+ await session.send("请手动填入 gt 和 challenge 后点击生成进行验证,验证完成后点击结果,根据提示输入对应validate");
1054
+ await session.send(`gt:${data$1.geetest.gt}`);
1055
+ await session.send(`challenge:${data$1.geetest.challenge}`);
1056
+ await session.send("请输入validate");
1057
+ const validate$1 = await session.prompt();
1058
+ const seccode = `${validate$1}|jordan`;
1059
+ const { data: validateCaptchaData } = await ctx.ba.validateCaptcha(data$1.geetest.challenge, data$1.token, validate$1, seccode);
1060
+ if (validateCaptchaData.is_valid !== 1) return "验证不成功!";
1061
+ ctx.ba.addCookie(`x-bili-gaia-vtoken=${validateCaptchaData.grisk_id}`);
1062
+ return "验证成功!";
1063
+ });
1041
1064
  }
1042
1065
  async init(config) {
1043
1066
  this.logger = this.ctx.logger("cr");
@@ -1444,7 +1467,8 @@ var ComRegister = class {
1444
1467
  roomId: data$1.room_id,
1445
1468
  liveOpenFollowerNum,
1446
1469
  liveEndFollowerNum,
1447
- liveFollowerChange
1470
+ liveFollowerChange,
1471
+ medalName: data$1.medal_name
1448
1472
  };
1449
1473
  }
1450
1474
  async useLiveRoomInfo(roomId) {
@@ -1486,7 +1510,7 @@ var ComRegister = class {
1486
1510
  const sendDanmakuWordCloud = async () => {
1487
1511
  this.logger.info("开始制作弹幕词云");
1488
1512
  this.logger.info("正在获取前90热词");
1489
- const top90Words = Object.entries(danmakuWeightRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 90).map(([word, weight]) => [word, weight > 60 ? 60 : weight]);
1513
+ const top90Words = Object.entries(danmakuWeightRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 90);
1490
1514
  this.logger.info("弹幕词云前90词及权重:");
1491
1515
  this.logger.info(top90Words);
1492
1516
  this.logger.info("正在准备生成弹幕词云");
@@ -1498,7 +1522,7 @@ var ComRegister = class {
1498
1522
  const danmakuMakerCount = Object.keys(danmakuMakerRecord).length;
1499
1523
  const danmakuCount = Object.values(danmakuMakerRecord).reduce((sum, val) => sum + val, 0);
1500
1524
  const top5DanmakuMaker = Object.entries(danmakuMakerRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 5);
1501
- const danmakuMakerMsg = this.config.liveSummary.replace("-dmc", `${danmakuMakerCount}`).replace("-dca", `${danmakuCount}`).replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
1525
+ const danmakuMakerMsg = this.config.liveSummary.replace("-dmc", `${danmakuMakerCount}`).replace("-mdn", `${masterInfo.medalName}`).replace("-dca", `${danmakuCount}`).replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
1502
1526
  await this.broadcastToTargets(uid, danmakuMakerMsg, PushType.Live);
1503
1527
  Object.keys(danmakuWeightRecord).forEach((key) => delete danmakuWeightRecord[key]);
1504
1528
  Object.keys(danmakuMakerRecord).forEach((key) => delete danmakuMakerRecord[key]);
@@ -1917,7 +1941,7 @@ var ComRegister = class {
1917
1941
  this.preInitConfig(subs);
1918
1942
  for (const sub of subs) {
1919
1943
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1920
- const { code: userInfoCode, msg: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1944
+ const { code: userInfoCode, message: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1921
1945
  const data$1 = await this.ctx.ba.getUserInfo(sub.uid);
1922
1946
  return {
1923
1947
  code: 0,
@@ -1930,6 +1954,14 @@ var ComRegister = class {
1930
1954
  message: `加载订阅UID:${sub.uid}失败!`
1931
1955
  };
1932
1956
  });
1957
+ if (userInfoCode === -352 && userInfoData.v_voucher) {
1958
+ this.logger.info("账号被风控,请使用指令 bili captcha 进行风控验证");
1959
+ await this.sendPrivateMsg("账号被风控,请使用指令 bili captcha 进行风控验证");
1960
+ return {
1961
+ code: userInfoCode,
1962
+ msg: userInfoMsg
1963
+ };
1964
+ }
1933
1965
  if (userInfoCode !== 0) return {
1934
1966
  code: userInfoCode,
1935
1967
  msg: userInfoMsg
@@ -94942,7 +94974,7 @@ var BiliAPI = class extends koishi.Service {
94942
94974
  const csrf = this.getCSRF();
94943
94975
  const ticket = await this.getBiliTicket(csrf);
94944
94976
  if (ticket.code !== 0) throw new Error(`获取BiliTicket失败: ${ticket.message}`);
94945
- this.jar.setCookieSync(`bili_ticket=${ticket.data.ticket}; path=/; domain=.bilibili.com`, "https://www.bilibili.com");
94977
+ this.addCookie(`bili_ticket=${ticket.data.ticket}`);
94946
94978
  this.wbiSign.img_key = ticket.data.nav.img.slice(ticket.data.nav.img.lastIndexOf("/") + 1, ticket.data.nav.img.lastIndexOf("."));
94947
94979
  this.wbiSign.sub_key = ticket.data.nav.sub.slice(ticket.data.nav.sub.lastIndexOf("/") + 1, ticket.data.nav.sub.lastIndexOf("."));
94948
94980
  } catch (e$1) {
@@ -95157,6 +95189,9 @@ var BiliAPI = class extends koishi.Service {
95157
95189
  }
95158
95190
  }));
95159
95191
  }
95192
+ addCookie(cookieStr) {
95193
+ this.jar.setCookieSync(`${cookieStr}; path=/; domain=.bilibili.com`, "https://www.bilibili.com");
95194
+ }
95160
95195
  getCookies() {
95161
95196
  try {
95162
95197
  const cookies = this.jar.serializeSync().cookies.map((cookie) => {
@@ -95360,6 +95395,32 @@ var BiliAPI = class extends koishi.Service {
95360
95395
  case -400: throw new Error("请求错误");
95361
95396
  }
95362
95397
  }
95398
+ async v_voucherCaptcha(v_voucher) {
95399
+ const csrf = this.getCSRF();
95400
+ const { data: data$1 } = await this.client.post("https://api.bilibili.com/x/gaia-vgate/v1/register", {
95401
+ csrf,
95402
+ v_voucher
95403
+ }, { headers: { "Content-Type": "application/x-www-form-urlencoded" } }).catch((e$1) => {
95404
+ this.logger.error(e$1);
95405
+ });
95406
+ if (data$1.code !== 0) this.logger.error("验证码获取失败!");
95407
+ return { data: data$1.data };
95408
+ }
95409
+ async validateCaptcha(challenge, token, validate$1, seccode) {
95410
+ const csrf = this.getCSRF();
95411
+ const { data: data$1 } = await this.client.post("https://api.bilibili.com/x/gaia-vgate/v1/validate", {
95412
+ csrf,
95413
+ challenge,
95414
+ token,
95415
+ validate: validate$1,
95416
+ seccode
95417
+ }, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
95418
+ if (data$1.code !== 0) {
95419
+ this.logger.info(`验证失败:错误码=${data$1.code},错误消息:${data$1.message}`);
95420
+ return { data: null };
95421
+ }
95422
+ return { data: data$1.data };
95423
+ }
95363
95424
  };
95364
95425
  (0, import_decorate.default)([Retry({
95365
95426
  attempts: 3,
package/lib/index.mjs CHANGED
@@ -115,8 +115,8 @@ const BAConfigSchema = Schema.object({
115
115
  pushImgsInDynamic: Schema.boolean().default(false).description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
116
116
  live: Schema.object({}).description("直播推送设置"),
117
117
  liveDetectType: Schema.union([Schema.const("WS").description("使用WebSocket连接到B站消息服务器进行直播检测,推荐使用"), Schema.const("API").description("通过轮询API发送请求监测直播状态,此模式理论可无限订阅,但容易产生其他问题,功能没有WS模式全面").experimental()]).role("radio").default("WS").description("直播检测方式,WS为连接到B站消息服务器,API为通过轮询发送请求监测,默认使用WS检测"),
118
- wordcloud: Schema.boolean().default(false).description("直播结束后,是否生成本场直播弹幕词云"),
119
- liveSummary: Schema.string().default("🔍【弹幕情报站】本场直播数据如下:\\n🧍‍♂️ 总共 -dmc 位特工上线\\n💬 共计 -dca 条弹幕飞驰而过\\n📊 热词云图已生成,快来看看你有没有上榜!\\n\\n👑 本场顶级输出选手:\\n🥇 -un1 - 弹幕输出 -dc1 条\\n🥈 -un2 - 弹幕 -dc2 条,萌力惊人\\n🥉 -un3 - -dc3 条精准狙击\\n\\n🎖️ 特别嘉奖:-un4 & -un5\\n你们的弹幕,我们都记录在案!🕵️‍♀️").description("自定义直播总结语,开启弹幕词云自动发送。变量解释:-dmc代表总弹幕发送人数,-dca代表总弹幕数,-un1到-un5代表弹幕发送条数前五名用户的用户名,-dc1到-dc5代表弹幕发送条数前五名的弹幕发送数量"),
118
+ wordcloud: Schema.boolean().default(false).description("直播结束后,是否生成本场直播弹幕词云").experimental(),
119
+ liveSummary: Schema.string().default("🔍【弹幕情报站】本场直播数据如下:\\n🧍‍♂️ 总共 -dmc 位-mdn上线\\n💬 共计 -dca 条弹幕飞驰而过\\n📊 热词云图已生成,快来看看你有没有上榜!\\n\\n👑 本场顶级输出选手:\\n🥇 -un1 - 弹幕输出 -dc1 条\\n🥈 -un2 - 弹幕 -dc2 条,萌力惊人\\n🥉 -un3 - -dc3 条精准狙击\\n\\n🎖️ 特别嘉奖:-un4 & -un5\\n你们的弹幕,我们都记录在案!🕵️‍♀️").description("自定义直播总结语,开启弹幕词云自动发送。变量解释:-dmc代表总弹幕发送人数,-mdn代表主播粉丝牌子名,-dca代表总弹幕数,-un1到-un5代表弹幕发送条数前五名用户的用户名,-dc1到-dc5代表弹幕发送条数前五名的弹幕发送数量"),
120
120
  restartPush: Schema.boolean().default(true).description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
121
121
  pushTime: Schema.number().min(0).max(12).step(.5).default(1).description("设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时"),
122
122
  customLiveStart: Schema.string().default("-name开播啦,当前粉丝数:-follower\\n-link").description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
@@ -938,9 +938,9 @@ var ComRegister = class {
938
938
  });
939
939
  biliCom.subcommand(".wc").action(async ({ session }) => {
940
940
  const words = [
941
- ["摆烂", 60],
942
- ["可以", 42],
943
- ["可以", 42],
941
+ ["摆烂", 91],
942
+ ["可以", 82],
943
+ ["可以", 72],
944
944
  ["可以", 42],
945
945
  ["dog", 40],
946
946
  ["dog", 40],
@@ -1037,9 +1037,32 @@ var ComRegister = class {
1037
1037
  ["赵六", 27],
1038
1038
  ["田七", 25]
1039
1039
  ];
1040
- const danmakerRankMsg = this.config.liveSummary.replace("-dmc", "114").replace("-dca", "514").replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
1040
+ const danmakerRankMsg = this.config.liveSummary.replace("-dmc", "114").replace("-mdn", "特工").replace("-dca", "514").replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
1041
1041
  await session.send(danmakerRankMsg);
1042
1042
  });
1043
+ biliCom.subcommand(".cap").action(async ({ session }) => {
1044
+ const { code: userInfoCode, data: userInfoData } = await withRetry(async () => {
1045
+ const data$2 = await this.ctx.ba.getUserInfo("114514");
1046
+ return {
1047
+ code: 0,
1048
+ data: data$2
1049
+ };
1050
+ }).then((content) => content.data);
1051
+ if (userInfoCode !== -352 || !userInfoData.v_voucher) return "不满足风控条件,不需要执行该命令";
1052
+ const { data: data$1 } = await ctx.ba.v_voucherCaptcha(userInfoData.v_voucher);
1053
+ if (!data$1.geetest) return "当前风控无法通过该验证解除,或许考虑人工申诉?";
1054
+ await session.send("请到该网站进行验证操作:https://kuresaru.github.io/geetest-validator/");
1055
+ await session.send("请手动填入 gt 和 challenge 后点击生成进行验证,验证完成后点击结果,根据提示输入对应validate");
1056
+ await session.send(`gt:${data$1.geetest.gt}`);
1057
+ await session.send(`challenge:${data$1.geetest.challenge}`);
1058
+ await session.send("请输入validate");
1059
+ const validate$1 = await session.prompt();
1060
+ const seccode = `${validate$1}|jordan`;
1061
+ const { data: validateCaptchaData } = await ctx.ba.validateCaptcha(data$1.geetest.challenge, data$1.token, validate$1, seccode);
1062
+ if (validateCaptchaData.is_valid !== 1) return "验证不成功!";
1063
+ ctx.ba.addCookie(`x-bili-gaia-vtoken=${validateCaptchaData.grisk_id}`);
1064
+ return "验证成功!";
1065
+ });
1043
1066
  }
1044
1067
  async init(config) {
1045
1068
  this.logger = this.ctx.logger("cr");
@@ -1446,7 +1469,8 @@ var ComRegister = class {
1446
1469
  roomId: data$1.room_id,
1447
1470
  liveOpenFollowerNum,
1448
1471
  liveEndFollowerNum,
1449
- liveFollowerChange
1472
+ liveFollowerChange,
1473
+ medalName: data$1.medal_name
1450
1474
  };
1451
1475
  }
1452
1476
  async useLiveRoomInfo(roomId) {
@@ -1488,7 +1512,7 @@ var ComRegister = class {
1488
1512
  const sendDanmakuWordCloud = async () => {
1489
1513
  this.logger.info("开始制作弹幕词云");
1490
1514
  this.logger.info("正在获取前90热词");
1491
- const top90Words = Object.entries(danmakuWeightRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 90).map(([word, weight]) => [word, weight > 60 ? 60 : weight]);
1515
+ const top90Words = Object.entries(danmakuWeightRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 90);
1492
1516
  this.logger.info("弹幕词云前90词及权重:");
1493
1517
  this.logger.info(top90Words);
1494
1518
  this.logger.info("正在准备生成弹幕词云");
@@ -1500,7 +1524,7 @@ var ComRegister = class {
1500
1524
  const danmakuMakerCount = Object.keys(danmakuMakerRecord).length;
1501
1525
  const danmakuCount = Object.values(danmakuMakerRecord).reduce((sum, val) => sum + val, 0);
1502
1526
  const top5DanmakuMaker = Object.entries(danmakuMakerRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 5);
1503
- const danmakuMakerMsg = this.config.liveSummary.replace("-dmc", `${danmakuMakerCount}`).replace("-dca", `${danmakuCount}`).replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
1527
+ const danmakuMakerMsg = this.config.liveSummary.replace("-dmc", `${danmakuMakerCount}`).replace("-mdn", `${masterInfo.medalName}`).replace("-dca", `${danmakuCount}`).replace("-un1", `${top5DanmakuMaker[0][0]}`).replace("-dc1", `${top5DanmakuMaker[0][1]}`).replace("-un2", `${top5DanmakuMaker[1][0]}`).replace("-dc2", `${top5DanmakuMaker[1][1]}`).replace("-un3", `${top5DanmakuMaker[2][0]}`).replace("-dc3", `${top5DanmakuMaker[2][1]}`).replace("-un4", `${top5DanmakuMaker[3][0]}`).replace("-dc4", `${top5DanmakuMaker[3][1]}`).replace("-un5", `${top5DanmakuMaker[4][0]}`).replace("-dc5", `${top5DanmakuMaker[4][1]}`).replaceAll("\\n", "\n");
1504
1528
  await this.broadcastToTargets(uid, danmakuMakerMsg, PushType.Live);
1505
1529
  Object.keys(danmakuWeightRecord).forEach((key) => delete danmakuWeightRecord[key]);
1506
1530
  Object.keys(danmakuMakerRecord).forEach((key) => delete danmakuMakerRecord[key]);
@@ -1919,7 +1943,7 @@ var ComRegister = class {
1919
1943
  this.preInitConfig(subs);
1920
1944
  for (const sub of subs) {
1921
1945
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1922
- const { code: userInfoCode, msg: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1946
+ const { code: userInfoCode, message: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1923
1947
  const data$1 = await this.ctx.ba.getUserInfo(sub.uid);
1924
1948
  return {
1925
1949
  code: 0,
@@ -1932,6 +1956,14 @@ var ComRegister = class {
1932
1956
  message: `加载订阅UID:${sub.uid}失败!`
1933
1957
  };
1934
1958
  });
1959
+ if (userInfoCode === -352 && userInfoData.v_voucher) {
1960
+ this.logger.info("账号被风控,请使用指令 bili captcha 进行风控验证");
1961
+ await this.sendPrivateMsg("账号被风控,请使用指令 bili captcha 进行风控验证");
1962
+ return {
1963
+ code: userInfoCode,
1964
+ msg: userInfoMsg
1965
+ };
1966
+ }
1935
1967
  if (userInfoCode !== 0) return {
1936
1968
  code: userInfoCode,
1937
1969
  msg: userInfoMsg
@@ -94944,7 +94976,7 @@ var BiliAPI = class extends Service {
94944
94976
  const csrf = this.getCSRF();
94945
94977
  const ticket = await this.getBiliTicket(csrf);
94946
94978
  if (ticket.code !== 0) throw new Error(`获取BiliTicket失败: ${ticket.message}`);
94947
- this.jar.setCookieSync(`bili_ticket=${ticket.data.ticket}; path=/; domain=.bilibili.com`, "https://www.bilibili.com");
94979
+ this.addCookie(`bili_ticket=${ticket.data.ticket}`);
94948
94980
  this.wbiSign.img_key = ticket.data.nav.img.slice(ticket.data.nav.img.lastIndexOf("/") + 1, ticket.data.nav.img.lastIndexOf("."));
94949
94981
  this.wbiSign.sub_key = ticket.data.nav.sub.slice(ticket.data.nav.sub.lastIndexOf("/") + 1, ticket.data.nav.sub.lastIndexOf("."));
94950
94982
  } catch (e$1) {
@@ -95159,6 +95191,9 @@ var BiliAPI = class extends Service {
95159
95191
  }
95160
95192
  }));
95161
95193
  }
95194
+ addCookie(cookieStr) {
95195
+ this.jar.setCookieSync(`${cookieStr}; path=/; domain=.bilibili.com`, "https://www.bilibili.com");
95196
+ }
95162
95197
  getCookies() {
95163
95198
  try {
95164
95199
  const cookies = this.jar.serializeSync().cookies.map((cookie) => {
@@ -95362,6 +95397,32 @@ var BiliAPI = class extends Service {
95362
95397
  case -400: throw new Error("请求错误");
95363
95398
  }
95364
95399
  }
95400
+ async v_voucherCaptcha(v_voucher) {
95401
+ const csrf = this.getCSRF();
95402
+ const { data: data$1 } = await this.client.post("https://api.bilibili.com/x/gaia-vgate/v1/register", {
95403
+ csrf,
95404
+ v_voucher
95405
+ }, { headers: { "Content-Type": "application/x-www-form-urlencoded" } }).catch((e$1) => {
95406
+ this.logger.error(e$1);
95407
+ });
95408
+ if (data$1.code !== 0) this.logger.error("验证码获取失败!");
95409
+ return { data: data$1.data };
95410
+ }
95411
+ async validateCaptcha(challenge, token, validate$1, seccode) {
95412
+ const csrf = this.getCSRF();
95413
+ const { data: data$1 } = await this.client.post("https://api.bilibili.com/x/gaia-vgate/v1/validate", {
95414
+ csrf,
95415
+ challenge,
95416
+ token,
95417
+ validate: validate$1,
95418
+ seccode
95419
+ }, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
95420
+ if (data$1.code !== 0) {
95421
+ this.logger.info(`验证失败:错误码=${data$1.code},错误消息:${data$1.message}`);
95422
+ return { data: null };
95423
+ }
95424
+ return { data: data$1.data };
95425
+ }
95365
95426
  };
95366
95427
  (0, import_decorate.default)([Retry({
95367
95428
  attempts: 3,
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.9-rc.3",
4
+ "version": "3.2.10-alpha.0",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -49,7 +49,7 @@
49
49
  "tough-cookie": "^5.1.2"
50
50
  },
51
51
  "devDependencies": {
52
- "@biomejs/biome": "^2.0.0",
52
+ "@biomejs/biome": "^2.0.6",
53
53
  "@koishijs/cache": "^2.1.0",
54
54
  "@koishijs/client": "^5.30.9",
55
55
  "@koishijs/plugin-help": "^2.4.5",
@@ -61,7 +61,7 @@
61
61
  "@types/md5": "^2.3.5",
62
62
  "@types/qrcode": "^1.5.5",
63
63
  "@types/tough-cookie": "^4.0.5",
64
- "globals": "^16.2.0",
64
+ "globals": "^16.3.0",
65
65
  "koishi": "^4.18.8",
66
66
  "koishi-plugin-puppeteer": "^3.9.0",
67
67
  "tsdown": "^0.12.9",
package/readme.md CHANGED
@@ -306,6 +306,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
306
306
  > - ver 3.2.9-rc.1 优化:弹幕词云生成效果;
307
307
  > - ver 3.2.9-rc.2 优化:弹幕词云生成效果;
308
308
  > - ver 3.2.9-rc.3 优化:弹幕词云生成效果; 新增:直播总结语,开启弹幕词云后自动发送、选项 `liveSummary` 可自定义直播总结语; 修复:一场直播完成后,如果插件中途没有被关闭过,会影响同一位up主下一次直播词云数据;
309
+ > - ver 3.2.9-rc.4 优化:弹幕词云生成效果; 新增:直播总结 `-mdn` 变量,代表主播粉丝牌子名
310
+ > - ver 3.2.10-alpha.0 新增:指令 `bili cap` 在遇到风控时,可以手动验证解除风控; 优化:错误消息提示;
309
311
 
310
312
  ## 交流群
311
313