From af98cb11c59876b7c3efc3f1911f56a057d63197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B8=A6=E7=BE=BD?= Date: Fri, 30 May 2025 10:30:53 +0800 Subject: [PATCH] fix: handle missing nh3 library in plugin.py --- astrbot/dashboard/routes/plugin.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index 5c7832003..4f89dbcfc 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -4,7 +4,6 @@ import os import ssl import certifi -import nh3 from .route import Route, Response, RouteContext from astrbot.core import logger @@ -19,6 +18,12 @@ from astrbot.core.star.filter.regex import RegexFilter from astrbot.core.star.star_handler import EventType from astrbot.core import DEMO_MODE +try: + import nh3 +except ImportError: + logger.warning("未安装 nh3 库,无法清理插件 README.md 中的 HTML 标签。") + nh3 = None + class PluginRoute(Route): def __init__( @@ -327,6 +332,9 @@ class PluginRoute(Route): return Response().error(str(e)).__dict__ async def get_plugin_readme(self): + if not nh3: + return Response().error("未安装 nh3 库").__dict__ + plugin_name = request.args.get("name") logger.debug(f"正在获取插件 {plugin_name} 的README文件内容")