mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-21 22:58:05 +00:00
🐛 Fix the KeyError
exception caused by the character rarity not found
This commit is contained in:
parent
ca37f6948a
commit
9e23c1d20d
@ -167,14 +167,20 @@ class AvatarListPlugin(Plugin):
|
||||
name_card: Optional[str] = None
|
||||
avatar: Optional[str] = None
|
||||
rarity: int = 5
|
||||
if player_info is not None:
|
||||
if player_info.nickname is not None:
|
||||
nickname = player_info.nickname
|
||||
if player_info.name_card is not None:
|
||||
name_card = (await self.assets_service.namecard(int(player_info.name_card)).navbar()).as_uri()
|
||||
if player_info.hand_image is not None:
|
||||
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:
|
||||
if player_info is not None:
|
||||
if player_info.nickname is not None:
|
||||
nickname = player_info.nickname
|
||||
if player_info.name_card is not None:
|
||||
name_card = (await self.assets_service.namecard(int(player_info.name_card)).navbar()).as_uri()
|
||||
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]
|
||||
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: # 默认
|
||||
name_card = (await self.assets_service.namecard(210001).navbar()).as_uri()
|
||||
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()
|
||||
if player_info.hand_image is not None:
|
||||
avatar = (await self.assets_service.avatar(player_info.hand_image).icon()).as_uri()
|
||||
rarity = {k: v["rank"] for k, v in AVATAR_DATA.items()}[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: # 默认
|
||||
|
Loading…
Reference in New Issue
Block a user