🔧 avatar_list: optimize retry code

This commit is contained in:
SiHuaN 2022-10-28 11:53:59 +08:00 committed by GitHub
parent 3e4cd1db1c
commit 514d1bf3b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,13 +77,14 @@ class AvatarListPlugin(Plugin, BasePlugin):
if isinstance(e, GenshinException) and "Too Many Requests" in e.msg: if isinstance(e, GenshinException) and "Too Many Requests" in e.msg:
await asyncio.sleep(0.2) await asyncio.sleep(0.2)
continue continue
if character.name != "旅行者": if character.name == "旅行者":
raise e logger.debug(f"解析旅行者数据时遇到了错误:{e}")
logger.debug(f"解析旅行者数据时遇到了错误:{e}") return None
raise e
else: else:
break break
if detail is None: else:
logger.warning(f"解析[bold]{character.name}[/]的数据时遇到了错误{e.msg}", extra={"markup": True}) logger.warning(f"解析[bold]{character.name}[/]的数据时遇到了 Too Many Requests 错误", extra={"markup": True})
return None return None
if character.id == 10000005: # 针对男草主 if character.id == 10000005: # 针对男草主
talents = [] talents = []