🐛 修复深渊配队报错,优化遇到验证码时的提示

This commit is contained in:
CMHopeSunshine 2022-11-04 22:36:07 +08:00
parent e6f208d4fb
commit b9e6b07eda
5 changed files with 18 additions and 10 deletions

View File

@ -9,6 +9,7 @@ BASE_API = 'https://www.youchuang.fun'
TEAM_RATE_API = f'{BASE_API}/gamerole/formationRate'
VERSION_API = 'https://api-cloudgame-static.mihoyo.com/hk4e_cg_cn/gamer/api/getFunctionShieldNew?client_type=1'
VERSION = 3.1 # 尚未更新3.2深渊
HEADERS = {
'Host': 'www.youchuang.fun',
'Referer': 'https://servicewechat.com/wxce4dbe0cb0f764b3/91/page-frame.html',
@ -18,22 +19,22 @@ HEADERS = {
}
async def get_game_version() -> float:
data = await aiorequests.get(VERSION_API)
data = data.json()
return float(data['data']['config']['cg.key_function_queue_news']['versions'][0].replace('.0', ''))
# async def get_game_version() -> float:
# data = await aiorequests.get(VERSION_API)
# data = data.json()
# return float(data['data']['config']['cg.key_function_queue_news']['versions'][0].replace('.0', ''))
async def get_team_rate() -> Tuple[TeamRateResult, float]:
version = await get_game_version()
# version = await get_game_version()
data_up = (await aiorequests.post(TEAM_RATE_API, json={
'version': version,
'version': VERSION,
'layer': 1
}, headers=HEADERS)).json()['result']
data_down = (await aiorequests.post(TEAM_RATE_API, json={
'version': version,
'version': VERSION,
'layer': 2
}, headers=HEADERS)).json()['result']
return TeamRateResult(rateListUp=parse_obj_as(List[TeamRate], data_up['rateList']),
rateListDown=parse_obj_as(List[TeamRate], data_down['rateList']),
userCount=data_up['userCount']), version
userCount=data_up['userCount']), VERSION

View File

@ -204,7 +204,7 @@ class MihoyoBBSCoin:
if data['retcode'] != 1034:
self.is_valid = False
self.state = 'Cookie已失效' if data['retcode'] in [-100,
10001] else f"出错了:{data['retcode']} {data['message']}"
10001] else f"出错了:{data['retcode']} {data['message']}" if data['retcode'] != 1034 else '疑似遇到验证码'
logger.info('米游币自动获取', f'➤➤<r>{self.state}</r>')
return f'讨论区签到:{self.state}'
await asyncio.sleep(random.randint(15, 30))

View File

@ -50,6 +50,10 @@ async def handle_ssbq(player: Player):
if isinstance(data, str):
logger.info('原神实时便签', '', {'用户': player.user_id, 'UID': player.uid}, f'获取数据失败, {data}', False)
return f'{player.uid}{data}\n'
elif data['retcode'] == 1034:
logger.info('原神实时便签', '', {'用户': player.user_id, 'UID': player.uid},
'获取数据失败状态码为1034疑似验证码', False)
return f'{player.uid}获取数据失败,疑似遇米游社验证码阻拦,请稍后再试\n'
elif data['retcode'] != 0:
logger.info('原神实时便签', '', {'用户': player.user_id, 'UID': player.uid},
f'获取数据失败code为{data["retcode"]} msg为{data["message"]}', False)

View File

@ -188,7 +188,7 @@ async def draw_chara_bag(player: Player, info: PlayerInfo, characters: List[Char
# 签名和uid
if info.signature:
await img.text(info.signature, 165, 116, fm.get('hywh', 32), '#252525')
nickname_length = img.text_length(info.nickname, fm.get('hywh', 40))
nickname_length = img.text_length(info.nickname, fm.get('hywh', 48))
await img.text(f'UID{player.uid}', 166 + nickname_length + 36, 58, fm.get('bahnschrift_regular', 48, 'Regular'),
'#252525')
else:

View File

@ -115,6 +115,9 @@ class GenshinInfoManager:
data = await get_mihoyo_public_data(self.uid, self.user_id, 'player_card')
if not isinstance(data, dict):
return data
elif data['retcode'] == 1034:
logger.info('原神信息', f'更新<m>{self.uid}</m>的玩家数据时出错状态码为1034疑似验证码</r>')
return '疑似遇米游社验证码阻拦,请稍后再试'
elif data['retcode'] != 0:
logger.info('原神信息', f'更新<m>{self.uid}</m>的玩家数据时出错,消息为<r>{data["message"]}</r>')
return data['message']