mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 07:07:46 +00:00
🐛 Replace all 1034 to NeedChallenge error
This commit is contained in:
parent
1f7d35ff95
commit
339f386997
@ -11,7 +11,7 @@ from gram_core.services.cookies.services import (
|
||||
)
|
||||
|
||||
from simnet import GenshinClient, 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,13 +74,14 @@ 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)
|
||||
await self._cache.delete_public_cookies(cookies.user_id, region)
|
||||
|
@ -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_genshin_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 GenshinClient, 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,8 +372,7 @@ class GenshinHelper(Plugin):
|
||||
) as client:
|
||||
try:
|
||||
yield client
|
||||
except SimnetBadRequest as exc:
|
||||
if exc.ret_code == 1034:
|
||||
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
|
||||
@ -396,7 +395,5 @@ class GenshinHelper(Plugin):
|
||||
try:
|
||||
client.public = True
|
||||
yield client
|
||||
except SimnetBadRequest as exc:
|
||||
if exc.ret_code == 1034:
|
||||
except NeedChallenge as exc:
|
||||
raise CookiesNotFoundError(user_id) from exc
|
||||
raise exc
|
||||
|
Loading…
Reference in New Issue
Block a user