自动签到尝试绕过geetest验证

This commit is contained in:
CMHopeSunshine 2022-10-07 00:40:32 +08:00
parent 890994925d
commit cedd7366ef

View File

@ -25,6 +25,7 @@ sign_reward_list: dict = {}
async def pass_geetest(data: Dict[str, Any]): async def pass_geetest(data: Dict[str, Any]):
if data is not None:
url = f'https://api.geetest.com/ajax.php?gt={data["gt"]}&challenge={data["challenge"]}&lang=zh-cn&pt=3&client_type=web_mobile' url = f'https://api.geetest.com/ajax.php?gt={data["gt"]}&challenge={data["challenge"]}&lang=zh-cn&pt=3&client_type=web_mobile'
resp = await aiorequests.get(url, headers=GEETEST_HEADER) resp = await aiorequests.get(url, headers=GEETEST_HEADER)
if resp.status_code == 200: if resp.status_code == 200:
@ -70,7 +71,7 @@ async def mhy_bbs_sign(user_id: str, uid: str) -> Tuple[SignResult, str]:
defaults={'uid': uid, 'last_time': datetime.datetime.now()}) defaults={'uid': uid, 'last_time': datetime.datetime.now()})
sign_info = await get_mihoyo_private_data(uid, user_id, 'sign_info') sign_info = await get_mihoyo_private_data(uid, user_id, 'sign_info')
if isinstance(sign_info, str): if isinstance(sign_info, str):
logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, '未绑定私人cookie', False) logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, '未绑定私人cookie或已失效', False)
await MihoyoBBSSub.filter(user_id=user_id, uid=uid).delete() await MihoyoBBSSub.filter(user_id=user_id, uid=uid).delete()
return SignResult.FAIL, sign_info return SignResult.FAIL, sign_info
elif sign_info['data']['is_sign']: elif sign_info['data']['is_sign']:
@ -99,8 +100,9 @@ async def mhy_bbs_sign(user_id: str, uid: str) -> Tuple[SignResult, str]:
signed_days = sign_info['data']['total_sign_day'] signed_days = sign_info['data']['total_sign_day']
return SignResult.SUCCESS, f'签到成功,获得的奖励为\n{sign_reward_list[signed_days]["name"]}*{sign_reward_list[signed_days]["cnt"]}' return SignResult.SUCCESS, f'签到成功,获得的奖励为\n{sign_reward_list[signed_days]["name"]}*{sign_reward_list[signed_days]["cnt"]}'
else: else:
logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, f'出现验证码,重试第{i}', False) wait_time = random.randint(45, 60)
await asyncio.sleep(random.randint(30, 45)) logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, f'出现验证码,等待{wait_time}秒后进行第{i + 1}次尝试绕过', False)
await asyncio.sleep(wait_time)
logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, '尝试6次签到失败无法绕过验证码', False) logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, '尝试6次签到失败无法绕过验证码', False)
return SignResult.FAIL, f'{uid}签到失败,无法绕过验证码' return SignResult.FAIL, f'{uid}签到失败,无法绕过验证码'
@ -122,7 +124,7 @@ async def bbs_auto_sign():
if not subs: if not subs:
# 如果没有米游社原神签到订阅,则不执行签到任务 # 如果没有米游社原神签到订阅,则不执行签到任务
return return
logger.info('米游社原神签到', f'开始执行米游社自动签到,共<m>{len(subs)}</m>个任务,预计花费<m>{round(40 * len(subs) / 60, 2)}</m>分钟') logger.info('米游社原神签到', f'开始执行米游社自动签到,共<m>{len(subs)}</m>个任务,预计花费<m>{round(100 * len(subs) / 60, 2)}</m>分钟')
sign_result_group = defaultdict(list) sign_result_group = defaultdict(list)
sign_result_private = defaultdict(list) sign_result_private = defaultdict(list)
for sub in subs: for sub in subs:
@ -144,7 +146,7 @@ async def bbs_auto_sign():
if result == SignResult.DONE: if result == SignResult.DONE:
await asyncio.sleep(random.randint(3, 8)) await asyncio.sleep(random.randint(3, 8))
else: else:
await asyncio.sleep(random.randint(30, 45)) await asyncio.sleep(random.randint(45, 60))
for group_id, sign_result in sign_result_group.items(): for group_id, sign_result in sign_result_group.items():
# 发送签到结果到群 # 发送签到结果到群