From f5480f316a89b19d215cfc1f029e715854b0c282 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 1 Jun 2024 22:21:03 +0800 Subject: [PATCH] :bug: Fix new profile avatar --- core/services/players/services.py | 4 ++-- plugins/tools/player_info.py | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/services/players/services.py b/core/services/players/services.py index e0c3986b..f44ca0a0 100644 --- a/core/services/players/services.py +++ b/core/services/players/services.py @@ -96,7 +96,7 @@ class PlayerInfoService(BaseService): player_info.nickname = player_info_enka.nickname player_info.name_card = player_info_enka.namecard.id player_info.signature = player_info_enka.signature - player_info.hand_image = player_info_enka.avatar.id + player_info.hand_image = player_info_enka.avatar.id or player_info_enka.avatar.avatar_id player_info.nickname = player_info_enka.nickname player_info.last_save_time = datetime.now() await self._players_info_repository.update(player_info) @@ -112,7 +112,7 @@ class PlayerInfoService(BaseService): player_info.nickname = player_info_enka.nickname player_info.name_card = player_info_enka.namecard.id player_info.signature = player_info_enka.signature - player_info.hand_image = player_info_enka.avatar.id + player_info.hand_image = player_info_enka.avatar.id or player_info_enka.avatar.avatar_id player_info.nickname = player_info_enka.nickname player_info.last_save_time = datetime.now() await self._players_info_repository.update(player_info) diff --git a/plugins/tools/player_info.py b/plugins/tools/player_info.py index 2c732193..ce207271 100644 --- a/plugins/tools/player_info.py +++ b/plugins/tools/player_info.py @@ -1,5 +1,7 @@ from typing import Optional +from enkanetwork import Assets + from core.dependence.assets import AssetsService from core.plugin import Plugin from core.services.players.services import PlayerInfoService, PlayersService @@ -32,11 +34,15 @@ class PlayerInfoSystem(Plugin): 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()}[str(player_info.hand_image)] - except KeyError: - logger.warning("未找到角色 %s 的星级", player_info.hand_image) + if player_info.hand_image > 10000000: + 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()}[str(player_info.hand_image)] + except KeyError: + logger.warning("未找到角色 %s 的星级", player_info.hand_image) + else: + avatar = Assets.profile_picture(player_info.hand_image).url + rarity = 5 except Exception as exc: # pylint: disable=W0703 logger.error("卡片信息请求失败 %s", str(exc)) if name_card is None: # 默认