mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🚨 auto fix by pre-commit hooks
This commit is contained in:
parent
5ec4baf089
commit
1898760bee
@ -63,10 +63,7 @@ class ApiDataSource:
|
|||||||
else:
|
else:
|
||||||
nickname = bot.self_id
|
nickname = bot.self_id
|
||||||
ava_url = (
|
ava_url = (
|
||||||
await PlatformUtils.get_user_avatar_url(
|
await PlatformUtils.get_user_avatar_url(bot.self_id, platform) or ""
|
||||||
bot.self_id, platform
|
|
||||||
)
|
|
||||||
or ""
|
|
||||||
)
|
)
|
||||||
bot_info = BotInfo(
|
bot_info = BotInfo(
|
||||||
self_id=bot.self_id, nickname=nickname, ava_url=ava_url, platform=platform
|
self_id=bot.self_id, nickname=nickname, ava_url=ava_url, platform=platform
|
||||||
|
|||||||
@ -81,9 +81,7 @@ class ApiDataSource:
|
|||||||
bot=bot,
|
bot=bot,
|
||||||
self_id=bot.self_id,
|
self_id=bot.self_id,
|
||||||
nickname=login_info["nickname"] if login_info else bot.self_id,
|
nickname=login_info["nickname"] if login_info else bot.self_id,
|
||||||
ava_url=await PlatformUtils.get_user_avatar_url(
|
ava_url=await PlatformUtils.get_user_avatar_url(bot.self_id, platform)
|
||||||
bot.self_id, platform
|
|
||||||
)
|
|
||||||
or AVA_URL.format(bot.self_id),
|
or AVA_URL.format(bot.self_id),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -248,24 +248,28 @@ class PlatformUtils:
|
|||||||
else:
|
else:
|
||||||
return f"https://q.qlogo.cn/qqapp/{appid}/{user_id}/640"
|
return f"https://q.qlogo.cn/qqapp/{appid}/{user_id}/640"
|
||||||
elif platform == "kaiheila":
|
elif platform == "kaiheila":
|
||||||
if not hasattr(cls,'_kook_cache'):
|
if not hasattr(cls, "_kook_cache"):
|
||||||
params = {
|
params = {"user_id": user_id}
|
||||||
'user_id': user_id
|
|
||||||
}
|
|
||||||
header = {
|
header = {
|
||||||
'Authorization': f"Bot {BotConfig.kaiheila_bots[0].get('token')}"
|
"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)
|
result = await AsyncHttpx.get(
|
||||||
cls._kook_cache = result.json()['data']['avatar']
|
url="https://www.kookapp.cn/api/v3/user/view",
|
||||||
|
params=params,
|
||||||
|
headers=header,
|
||||||
|
)
|
||||||
|
cls._kook_cache = result.json()["data"]["avatar"]
|
||||||
return cls._kook_cache
|
return cls._kook_cache
|
||||||
else:
|
else:
|
||||||
return cls._kook_cache # 使用临时缓存
|
return cls._kook_cache # 使用临时缓存
|
||||||
elif platform == "discord":
|
elif platform == "discord":
|
||||||
if not hasattr(cls,'_discord_cache'):
|
if not hasattr(cls, "_discord_cache"):
|
||||||
header = {
|
header = {
|
||||||
'Authorization': f"Bot {BotConfig.discord_bots[0].get('token')}"
|
"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"
|
cls._discord_cache = f"https://cdn.discordapp.com/avatars/{user_id}/{result.json()['avatar']}.png?size=256"
|
||||||
return cls._discord_cache
|
return cls._discord_cache
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user