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文件内容")