mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 03:55:26 +00:00
🐛 Replace all 1034 to NeedChallenge error
This commit is contained in:
parent
2db6895581
commit
82ca5b20dd
@ -11,7 +11,7 @@ from gram_core.services.cookies.services import (
|
||||
)
|
||||
|
||||
from simnet import StarRailClient, Region, Game
|
||||
from simnet.errors import InvalidCookies, TooManyRequests, BadRequest as SimnetBadRequest
|
||||
from simnet.errors import InvalidCookies, TooManyRequests, BadRequest as SimnetBadRequest, NeedChallenge
|
||||
|
||||
from utils.log import logger
|
||||
|
||||
@ -74,15 +74,16 @@ class PublicCookiesService(BaseService, BasePublicCookiesService):
|
||||
await self._repository.update(cookies)
|
||||
await self._cache.delete_public_cookies(cookies.user_id, region)
|
||||
raise NeedContinue
|
||||
except NeedChallenge:
|
||||
logger.warning("用户 [%s] 触发验证", public_id)
|
||||
await self.set_device_valid(client.account_id, False)
|
||||
await self._cache.delete_public_cookies(cookies.user_id, region)
|
||||
raise NeedContinue
|
||||
except SimnetBadRequest as exc:
|
||||
if "invalid content type" in exc.message:
|
||||
raise exc
|
||||
if exc.ret_code == 1034:
|
||||
logger.warning("用户 [%s] 触发验证", public_id)
|
||||
await self.set_device_valid(client.account_id, False)
|
||||
else:
|
||||
logger.warning("用户 [%s] 获取账号信息发生错误,错误信息为", public_id)
|
||||
logger.exception(exc)
|
||||
logger.warning("用户 [%s] 获取账号信息发生错误,错误信息为", public_id)
|
||||
logger.exception(exc)
|
||||
await self._cache.delete_public_cookies(cookies.user_id, region)
|
||||
raise NeedContinue
|
||||
except RuntimeError as exc:
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 30cc0cf8f700f50ad3063b2f3bca4f325f121bd3
|
||||
Subproject commit 9dd1acab7842fb2c7cfd5ca507de93778318dc82
|
@ -2,7 +2,7 @@ from typing import Tuple, Optional
|
||||
|
||||
from simnet import Region
|
||||
from simnet.client.cookies import Cookies
|
||||
from simnet.errors import BadRequest as SIMNetBadRequest
|
||||
from simnet.errors import NeedChallenge
|
||||
|
||||
from core.basemodel import RegionEnum
|
||||
from core.dependence.redisdb import RedisDB
|
||||
@ -62,9 +62,8 @@ class ChallengeSystem(Plugin):
|
||||
if need_verify:
|
||||
try:
|
||||
await client.get_starrail_notes()
|
||||
except SIMNetBadRequest as exc:
|
||||
if exc.retcode != 1034:
|
||||
raise exc
|
||||
except NeedChallenge:
|
||||
pass
|
||||
else:
|
||||
raise ChallengeSystemException("账户正常,无需验证")
|
||||
finally:
|
||||
|
@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, Union
|
||||
|
||||
from pydantic import ValidationError
|
||||
from simnet import StarRailClient, Region
|
||||
from simnet.errors import BadRequest as SimnetBadRequest, InvalidCookies, NetworkError, CookieException
|
||||
from simnet.errors import BadRequest as SimnetBadRequest, InvalidCookies, NetworkError, CookieException, NeedChallenge
|
||||
from simnet.models.genshin.calculator import CalculatorCharacterDetails
|
||||
from simnet.models.genshin.chronicle.characters import Character
|
||||
from simnet.utils.player import recognize_game_biz
|
||||
@ -294,8 +294,8 @@ class GenshinHelper(Plugin):
|
||||
if refresh:
|
||||
raise CookieException(message="The cookie has been refreshed.") from exc
|
||||
raise exc
|
||||
except SimnetBadRequest as exc:
|
||||
if exc.ret_code == 1034 and devices is not None:
|
||||
except NeedChallenge as exc:
|
||||
if devices is not None:
|
||||
devices.is_valid = False
|
||||
await self.devices_service.update(devices)
|
||||
raise exc
|
||||
@ -372,10 +372,9 @@ class GenshinHelper(Plugin):
|
||||
) as client:
|
||||
try:
|
||||
yield client
|
||||
except SimnetBadRequest as exc:
|
||||
if exc.ret_code == 1034:
|
||||
await self.public_cookies_service.undo(user_id)
|
||||
await self.public_cookies_service.set_device_valid(client.account_id, False)
|
||||
except NeedChallenge as exc:
|
||||
await self.public_cookies_service.undo(user_id)
|
||||
await self.public_cookies_service.set_device_valid(client.account_id, False)
|
||||
raise exc
|
||||
|
||||
@asynccontextmanager
|
||||
@ -396,7 +395,5 @@ class GenshinHelper(Plugin):
|
||||
try:
|
||||
client.public = True
|
||||
yield client
|
||||
except SimnetBadRequest as exc:
|
||||
if exc.ret_code == 1034:
|
||||
raise CookiesNotFoundError(user_id) from exc
|
||||
raise exc
|
||||
except NeedChallenge as exc:
|
||||
raise CookiesNotFoundError(user_id) from exc
|
||||
|
Loading…
Reference in New Issue
Block a user