🐛 Fix default namecard navbar not found

This commit is contained in:
xtaodada 2024-04-12 23:09:37 +08:00
parent 3936c14d00
commit f57d6760ac
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
3 changed files with 8 additions and 3 deletions

View File

@ -392,6 +392,9 @@ class _NamecardAssets(_AssetsService):
profile: ICON_TYPE profile: ICON_TYPE
"""个人资料名片背景""" """个人资料名片背景"""
NAME_CARD_DEFAULT: int = 210189
"""默认名片 ID"""
@cached_property @cached_property
def game_name(self) -> str: def game_name(self) -> str:
return NAMECARD_DATA[str(self.id)]["icon"] return NAMECARD_DATA[str(self.id)]["icon"]
@ -410,6 +413,8 @@ class _NamecardAssets(_AssetsService):
raise ValueError(avatar_id) raise ValueError(avatar_id)
def __call__(self, target: int) -> "_NamecardAssets": def __call__(self, target: int) -> "_NamecardAssets":
if target == 0:
target = self.NAME_CARD_DEFAULT
result = _NamecardAssets(self.client) result = _NamecardAssets(self.client)
target = int(target) if not isinstance(target, int) else target target = int(target) if not isinstance(target, int) else target
if target > 10000000: if target > 10000000:

View File

@ -151,7 +151,7 @@ class AvatarListPlugin(Plugin):
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 None: # 默认 if name_card is None: # 默认
name_card = (await self.assets_service.namecard(210001).navbar()).as_uri() name_card = (await self.assets_service.namecard(0).navbar()).as_uri()
return name_card, avatar, nickname, rarity return name_card, avatar, nickname, rarity
@handler.command("avatars", cookie=True, block=False) @handler.command("avatars", cookie=True, block=False)

View File

@ -43,7 +43,7 @@ class PlayerInfoSystem(Plugin):
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 None: # 默认 if name_card is None: # 默认
name_card = (await self.assets_service.namecard(210001).navbar()).as_uri() name_card = (await self.assets_service.namecard(0).navbar()).as_uri()
return name_card, avatar, nickname, rarity return name_card, avatar, nickname, rarity
async def get_name_card(self, player_id: int, user_id: int): async def get_name_card(self, player_id: int, user_id: int):
@ -56,5 +56,5 @@ class PlayerInfoSystem(Plugin):
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 None: # 默认 if name_card is None: # 默认
name_card = (await self.assets_service.namecard(210001).navbar()).as_uri() name_card = (await self.assets_service.namecard(0).navbar()).as_uri()
return name_card return name_card