From 462d6e7f453fe9a5d1972cd8d48236c9c3071fcb Mon Sep 17 00:00:00 2001 From: seria Date: Sat, 1 Jun 2024 13:25:30 +0900 Subject: [PATCH] Remove the use of cookies in GeetestError --- genshin/client/manager/managers.py | 2 +- genshin/errors.py | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/genshin/client/manager/managers.py b/genshin/client/manager/managers.py index 7f484918..0e33324b 100644 --- a/genshin/client/manager/managers.py +++ b/genshin/client/manager/managers.py @@ -151,7 +151,7 @@ async def _request( cookies.update(new_cookies) _LOGGER.debug("Updating cookies for %s: %s", get_cookie_identifier(cookies), new_keys) - errors.check_for_geetest(data, {k: morsel.value for k, morsel in response.cookies.items()}) + errors.check_for_geetest(data) if data["retcode"] == 0: return data["data"] diff --git a/genshin/errors.py b/genshin/errors.py index 7cb796dc..acda773f 100644 --- a/genshin/errors.py +++ b/genshin/errors.py @@ -192,12 +192,7 @@ class WrongOTP(GenshinException): class GeetestError(GenshinException): """Geetest triggered during the battle chronicle API request.""" - def __init__( - self, - response: typing.Dict[str, typing.Any], - cookies: typing.Mapping[str, str], - ) -> None: - self.cookies = cookies + def __init__(self, response: typing.Dict[str, typing.Any]) -> None: super().__init__(response) msg = "Geetest triggered during the battle chronicle API request." @@ -342,10 +337,10 @@ def raise_for_retcode(data: typing.Dict[str, typing.Any]) -> typing.NoReturn: raise GenshinException(data) -def check_for_geetest(data: typing.Dict[str, typing.Any], cookies: typing.Mapping[str, typing.Any]) -> None: +def check_for_geetest(data: typing.Dict[str, typing.Any]) -> None: """Check if geetest was triggered during the request and raise an error if so.""" if data["retcode"] in GEETEST_RETCODES: - raise GeetestError(data, cookies) + raise GeetestError(data) if not data.get("data"): # if is an error return