mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
✨ 优化错误提示
This commit is contained in:
parent
59bb191941
commit
4e80c1bc09
@ -198,33 +198,38 @@ async def _(event: MessageEvent):
|
|||||||
async def _(event: MessageEvent, players=CommandPlayer(only_cn=False), characters=CommandCharacter()):
|
async def _(event: MessageEvent, players=CommandPlayer(only_cn=False), characters=CommandCharacter()):
|
||||||
logger.info('原神角色面板', '开始执行')
|
logger.info('原神角色面板', '开始执行')
|
||||||
msg = Message()
|
msg = Message()
|
||||||
if len(players) == 1:
|
try:
|
||||||
# 当查询对象只有一个时,查询所有角色
|
if len(players) == 1:
|
||||||
gim = GenshinInfoManager(players[0].user_id, players[0].uid)
|
# 当查询对象只有一个时,查询所有角色
|
||||||
await LastQuery.update_last_query(players[0].user_id, players[0].uid)
|
gim = GenshinInfoManager(players[0].user_id, players[0].uid)
|
||||||
logger.info('原神角色面板', '➤', {'用户': players[0].user_id, 'UID': players[0].uid})
|
await LastQuery.update_last_query(players[0].user_id, players[0].uid)
|
||||||
for character in characters:
|
logger.info('原神角色面板', '➤', {'用户': players[0].user_id, 'UID': players[0].uid})
|
||||||
character_info = await gim.get_character(name=character, data_source='enka')
|
for character in characters:
|
||||||
if not character_info:
|
character_info = await gim.get_character(name=character, data_source='enka')
|
||||||
logger.info('原神角色面板', '➤➤', {'角色': character}, '没有该角色信息', False)
|
if not character_info:
|
||||||
msg += f'\n暂无你{character}信息,请在游戏内展柜放置该角色'
|
logger.info('原神角色面板', '➤➤', {'角色': character}, '没有该角色信息', False)
|
||||||
else:
|
msg += f'\n暂无你{character}信息,请在游戏内展柜放置该角色'
|
||||||
img = await draw_chara_detail(players[0].uid, character_info)
|
else:
|
||||||
logger.info('原神角色面板', '➤➤➤', {}, '制图完成', True)
|
img = await draw_chara_detail(players[0].uid, character_info)
|
||||||
msg += img
|
logger.info('原神角色面板', '➤➤➤', {}, '制图完成', True)
|
||||||
else:
|
msg += img
|
||||||
# 当查询对象有多个时,只查询第一个角色
|
else:
|
||||||
for player in players:
|
# 当查询对象有多个时,只查询第一个角色
|
||||||
gim = GenshinInfoManager(player.user_id, player.uid)
|
for player in players:
|
||||||
await LastQuery.update_last_query(player.user_id, player.uid)
|
gim = GenshinInfoManager(player.user_id, player.uid)
|
||||||
logger.info('原神角色面板', '➤', {'用户': player.user_id, 'UID': player.uid})
|
await LastQuery.update_last_query(player.user_id, player.uid)
|
||||||
character_info = await gim.get_character(name=characters[0], data_source='enka')
|
logger.info('原神角色面板', '➤', {'用户': player.user_id, 'UID': player.uid})
|
||||||
if not character_info:
|
character_info = await gim.get_character(name=characters[0], data_source='enka')
|
||||||
msg += f'\n暂无{player.uid}的{characters[0]}信息,请在游戏内展柜放置该角色'
|
if not character_info:
|
||||||
else:
|
msg += f'\n暂无{player.uid}的{characters[0]}信息,请在游戏内展柜放置该角色'
|
||||||
img = await draw_chara_detail(player.uid, character_info)
|
else:
|
||||||
logger.info('原神角色面板', '➤➤➤', {}, '制图完成', True)
|
img = await draw_chara_detail(player.uid, character_info)
|
||||||
msg += img
|
logger.info('原神角色面板', '➤➤➤', {}, '制图完成', True)
|
||||||
|
msg += img
|
||||||
|
except KeyError as e:
|
||||||
|
msg = f'获取角色信息失败,缺少{e}的数据,可能是Enka.Network接口出现问题'
|
||||||
|
except Exception as e:
|
||||||
|
msg = f'获取角色信息失败,错误信息:{e}'
|
||||||
await ysd.finish(msg, at_sender=True)
|
await ysd.finish(msg, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@ -248,7 +253,7 @@ async def _(event: MessageEvent, state: T_State, uid=CommandUID()):
|
|||||||
gim = GenshinInfoManager(str(event.user_id), uid)
|
gim = GenshinInfoManager(str(event.user_id), uid)
|
||||||
result = await gim.update_all(include_talent)
|
result = await gim.update_all(include_talent)
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
result = f'更新失败,缺少{e}的数据,请尝试更新bot版本'
|
result = f'更新失败,缺少{e}的数据,可能是Enka.Network接口出现问题'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
result = f'更新失败,错误信息:{e}'
|
result = f'更新失败,错误信息:{e}'
|
||||||
running_udi.remove(f'{event.user_id}-{uid}')
|
running_udi.remove(f'{event.user_id}-{uid}')
|
||||||
|
@ -173,7 +173,14 @@ class GenshinInfoManager:
|
|||||||
if not character or character.update_time < (
|
if not character or character.update_time < (
|
||||||
datetime.datetime.now() - datetime.timedelta(hours=config.ysd_auto_update)).replace(
|
datetime.datetime.now() - datetime.timedelta(hours=config.ysd_auto_update)).replace(
|
||||||
tzinfo=pytz.timezone('UTC')):
|
tzinfo=pytz.timezone('UTC')):
|
||||||
await self.update_from_enka()
|
try:
|
||||||
|
await self.update_from_enka()
|
||||||
|
except Exception as e:
|
||||||
|
logger.info('原神角色面板', '➤➤', {'角色': name or character_id}, f'数据更新失败,可能是Enka.Network接口出现问题:{e}', False)
|
||||||
|
if character:
|
||||||
|
return character
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
if character := await Character.get_or_none(**query, data_source='enka'):
|
if character := await Character.get_or_none(**query, data_source='enka'):
|
||||||
logger.info('原神角色面板', '➤➤', {'角色': name or character_id}, '数据更新成功', True)
|
logger.info('原神角色面板', '➤➤', {'角色': name or character_id}, '数据更新成功', True)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user