🐛 Fix KeyError caused by improper parameter type for character star level retrieval

This commit is contained in:
洛水居室 2023-04-28 14:51:31 +08:00
parent 3ec8b96c02
commit 007ef28d0b
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
2 changed files with 2 additions and 2 deletions

View File

@ -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

View File

@ -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