From f1e56c0318d6b7afc2a1551e0a2d28ff29199679 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, 15 Mar 2023 12:27:53 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20the=20exception=20caused?= =?UTF-8?q?=20by=20not=20handling=20the=20non-existent=20player?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/tools/sign.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/tools/sign.py b/plugins/tools/sign.py index 05fa4da1..b684aeaa 100644 --- a/plugins/tools/sign.py +++ b/plugins/tools/sign.py @@ -23,7 +23,7 @@ from core.services.sign.models import SignStatusEnum from core.services.sign.services import SignServices from core.services.users.services import UserService from modules.apihelper.client.components.verify import Verify -from plugins.tools.genshin import GenshinHelper +from plugins.tools.genshin import GenshinHelper, CookiesNotFoundError, PlayerNotFoundError from utils.log import logger @@ -346,8 +346,16 @@ class SignSystem(Plugin): except NeedChallenge: text = "签到失败,触发验证码风控,自动签到自动关闭" sign_db.status = SignStatusEnum.NEED_CHALLENGE + except PlayerNotFoundError: + logger.info("用户 user_id[%s] 玩家不存在 关闭并移除自动签到", user_id) + await self.sign_service.remove(sign_db) + continue + except CookiesNotFoundError: + logger.info("用户 user_id[%s] cookie 不存在 关闭并移除自动签到", user_id) + await self.sign_service.remove(sign_db) + continue except Exception as exc: - logger.error("执行自动签到时发生错误 user_id[%s] Message[%s]", user_id, exc.message) + logger.error("执行自动签到时发生错误 user_id[%s]", user_id, exc_info=exc) text = "签到失败了呜呜呜 ~ 执行自动签到时发生错误" else: sign_db.status = SignStatusEnum.STATUS_SUCCESS