From 94928c893f0121dc75f2018afe317cae7f077362 Mon Sep 17 00:00:00 2001 From: mobyw Date: Fri, 7 Jun 2024 18:45:20 +0800 Subject: [PATCH] :bug: Fix srsign pass --- march7th/nonebot_plugin_mys_api/api.py | 28 ++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/march7th/nonebot_plugin_mys_api/api.py b/march7th/nonebot_plugin_mys_api/api.py index a34ad78..3b24463 100644 --- a/march7th/nonebot_plugin_mys_api/api.py +++ b/march7th/nonebot_plugin_mys_api/api.py @@ -284,9 +284,8 @@ async def _upass(self, headers: dict[str, str], is_bbs: bool = False) -> str: validate, challenge = await self._pass(gt, challenge, headers) if validate and challenge: await self._validate(headers, challenge, validate) - if challenge: - logger.info(f"Challenge upass: {challenge}") - return challenge + logger.info(f"Challenge upass: {challenge}") + return challenge logger.warning("Get upass validate failed") return "" except (json.JSONDecodeError, KeyError): @@ -644,7 +643,28 @@ async def call_mihoyo_api( retcode = None try: retcode = int(data["retcode"]) - if retcode == 1034 and plugin_config.magic_api is not None: + risk_code = data["data"].get("risk_code") if data.get("data") else None + if risk_code == 5001 and plugin_config.magic_api is not None: + logger.warning(f"Mys API {api} risk 5001: {data}") + logger.warning(f"with headers: {headers}") + times_try += 1 + gt = data["data"].get("gt") + challenge = data["data"].get("challenge") + validate, challenge = await self._pass(gt, challenge, headers) + if validate is None or challenge is None: + break + await self._validate(headers, challenge, validate) + logger.info(f"Challenge upass: {challenge}") + headers["x-rpc-challenge_game"] = "6" + headers["x-rpc-challenge"] = challenge + data = await self.request( + "POST" if is_post else "GET", + url=url, + headers=headers, + params=params, + body=body, + ) + elif retcode == 1034 and plugin_config.magic_api is not None: logger.warning(f"Mys API {api} 1034: {data}") logger.warning(f"with headers: {headers}") times_try += 1