🐛 Fix new profile avatar

This commit is contained in:
xtaodada 2024-06-01 22:21:03 +08:00
parent 1f27aada4e
commit f5480f316a
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 13 additions and 7 deletions

View File

@ -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)

View File

@ -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: # 默认