mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-25 18:04:10 +00:00
🐛 Fix the KeyError
exception caused by the character rarity not found
This commit is contained in:
parent
ca37f6948a
commit
9e23c1d20d
@ -167,6 +167,7 @@ class AvatarListPlugin(Plugin):
|
|||||||
name_card: Optional[str] = None
|
name_card: Optional[str] = None
|
||||||
avatar: Optional[str] = None
|
avatar: Optional[str] = None
|
||||||
rarity: int = 5
|
rarity: int = 5
|
||||||
|
try:
|
||||||
if player_info is not None:
|
if player_info is not None:
|
||||||
if player_info.nickname is not None:
|
if player_info.nickname is not None:
|
||||||
nickname = player_info.nickname
|
nickname = player_info.nickname
|
||||||
@ -174,7 +175,12 @@ class AvatarListPlugin(Plugin):
|
|||||||
name_card = (await self.assets_service.namecard(int(player_info.name_card)).navbar()).as_uri()
|
name_card = (await self.assets_service.namecard(int(player_info.name_card)).navbar()).as_uri()
|
||||||
if player_info.hand_image is not None:
|
if player_info.hand_image is not None:
|
||||||
avatar = (await self.assets_service.avatar(player_info.hand_image).icon()).as_uri()
|
avatar = (await self.assets_service.avatar(player_info.hand_image).icon()).as_uri()
|
||||||
rarity = {k: v["rank"] for k, v in AVATAR_DATA.items()}[str(player_info.hand_image)]
|
try:
|
||||||
|
rarity = {k: v["rank"] for k, v in AVATAR_DATA.items()}[player_info.hand_image]
|
||||||
|
except KeyError:
|
||||||
|
logger.warning("未找到角色 %s 的星级", player_info.hand_image)
|
||||||
|
except Exception as exc: # pylint: disable=W0703
|
||||||
|
logger.error("卡片信息请求失败 %s", str(exc))
|
||||||
if name_card is not None: # 默认
|
if name_card is not None: # 默认
|
||||||
name_card = (await self.assets_service.namecard(210001).navbar()).as_uri()
|
name_card = (await self.assets_service.namecard(210001).navbar()).as_uri()
|
||||||
return name_card, avatar, nickname, rarity
|
return name_card, avatar, nickname, rarity
|
||||||
|
@ -36,7 +36,10 @@ class PlayerInfoSystem(Plugin):
|
|||||||
name_card = (await self.assets_service.namecard(int(player_info.name_card)).navbar()).as_uri()
|
name_card = (await self.assets_service.namecard(int(player_info.name_card)).navbar()).as_uri()
|
||||||
if player_info.hand_image is not None:
|
if player_info.hand_image is not None:
|
||||||
avatar = (await self.assets_service.avatar(player_info.hand_image).icon()).as_uri()
|
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()}[player_info.hand_image]
|
||||||
|
except KeyError:
|
||||||
|
logger.warning("未找到角色 %s 的等级", player_info.hand_image)
|
||||||
except Exception as exc: # pylint: disable=W0703
|
except Exception as exc: # pylint: disable=W0703
|
||||||
logger.error("卡片信息请求失败 %s", str(exc))
|
logger.error("卡片信息请求失败 %s", str(exc))
|
||||||
if name_card is not None: # 默认
|
if name_card is not None: # 默认
|
||||||
|
Loading…
Reference in New Issue
Block a user