Compare commits

...
6 Commits
Author SHA1 Message Date
Hanako Uesugi 8a25dea757 Merge 4a7b1cec4d into c571bfb133 2025-07-26 15:30:23 +08:00
AkashiCoin c571bfb133 🎉 chore(version): Update version to v0.2.4-da6d5b4 (#1822)
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Sequential Lint and Type Check / ruff-call (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Force Sync to Aliyun / sync (push) Has been cancelled
Sequential Lint and Type Check / pyright-call (push) Has been cancelled
2025-07-25 10:50:23 +08:00
HibiKier da6d5b4be4 🐛 修复bot个人介绍重载后不重新读取个人介绍文件 (#1990)
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run
Sequential Lint and Type Check / ruff-call (push) Waiting to run
Sequential Lint and Type Check / pyright-call (push) Blocked by required conditions
Release Drafter / Update Release Draft (push) Waiting to run
Force Sync to Aliyun / sync (push) Waiting to run
检查bot是否运行正常 / bot check (push) Has been cancelled
Update Version / update-version (push) Has been cancelled
2025-07-24 15:59:28 +08:00
HibiKier 62fac483f2 ✨ feat(workflow): 新增阿里云强制同步工作流配置 (#1991) 2025-07-24 15:59:17 +08:00
pre-commit-ci[bot] 4a7b1cec4d 🚨 auto fix by pre-commit hooks 2025-07-07 18:13:03 +00:00
Hanako ab4116a253 ✨ 添加并修复webui对kook、discord的头像显示 2025-07-08 02:11:32 +08:00
8 changed files with 77 additions and 11 deletions
+26
View File
@@ -0,0 +1,26 @@
name: Force Sync to Aliyun
on:
push:
branches: ["main"]
jobs:
sync:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config --global http.postBuffer 524288000
git config --global core.compression 0
- name: Add aliyun remote
run: |
git remote add aliyun https://${{secrets.ALIYUN_ACCOUNT}}:${{secrets.ALIYUN_PASSWORD}}@codeup.aliyun.com/67a361cf556e6cdab537117a/zhenxun-org/zhenxun_bot.git
git fetch aliyun main --force # 强制更新本地引用
- name: Force push
run: git push --progress --force aliyun HEAD:main
+1 -1
View File
@@ -1 +1 @@
__version__: v0.2.4-2c97eea
__version__: v0.2.4-da6d5b4
@@ -54,15 +54,17 @@ class ApiDataSource:
if platform == "qq":
login_info = await bot.get_login_info()
nickname = login_info["nickname"]
ava_url = (
PlatformUtils.get_user_avatar_url(
ava_url: str = (
await PlatformUtils.get_user_avatar_url(
bot.self_id, "qq", BotConfig.get_qbot_uid(bot.self_id)
)
or ""
)
else:
nickname = bot.self_id
ava_url = ""
ava_url: str = (
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
)
@@ -76,11 +76,13 @@ class ApiDataSource:
login_info = await bot.get_login_info()
except Exception as e:
logger.warning("调用接口get_login_info失败", "WebUi", e=e)
platform = PlatformUtils.get_platform(bot) or ""
return TemplateBaseInfo(
bot=bot,
self_id=bot.self_id,
nickname=login_info["nickname"] if login_info else bot.self_id,
ava_url=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
+4
View File
@@ -19,6 +19,10 @@ 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)
"""kaiheilabot id:账号id"""
discord_bots: list[dict] = Field(default_factory=list)
"""discordbot id:账号id"""
def get_qbot_uid(self, qbot_id: str) -> str | None:
"""获取官bot账号id
+2
View File
@@ -1,3 +1,4 @@
import asyncio
from typing_extensions import Self
from nonebot.adapters import Bot
@@ -132,6 +133,7 @@ class FgRequest(Model):
bot.self_id
)
if file_path:
await asyncio.sleep(2)
await PlatformUtils.send_message(
bot,
req.user_id,
@@ -76,6 +76,7 @@ class BotProfileManager:
_f = PROFILE_IMAGE_PATH / f
if _f.is_file():
_f.unlink()
cls._bot_data.clear()
@classmethod
async def _read_profile(cls, bot_id: str):
+35 -6
View File
@@ -235,7 +235,7 @@ class PlatformUtils:
return await AsyncHttpx.get_content(url) if url else None
@classmethod
def get_user_avatar_url(
async def get_user_avatar_url(
cls, user_id: str, platform: str, appid: str | None = None
) -> str | None:
"""快捷获取用户头像url
@@ -244,12 +244,41 @@ class PlatformUtils:
user_id: 用户id
platform: 平台
"""
if platform != "qq":
return None
if user_id.isdigit():
return f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=160"
if platform == "qq":
if user_id.isdigit():
return f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=160"
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}
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"]
return cls._kook_cache
else:
return cls._kook_cache # 使用临时缓存
elif platform == "discord":
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
)
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 # 使用临时缓存
else:
return f"https://q.qlogo.cn/qqapp/{appid}/{user_id}/640"
return None
@classmethod
async def get_group_avatar(cls, gid: str, platform: str) -> bytes | None: