From 007ef28d0bedf18f9919ccc9ee63ceadf3528025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Fri, 28 Apr 2023 14:51:31 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20KeyError=20caused=20by=20i?= =?UTF-8?q?mproper=20parameter=20type=20for=20character=20star=20level=20r?= =?UTF-8?q?etrieval?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/avatar_list.py | 2 +- plugins/tools/player_info.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/genshin/avatar_list.py b/plugins/genshin/avatar_list.py index 0a4ac716..1aa80ef0 100644 --- a/plugins/genshin/avatar_list.py +++ b/plugins/genshin/avatar_list.py @@ -176,7 +176,7 @@ class AvatarListPlugin(Plugin): if player_info.hand_image is not None: avatar = (await self.assets_service.avatar(player_info.hand_image).icon()).as_uri() try: - rarity = {k: v["rank"] for k, v in AVATAR_DATA.items()}[player_info.hand_image] + rarity = {k: v["rank"] for k, v in AVATAR_DATA.items()}[str(player_info.hand_image)] except KeyError: logger.warning("未找到角色 %s 的星级", player_info.hand_image) except Exception as exc: # pylint: disable=W0703 diff --git a/plugins/tools/player_info.py b/plugins/tools/player_info.py index 5b995b0d..f1882382 100644 --- a/plugins/tools/player_info.py +++ b/plugins/tools/player_info.py @@ -37,7 +37,7 @@ class PlayerInfoSystem(Plugin): if player_info.hand_image is not None: avatar = (await self.assets_service.avatar(player_info.hand_image).icon()).as_uri() try: - rarity = {k: v["rank"] for k, v in AVATAR_DATA.items()}[player_info.hand_image] + rarity = {k: v["rank"] for k, v in AVATAR_DATA.items()}[str(player_info.hand_image)] except KeyError: logger.warning("未找到角色 %s 的等级", player_info.hand_image) except Exception as exc: # pylint: disable=W0703