koishi-plugin-bilibili-notify 3.2.9-rc.4 → 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
@@ -1038,6 +1038,29 @@ var ComRegister = class {
1038
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");
@@ -1918,7 +1941,7 @@ var ComRegister = class {
1918
1941
  this.preInitConfig(subs);
1919
1942
  for (const sub of subs) {
1920
1943
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1921
- const { code: userInfoCode, msg: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1944
+ const { code: userInfoCode, message: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1922
1945
  const data$1 = await this.ctx.ba.getUserInfo(sub.uid);
1923
1946
  return {
1924
1947
  code: 0,
@@ -1931,6 +1954,14 @@ var ComRegister = class {
1931
1954
  message: `加载订阅UID:${sub.uid}失败!`
1932
1955
  };
1933
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
+ }
1934
1965
  if (userInfoCode !== 0) return {
1935
1966
  code: userInfoCode,
1936
1967
  msg: userInfoMsg
@@ -94943,7 +94974,7 @@ var BiliAPI = class extends koishi.Service {
94943
94974
  const csrf = this.getCSRF();
94944
94975
  const ticket = await this.getBiliTicket(csrf);
94945
94976
  if (ticket.code !== 0) throw new Error(`获取BiliTicket失败: ${ticket.message}`);
94946
- this.jar.setCookieSync(`bili_ticket=${ticket.data.ticket}; path=/; domain=.bilibili.com`, "https://www.bilibili.com");
94977
+ this.addCookie(`bili_ticket=${ticket.data.ticket}`);
94947
94978
  this.wbiSign.img_key = ticket.data.nav.img.slice(ticket.data.nav.img.lastIndexOf("/") + 1, ticket.data.nav.img.lastIndexOf("."));
94948
94979
  this.wbiSign.sub_key = ticket.data.nav.sub.slice(ticket.data.nav.sub.lastIndexOf("/") + 1, ticket.data.nav.sub.lastIndexOf("."));
94949
94980
  } catch (e$1) {
@@ -95158,6 +95189,9 @@ var BiliAPI = class extends koishi.Service {
95158
95189
  }
95159
95190
  }));
95160
95191
  }
95192
+ addCookie(cookieStr) {
95193
+ this.jar.setCookieSync(`${cookieStr}; path=/; domain=.bilibili.com`, "https://www.bilibili.com");
95194
+ }
95161
95195
  getCookies() {
95162
95196
  try {
95163
95197
  const cookies = this.jar.serializeSync().cookies.map((cookie) => {
@@ -95361,6 +95395,32 @@ var BiliAPI = class extends koishi.Service {
95361
95395
  case -400: throw new Error("请求错误");
95362
95396
  }
95363
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
+ }
95364
95424
  };
95365
95425
  (0, import_decorate.default)([Retry({
95366
95426
  attempts: 3,
package/lib/index.mjs CHANGED
@@ -1040,6 +1040,29 @@ var ComRegister = class {
1040
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");
@@ -1920,7 +1943,7 @@ var ComRegister = class {
1920
1943
  this.preInitConfig(subs);
1921
1944
  for (const sub of subs) {
1922
1945
  this.logger.info(`加载订阅UID:${sub.uid}中...`);
1923
- const { code: userInfoCode, msg: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1946
+ const { code: userInfoCode, message: userInfoMsg, data: userInfoData } = await withRetry(async () => {
1924
1947
  const data$1 = await this.ctx.ba.getUserInfo(sub.uid);
1925
1948
  return {
1926
1949
  code: 0,
@@ -1933,6 +1956,14 @@ var ComRegister = class {
1933
1956
  message: `加载订阅UID:${sub.uid}失败!`
1934
1957
  };
1935
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
+ }
1936
1967
  if (userInfoCode !== 0) return {
1937
1968
  code: userInfoCode,
1938
1969
  msg: userInfoMsg
@@ -94945,7 +94976,7 @@ var BiliAPI = class extends Service {
94945
94976
  const csrf = this.getCSRF();
94946
94977
  const ticket = await this.getBiliTicket(csrf);
94947
94978
  if (ticket.code !== 0) throw new Error(`获取BiliTicket失败: ${ticket.message}`);
94948
- this.jar.setCookieSync(`bili_ticket=${ticket.data.ticket}; path=/; domain=.bilibili.com`, "https://www.bilibili.com");
94979
+ this.addCookie(`bili_ticket=${ticket.data.ticket}`);
94949
94980
  this.wbiSign.img_key = ticket.data.nav.img.slice(ticket.data.nav.img.lastIndexOf("/") + 1, ticket.data.nav.img.lastIndexOf("."));
94950
94981
  this.wbiSign.sub_key = ticket.data.nav.sub.slice(ticket.data.nav.sub.lastIndexOf("/") + 1, ticket.data.nav.sub.lastIndexOf("."));
94951
94982
  } catch (e$1) {
@@ -95160,6 +95191,9 @@ var BiliAPI = class extends Service {
95160
95191
  }
95161
95192
  }));
95162
95193
  }
95194
+ addCookie(cookieStr) {
95195
+ this.jar.setCookieSync(`${cookieStr}; path=/; domain=.bilibili.com`, "https://www.bilibili.com");
95196
+ }
95163
95197
  getCookies() {
95164
95198
  try {
95165
95199
  const cookies = this.jar.serializeSync().cookies.map((cookie) => {
@@ -95363,6 +95397,32 @@ var BiliAPI = class extends Service {
95363
95397
  case -400: throw new Error("请求错误");
95364
95398
  }
95365
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
+ }
95366
95426
  };
95367
95427
  (0, import_decorate.default)([Retry({
95368
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.4",
4
+ "version": "3.2.10-alpha.0",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -307,6 +307,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
307
307
  > - ver 3.2.9-rc.2 优化:弹幕词云生成效果;
308
308
  > - ver 3.2.9-rc.3 优化:弹幕词云生成效果; 新增:直播总结语,开启弹幕词云后自动发送、选项 `liveSummary` 可自定义直播总结语; 修复:一场直播完成后,如果插件中途没有被关闭过,会影响同一位up主下一次直播词云数据;
309
309
  > - ver 3.2.9-rc.4 优化:弹幕词云生成效果; 新增:直播总结 `-mdn` 变量,代表主播粉丝牌子名
310
+ > - ver 3.2.10-alpha.0 新增:指令 `bili cap` 在遇到风控时,可以手动验证解除风控; 优化:错误消息提示;
310
311
 
311
312
  ## 交流群
312
313