From f57d6760ac67b762753762943e3b3d3a8c75b77b Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 12 Apr 2024 23:09:37 +0800 Subject: [PATCH] :bug: Fix default namecard navbar not found --- core/dependence/assets.py | 5 +++++ plugins/genshin/avatar_list.py | 2 +- plugins/tools/player_info.py | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/dependence/assets.py b/core/dependence/assets.py index e035b55..fed55f2 100644 --- a/core/dependence/assets.py +++ b/core/dependence/assets.py @@ -392,6 +392,9 @@ class _NamecardAssets(_AssetsService): profile: ICON_TYPE """个人资料名片背景""" + NAME_CARD_DEFAULT: int = 210189 + """默认名片 ID""" + @cached_property def game_name(self) -> str: return NAMECARD_DATA[str(self.id)]["icon"] @@ -410,6 +413,8 @@ class _NamecardAssets(_AssetsService): raise ValueError(avatar_id) def __call__(self, target: int) -> "_NamecardAssets": + if target == 0: + target = self.NAME_CARD_DEFAULT result = _NamecardAssets(self.client) target = int(target) if not isinstance(target, int) else target if target > 10000000: diff --git a/plugins/genshin/avatar_list.py b/plugins/genshin/avatar_list.py index 9b82025..9b9cc5f 100644 --- a/plugins/genshin/avatar_list.py +++ b/plugins/genshin/avatar_list.py @@ -151,7 +151,7 @@ class AvatarListPlugin(Plugin): except Exception as exc: # pylint: disable=W0703 logger.error("卡片信息请求失败 %s", str(exc)) 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 @handler.command("avatars", cookie=True, block=False) diff --git a/plugins/tools/player_info.py b/plugins/tools/player_info.py index 6a14b7f..ee47170 100644 --- a/plugins/tools/player_info.py +++ b/plugins/tools/player_info.py @@ -43,7 +43,7 @@ class PlayerInfoSystem(Plugin): except Exception as exc: # pylint: disable=W0703 logger.error("卡片信息请求失败 %s", str(exc)) 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 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 logger.error("卡片信息请求失败 %s", str(exc)) 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