🚨 auto fix by pre-commit hooks

This commit is contained in:
pre-commit-ci[bot] 2025-07-07 18:13:02 +00:00
parent ab4116a253
commit 4a7b1cec4d
4 changed files with 22 additions and 23 deletions

View File

@ -63,10 +63,7 @@ class ApiDataSource:
else:
nickname = bot.self_id
ava_url: str = (
await PlatformUtils.get_user_avatar_url(
bot.self_id, platform
)
or ""
await PlatformUtils.get_user_avatar_url(bot.self_id, platform) or ""
)
bot_info = BotInfo(
self_id=bot.self_id, nickname=nickname, ava_url=ava_url, platform=platform

View File

@ -81,10 +81,8 @@ class ApiDataSource:
bot=bot,
self_id=bot.self_id,
nickname=login_info["nickname"] if login_info else bot.self_id,
ava_url=await PlatformUtils.get_user_avatar_url(
bot.self_id, platform
)
or AVA_URL.format(bot.self_id),
ava_url=await PlatformUtils.get_user_avatar_url(bot.self_id, platform)
or AVA_URL.format(bot.self_id),
)
@classmethod

View File

@ -19,7 +19,7 @@ class BotSetting(BaseModel):
"""平台超级用户"""
qbot_id_data: dict[str, str] = Field(default_factory=dict)
"""官bot id:账号id"""
kaiheila_bots: list[dict[str,str]] = Field(default_factory=list)
kaiheila_bots: list[dict[str, str]] = Field(default_factory=list)
"""kaiheilabot id:账号id"""
discord_bots: list[dict] = Field(default_factory=list)
"""discordbot id:账号id"""

View File

@ -248,28 +248,32 @@ class PlatformUtils:
else:
return f"https://q.qlogo.cn/qqapp/{appid}/{user_id}/640"
elif platform == "kaiheila":
if not hasattr(cls,'_kook_cache'):
params = {
'user_id': user_id
if not hasattr(cls, "_kook_cache"):
params = {"user_id": user_id}
header = {
"Authorization": f"Bot {BotConfig.kaiheila_bots[0].get('token')}"
}
header={
'Authorization': f"Bot {BotConfig.kaiheila_bots[0].get('token')}"
}
result=await AsyncHttpx.get(url='https://www.kookapp.cn/api/v3/user/view',params=params,headers=header)
cls._kook_cache = result.json()['data']['avatar']
result = await AsyncHttpx.get(
url="https://www.kookapp.cn/api/v3/user/view",
params=params,
headers=header,
)
cls._kook_cache = result.json()["data"]["avatar"]
return cls._kook_cache
else:
return cls._kook_cache #使用临时缓存
return cls._kook_cache # 使用临时缓存
elif platform == "discord":
if not hasattr(cls,'_discord_cache'):
header={
'Authorization': f"Bot {BotConfig.discord_bots[0].get('token')}"
if not hasattr(cls, "_discord_cache"):
header = {
"Authorization": f"Bot {BotConfig.discord_bots[0].get('token')}"
}
result=await AsyncHttpx.get(url=f'https://discord.com/api/users/{user_id}',headers=header)
result = await AsyncHttpx.get(
url=f"https://discord.com/api/users/{user_id}", headers=header
)
cls._discord_cache = f"https://cdn.discordapp.com/avatars/{user_id}/{result.json()['avatar']}.png?size=256"
return cls._discord_cache
else:
return cls._discord_cache #使用临时缓存
return cls._discord_cache # 使用临时缓存
else:
return None