🐛 Fix hoyoverse redeem_code

This commit is contained in:
xtaodada 2024-09-10 20:35:09 +08:00
parent 1e23a95b08
commit c07234d94e
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 27 additions and 13 deletions

View File

@ -186,7 +186,7 @@ class LabClient(BaseClient):
player_id: Optional[int] = None,
*,
lang: Optional[str] = None,
) -> None:
) -> dict:
"""Redeems a gift code for the current or specified user.
Args:
@ -195,16 +195,23 @@ class LabClient(BaseClient):
lang (str, optional): The language code used for the request. Defaults to None.
"""
player_id = self.player_id or player_id
await self.request_bbs(
CODE_URL.get_url(),
params=dict(
url = CODE_URL.get_url(self.region, self.game)
params = dict(
uid=player_id,
region=recognize_genshin_server(player_id),
region=recognize_server(player_id, self.game),
cdkey=code,
game_biz="hk4e_global",
game_biz=recognize_game_biz(player_id, self.game),
lang=create_short_lang_code(lang or self.lang),
),
)
if self.game is Game.STARRAIL:
return await self.request_bbs(
url,
data=params,
)
return await self.request_bbs(
url,
params=params,
)
async def redeem_code_by_hoyolab(
@ -213,7 +220,7 @@ class LabClient(BaseClient):
player_id: Optional[int] = None,
*,
lang: Optional[str] = None,
) -> None:
) -> dict:
"""Redeems a gift code for the current or specified user.
Args:
@ -230,7 +237,7 @@ class LabClient(BaseClient):
game_biz=recognize_game_biz(player_id, self.game),
lang=create_short_lang_code(lang or self.lang),
)
await self.request_bbs(url, params=params)
return await self.request_bbs(url, params=params)
async def get_game_accounts(self, *, lang: Optional[str] = None) -> List[Account]:
"""Get the game accounts of the currently logged-in user.

View File

@ -328,7 +328,14 @@ YSULOG_URL = InternationalRoute(
HK4E_URL = Route("https://sg-hk4e-api.hoyoverse.com/common/hk4e_global/")
CODE_URL = Route("https://sg-hk4e-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey")
CODE_URL = GameRoute(
overseas=dict(
genshin="https://sg-hk4e-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey",
hkrpg="https://sg-hkrpg-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkeyRisk",
nap="https://public-operation-nap.hoyoverse.com/common/apicdkey/api/webExchangeCdkey",
),
chinese={},
)
CODE_HOYOLAB_URL = GameRoute(
overseas=dict(
genshin="https://sg-hk4e-api.hoyolab.com/common/apicdkey/api/webExchangeCdkeyHyl",