Skip to content

Commit

Permalink
Remove the use of cookies in GeetestError
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Jun 1, 2024
1 parent a2b2755 commit 462d6e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion genshin/client/manager/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
11 changes: 3 additions & 8 deletions genshin/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 462d6e7

Please sign in to comment.