🐛 修复获取签到奖励列表被阻断导致无法启动bot的问题

This commit is contained in:
CMHopeSunshine 2022-10-16 19:17:41 +08:00
parent 1872ec13f8
commit b1c574d451
2 changed files with 26 additions and 7 deletions

View File

@ -77,7 +77,10 @@ async def mhy_bbs_sign(user_id: str, uid: str) -> Tuple[SignResult, str]:
elif sign_info['data']['is_sign']:
signed_days = sign_info['data']['total_sign_day'] - 1
logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, '今天已经签过了', True)
if sign_reward_list:
return SignResult.DONE, f'UID{uid}今天已经签过了,获得的奖励为\n{sign_reward_list[signed_days]["name"]}*{sign_reward_list[signed_days]["cnt"]}'
else:
return SignResult.DONE, f'UID{uid}今天已经签过了'
validate = None
sign_data = None
for i in range(3):
@ -89,7 +92,10 @@ async def mhy_bbs_sign(user_id: str, uid: str) -> Tuple[SignResult, str]:
elif sign_data['retcode'] == -5003:
signed_days = sign_info['data']['total_sign_day'] - 1
logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, '今天已经签过了', True)
if sign_reward_list:
return SignResult.DONE, f'UID{uid}今天已经签过了,获得的奖励为\n{sign_reward_list[signed_days]["name"]}*{sign_reward_list[signed_days]["cnt"]}'
else:
return SignResult.DONE, f'UID{uid}今天已经签过了'
elif sign_data['retcode'] != 0:
logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid},
f'获取数据失败code为{sign_data["retcode"]} msg为{sign_data["message"]}', False)
@ -98,7 +104,10 @@ async def mhy_bbs_sign(user_id: str, uid: str) -> Tuple[SignResult, str]:
if sign_data['data']['success'] == 0:
logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, '签到成功', True)
signed_days = sign_info['data']['total_sign_day']
if sign_reward_list:
return SignResult.SUCCESS, f'签到成功,获得的奖励为\n{sign_reward_list[signed_days]["name"]}*{sign_reward_list[signed_days]["cnt"]}'
else:
return SignResult.SUCCESS, '签到成功'
else:
wait_time = random.randint(90, 120)
logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, f'出现验证码,等待{wait_time}秒后进行第{i + 1}次尝试绕过', False)
@ -177,5 +186,8 @@ async def init_reward_list():
初始化签到奖励列表
"""
global sign_reward_list
try:
sign_reward_list = await get_sign_reward_list()
sign_reward_list = sign_reward_list['data']['awards']
except Exception:
logger.info('米游社原神签到', '初始化签到奖励列表<r>失败</r>')

View File

@ -7,7 +7,6 @@ httpx>=0.23.0
lxml>=4.8.0
Pillow>=9.1.0
matplotlib>=3.5.1
pypinyin>=0.46.0
aiofiles>=0.8.0
tortoise-orm>=0.19.2
tqdm>=4.64.0
@ -15,3 +14,11 @@ ruamel.yaml>=0.17.21
ujson>=5.4.0
expandvars>=0.9.0
pywebio>=1.6.2
jieba>=0.42.1
scipy>=1.9.1
scikit-learn>=1.1.2
shapely>=1.8.4
gitpython>=3.1.27
pypinyin>=0.47.1