diff --git a/core/data/temp/help_menu.png b/core/data/temp/help_menu.png index 7750044..4f42dbe 100644 Binary files a/core/data/temp/help_menu.png and b/core/data/temp/help_menu.png differ diff --git a/core/managers/command_manager.py b/core/managers/command_manager.py index 5d84e28..e79e80f 100644 --- a/core/managers/command_manager.py +++ b/core/managers/command_manager.py @@ -202,17 +202,20 @@ class CommandManager: 内置的 `/help` 命令的实现。 直接从 Redis 获取缓存的图片。 """ - # 1. 尝试从 Redis 获取 - help_pic = await redis_manager.get("neobot:core:help_pic") - - if not help_pic: - await bot.send(event, "帮助图片缓存缺失,正在重新生成...") - await self.sync_help_pic() + try: + # 1. 尝试从 Redis 获取 help_pic = await redis_manager.get("neobot:core:help_pic") - if help_pic: - await bot.send(event, MessageSegment.image(help_pic)) - return + if not help_pic: + await bot.send(event, "帮助图片缓存缺失,正在重新生成...") + await self.sync_help_pic() + help_pic = await redis_manager.get("neobot:core:help_pic") + + if help_pic: + await bot.send(event, MessageSegment.image(help_pic)) + return + except Exception as e: + logger.error(f"获取或生成帮助图片失败: {e}") # 2. 最后的兜底:发送纯文本 help_text = "--- 可用指令列表 ---\n" diff --git a/docs/deployment.md b/docs/deployment.md index e2b1ca7..62e8d2f 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -24,10 +24,7 @@ pip install -r requirements.txt ### c. 编译核心模块 (可选,但为获得最佳性能强烈建议) -为了最大化性能,我们提供了两层级性能优化方案: - -#### 1. Mypyc 编译 (AOT - Ahead-of-Time) -将核心 Python 模块编译成 C 语言扩展。这将大幅提升机器人的响应速度和处理效率。 +为了最大化性能,你可以将项目中的核心 Python 模块编译成 C 语言扩展。这将大幅提升机器人的响应速度和处理效率。 ```bash # 确保你在虚拟环境中 @@ -38,16 +35,6 @@ python setup_mypyc.py > **注意**: 编译产物是平台相关的(例如,在 Windows 上编译的 `.pyd` 文件不能在 Linux 上使用)。因此,**请务必在你最终部署的服务器环境(例如 Linux)上执行此编译步骤**。更多关于 Mypyc 编译的细节,请参考 [性能优化详解](core-concepts/performance.md)。 -#### 2. Python 3.14 JIT (Just-In-Time) -即使不编译核心模块,你也可以通过启用 Python 3.14 自带的 JIT 编译器来获得性能提升。JIT 会在运行时将热点代码编译为机器码。 - -**如何启用**: 在启动命令中添加 `-X jit` 参数,或者在下面的 pm2 配置中添加 JIT 参数。 - -**性能策略**: -- **AOT (Mypyc)**: 负责静态、类型明确的核心模块(WebSocket、管理器、工具函数) -- **JIT**: 负责动态、灵活的插件代码(B站解析、代码沙箱等业务逻辑) -- **两者结合**: 可获得最佳性能,全面覆盖所有代码路径 - ## 2. 使用进程管理器 你想直接 `python main.py` 然后关掉 SSH?那机器人也跟着停了。必须用进程管理器来守护它。 @@ -71,7 +58,6 @@ module.exports = { name : "neobot", script : "main.py", interpreter: "/path/to/your/bot/venv/bin/python", // 指定虚拟环境里的 python - args: "-X jit", // 启用 Python 3.14 JIT 编译器 max_memory_restart: "500M", // 内存超过 500M 自动重启 env: { "PYTHONUNBUFFERED": "1" // 禁用 python 输出缓冲,日志能实时看 diff --git a/plugins/bili_parser.py b/plugins/bili_parser.py index 3b9030f..a8172cc 100644 --- a/plugins/bili_parser.py +++ b/plugins/bili_parser.py @@ -126,7 +126,9 @@ async def get_direct_video_url(video_url: str) -> Optional[str]: async with aiohttp.ClientSession() as session: async with session.get(api_url, headers=HEADERS, timeout=10) as response: response.raise_for_status() - data = await response.json() + # 使用 content_type=None 来忽略 Content-Type 检查 + # 因为 API 返回 text/json 而不是标准的 application/json + data = await response.json(content_type=None) if data.get("code") == 200 and data.get("data"): return data["data"][0].get("video_url") except (aiohttp.ClientError, json.JSONDecodeError, KeyError, IndexError) as e: diff --git a/templates/help.html b/templates/help.html index 4fdc65e..1388304 100644 --- a/templates/help.html +++ b/templates/help.html @@ -3,132 +3,235 @@ - NeoBot 帮助菜单 + CalglauBot Menu + -
+
+
-

NeoBot

-

功能插件列表

+
+
+
+
+
+
NeoBot System
-
+
+ +
+

功能中心

+

Dashboard & Command List · {{ plugins|length }} Modules Loaded

+
+ + {% for plugin in plugins %}
-
- {{ plugin.name }} -
-
{{ plugin.description }}
-
- {{ plugin.usage }} +
+
+ {{ plugin.name }} + Plugin +
+
+ {{ plugin.description }} +
+ + +
{{ plugin.usage }}
{% endfor %}
- \ No newline at end of file +