🎨 Add handling for InvalidDevice exception to PublicCookiesService

This commit is contained in:
luoshuijs 2023-11-23 00:51:46 +08:00 committed by GitHub
parent c4c452fb60
commit 30ad0151e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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, NeedChallenge
from simnet.errors import InvalidCookies, TooManyRequests, BadRequest as SimnetBadRequest, NeedChallenge, InvalidDevice
from utils.log import logger
@ -79,6 +79,11 @@ class PublicCookiesService(BaseService, BasePublicCookiesService):
await self.set_device_valid(client.account_id, False)
await self._cache.delete_public_cookies(cookies.user_id, region)
raise NeedContinue
except InvalidDevice:
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