From abd73f40508e90954f5ef1e44ed61b3e88eac6e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Wed, 19 Jul 2023 13:27:55 +0800 Subject: [PATCH] :rewind: Revert "Update `DailyRewardClient` error handler" --- simnet/client/components/daily.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/simnet/client/components/daily.py b/simnet/client/components/daily.py index 34b2568..b6db328 100644 --- a/simnet/client/components/daily.py +++ b/simnet/client/components/daily.py @@ -81,7 +81,7 @@ class DailyRewardClient(BaseClient): url = base_url / endpoint - daily_reward = await self.request_lab( + return await self.request_lab( url, method, params=params, @@ -89,20 +89,6 @@ class DailyRewardClient(BaseClient): lang=lang, ) - if endpoint == "sign": - if self.region == Region.CHINESE and daily_reward.get("success", 0) == 1: - gt = daily_reward.get("gt", "") - challenge = daily_reward.get("challenge", "") - raise GeetestTriggered(gt, challenge) - if self.region == Region.OVERSEAS: - gt_result = daily_reward.get("gt_result") - if gt_result is not None and gt_result["success"] != 0: - gt = gt_result.get("gt", "") - challenge = gt_result.get("challenge", "") - raise GeetestTriggered(gt, challenge) - - return daily_reward - async def get_reward_info( self, *, @@ -232,7 +218,7 @@ class DailyRewardClient(BaseClient): Returns: If `reward` is True, a DailyReward object representing the claimed reward. Otherwise, None. """ - await self.request_daily_reward( + daily_reward = await self.request_daily_reward( "sign", method="POST", game=game or self.game, @@ -241,6 +227,17 @@ class DailyRewardClient(BaseClient): validate=validate, ) + if self.region == Region.CHINESE and daily_reward.get("success", 0) == 1: + gt = daily_reward.get("gt", "") + challenge = daily_reward.get("challenge", "") + raise GeetestTriggered(gt, challenge) + if self.region == Region.OVERSEAS: + gt_result = daily_reward.get("gt_result") + if gt_result is not None and gt_result["success"] != 0: + gt = gt_result.get("gt", "") + challenge = gt_result.get("challenge", "") + raise GeetestTriggered(gt, challenge) + if not reward: return None