mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-25 07:36:27 +00:00
🐛 修复自动签到时需要验证码时返回签到成功的问题
This commit is contained in:
parent
55cd8c530d
commit
3ddb71cd06
@ -97,7 +97,7 @@ CREATE TABLE `sign` (
|
|||||||
`chat_id` bigint(20) NULL DEFAULT NULL,
|
`chat_id` bigint(20) NULL DEFAULT NULL,
|
||||||
`time_created` datetime(0) NULL DEFAULT NULL,
|
`time_created` datetime(0) NULL DEFAULT NULL,
|
||||||
`time_updated` 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
|
PRIMARY KEY (`id`, `user_id`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
@ -10,10 +10,11 @@ class SignStatusEnum(int, enum.Enum):
|
|||||||
STATUS_SUCCESS = 0 # 签到成功
|
STATUS_SUCCESS = 0 # 签到成功
|
||||||
INVALID_COOKIES = 1 # Cookie无效
|
INVALID_COOKIES = 1 # Cookie无效
|
||||||
ALREADY_CLAIMED = 2 # 已经获取奖励
|
ALREADY_CLAIMED = 2 # 已经获取奖励
|
||||||
GENSHIN_EXCEPTION = 3 # API异常
|
NEED_CHALLENGE = 3 # 需要验证码
|
||||||
TIMEOUT_ERROR = 4 # 请求超时
|
GENSHIN_EXCEPTION = 4 # API异常
|
||||||
BAD_REQUEST = 5 # 请求失败
|
TIMEOUT_ERROR = 5 # 请求超时
|
||||||
FORBIDDEN = 6 # 这错误一般为通知失败 机器人被用户BAN
|
BAD_REQUEST = 6 # 请求失败
|
||||||
|
FORBIDDEN = 7 # 这错误一般为通知失败 机器人被用户BAN
|
||||||
|
|
||||||
|
|
||||||
class Sign(SQLModel, table=True):
|
class Sign(SQLModel, table=True):
|
||||||
|
17
jobs/sign.py
17
jobs/sign.py
@ -18,6 +18,10 @@ from utils.job.manager import listener_jobs_class
|
|||||||
from utils.service.inject import inject
|
from utils.service.inject import inject
|
||||||
|
|
||||||
|
|
||||||
|
class NeedChallenge(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@listener_jobs_class()
|
@listener_jobs_class()
|
||||||
class SignJob:
|
class SignJob:
|
||||||
|
|
||||||
@ -49,8 +53,12 @@ class SignJob:
|
|||||||
daily_reward_info = await client.get_reward_info(game=Game.GENSHIN)
|
daily_reward_info = await client.get_reward_info(game=Game.GENSHIN)
|
||||||
if not daily_reward_info.signed_in:
|
if not daily_reward_info.signed_in:
|
||||||
request_daily_reward = await client.request_daily_reward("sign", method="POST", game=Game.GENSHIN)
|
request_daily_reward = await client.request_daily_reward("sign", method="POST", game=Game.GENSHIN)
|
||||||
Log.info(f"UID {client.uid} 签到请求 {request_daily_reward}")
|
if request_daily_reward and request_daily_reward.get("success", 0) == 1:
|
||||||
result = "OK"
|
Log.warning(f"UID {client.uid} 签到失败,触发验证码风控")
|
||||||
|
raise NeedChallenge
|
||||||
|
else:
|
||||||
|
Log.info(f"UID {client.uid} 签到请求 {request_daily_reward}")
|
||||||
|
result = "OK"
|
||||||
else:
|
else:
|
||||||
result = "今天旅行者已经签到过了~"
|
result = "今天旅行者已经签到过了~"
|
||||||
reward = rewards[daily_reward_info.claimed_rewards - (1 if daily_reward_info.signed_in else 0)]
|
reward = rewards[daily_reward_info.claimed_rewards - (1 if daily_reward_info.signed_in else 0)]
|
||||||
@ -78,9 +86,12 @@ class SignJob:
|
|||||||
except ClientConnectorError:
|
except ClientConnectorError:
|
||||||
text = "签到失败了呜呜呜 ~ 服务器连接超时 服务器熟啦 ~ "
|
text = "签到失败了呜呜呜 ~ 服务器连接超时 服务器熟啦 ~ "
|
||||||
sign_db.status = SignStatusEnum.TIMEOUT_ERROR
|
sign_db.status = SignStatusEnum.TIMEOUT_ERROR
|
||||||
|
except NeedChallenge:
|
||||||
|
text = f"签到失败,触发验证码风控,自动签到自动关闭"
|
||||||
|
sign_db.status = SignStatusEnum.NEED_CHALLENGE
|
||||||
except BaseException as exc:
|
except BaseException as exc:
|
||||||
Log.error(f"执行自动签到时发生错误 用户UID[{user_id}]", exc)
|
Log.error(f"执行自动签到时发生错误 用户UID[{user_id}]", exc)
|
||||||
continue
|
text = "签到失败了呜呜呜 ~ 执行自动签到时发生错误"
|
||||||
if sign_db.chat_id < 0:
|
if sign_db.chat_id < 0:
|
||||||
text = f"<a href=\"tg://user?id={sign_db.user_id}\">NOTICE {sign_db.user_id}</a>\n\n{text}"
|
text = f"<a href=\"tg://user?id={sign_db.user_id}\">NOTICE {sign_db.user_id}</a>\n\n{text}"
|
||||||
try:
|
try:
|
||||||
|
@ -57,7 +57,7 @@ class Sign(BasePlugins):
|
|||||||
game=Game.GENSHIN, lang="zh-cn")
|
game=Game.GENSHIN, lang="zh-cn")
|
||||||
Log.info(f"UID {client.uid} 签到请求 {request_daily_reward}")
|
Log.info(f"UID {client.uid} 签到请求 {request_daily_reward}")
|
||||||
if request_daily_reward and request_daily_reward.get("success", 0) == 1:
|
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} 签到失败,触发验证码风控,请尝试重新签到。"
|
return f"UID {client.uid} 签到失败,触发验证码风控,请尝试重新签到。"
|
||||||
except AlreadyClaimed:
|
except AlreadyClaimed:
|
||||||
result = "今天旅行者已经签到过了~"
|
result = "今天旅行者已经签到过了~"
|
||||||
|
Loading…
Reference in New Issue
Block a user