diff --git a/config/sql/paimon.sql b/config/sql/paimon.sql index dd3c0de..ac1e020 100644 --- a/config/sql/paimon.sql +++ b/config/sql/paimon.sql @@ -97,7 +97,7 @@ CREATE TABLE `sign` ( `chat_id` bigint(20) NULL DEFAULT NULL, `time_created` datetime(0) NULL DEFAULT NULL, `time_updated` datetime(0) NULL DEFAULT NULL, - `status` enum('STATUS_SUCCESS','INVALID_COOKIES','ALREADY_CLAIMED','GENSHIN_EXCEPTION','TIMEOUT_ERROR','BAD_REQUEST','FORBIDDEN') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `status` enum('STATUS_SUCCESS','INVALID_COOKIES','NEED_CHALLENGE' ,'ALREADY_CLAIMED','GENSHIN_EXCEPTION','TIMEOUT_ERROR','BAD_REQUEST','FORBIDDEN') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, PRIMARY KEY (`id`, `user_id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; diff --git a/core/sign/models.py b/core/sign/models.py index 7d48640..aaf52db 100644 --- a/core/sign/models.py +++ b/core/sign/models.py @@ -10,10 +10,11 @@ class SignStatusEnum(int, enum.Enum): STATUS_SUCCESS = 0 # 签到成功 INVALID_COOKIES = 1 # Cookie无效 ALREADY_CLAIMED = 2 # 已经获取奖励 - GENSHIN_EXCEPTION = 3 # API异常 - TIMEOUT_ERROR = 4 # 请求超时 - BAD_REQUEST = 5 # 请求失败 - FORBIDDEN = 6 # 这错误一般为通知失败 机器人被用户BAN + NEED_CHALLENGE = 3 # 需要验证码 + GENSHIN_EXCEPTION = 4 # API异常 + TIMEOUT_ERROR = 5 # 请求超时 + BAD_REQUEST = 6 # 请求失败 + FORBIDDEN = 7 # 这错误一般为通知失败 机器人被用户BAN class Sign(SQLModel, table=True): diff --git a/jobs/sign.py b/jobs/sign.py index 588a051..c72adab 100644 --- a/jobs/sign.py +++ b/jobs/sign.py @@ -18,6 +18,10 @@ from utils.job.manager import listener_jobs_class from utils.service.inject import inject +class NeedChallenge(Exception): + pass + + @listener_jobs_class() class SignJob: @@ -49,8 +53,12 @@ class SignJob: daily_reward_info = await client.get_reward_info(game=Game.GENSHIN) if not daily_reward_info.signed_in: request_daily_reward = await client.request_daily_reward("sign", method="POST", game=Game.GENSHIN) - Log.info(f"UID {client.uid} 签到请求 {request_daily_reward}") - result = "OK" + if request_daily_reward and request_daily_reward.get("success", 0) == 1: + Log.warning(f"UID {client.uid} 签到失败,触发验证码风控") + raise NeedChallenge + else: + Log.info(f"UID {client.uid} 签到请求 {request_daily_reward}") + result = "OK" else: result = "今天旅行者已经签到过了~" reward = rewards[daily_reward_info.claimed_rewards - (1 if daily_reward_info.signed_in else 0)] @@ -78,9 +86,12 @@ class SignJob: except ClientConnectorError: text = "签到失败了呜呜呜 ~ 服务器连接超时 服务器熟啦 ~ " sign_db.status = SignStatusEnum.TIMEOUT_ERROR + except NeedChallenge: + text = f"签到失败,触发验证码风控,自动签到自动关闭" + sign_db.status = SignStatusEnum.NEED_CHALLENGE except BaseException as exc: Log.error(f"执行自动签到时发生错误 用户UID[{user_id}]", exc) - continue + text = "签到失败了呜呜呜 ~ 执行自动签到时发生错误" if sign_db.chat_id < 0: text = f"NOTICE {sign_db.user_id}\n\n{text}" try: diff --git a/plugins/genshin/sign.py b/plugins/genshin/sign.py index 60ed37c..96981bb 100644 --- a/plugins/genshin/sign.py +++ b/plugins/genshin/sign.py @@ -57,7 +57,7 @@ class Sign(BasePlugins): game=Game.GENSHIN, lang="zh-cn") Log.info(f"UID {client.uid} 签到请求 {request_daily_reward}") if request_daily_reward and request_daily_reward.get("success", 0) == 1: - Log.error(f"UID {client.uid} 签到失败,触发验证码风控") + Log.warning(f"UID {client.uid} 签到失败,触发验证码风控") return f"UID {client.uid} 签到失败,触发验证码风控,请尝试重新签到。" except AlreadyClaimed: result = "今天旅行者已经签到过了~"