diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index 5fa1e23c5..ff07de712 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -13,7 +13,6 @@ import traceback from types import ModuleType from typing import List -import nh3 import yaml from astrbot.core import logger, pip_installer, sp @@ -38,6 +37,12 @@ except ImportError: if os.getenv("ASTRBOT_RELOAD", "0") == "1": logger.warning("未安装 watchfiles,无法实现插件的热重载。") +try: + import nh3 +except ImportError: + logger.warning("未安装 nh3 库,无法清理插件 README.md 中的 HTML 标签。") + nh3 = None + class PluginManager: def __init__(self, context: Context, config: AstrBotConfig): @@ -141,11 +146,13 @@ class PluginManager: if os.path.exists(os.path.join(path, d, "main.py")) or os.path.exists( os.path.join(path, d, d + ".py") ): - modules.append({ - "pname": d, - "module": module_str, - "module_path": os.path.join(path, d, module_str), - }) + modules.append( + { + "pname": d, + "module": module_str, + "module_path": os.path.join(path, d, module_str), + } + ) return modules def _get_plugin_modules(self) -> List[dict]: @@ -635,7 +642,7 @@ class PluginManager: if not os.path.exists(readme_path): readme_path = os.path.join(plugin_path, "readme.md") - if os.path.exists(readme_path): + if os.path.exists(readme_path) and nh3: try: with open(readme_path, "r", encoding="utf-8") as f: readme_content = f.read() diff --git a/astrbot/dashboard/routes/auth.py b/astrbot/dashboard/routes/auth.py index 896bea4e7..5ce578305 100644 --- a/astrbot/dashboard/routes/auth.py +++ b/astrbot/dashboard/routes/auth.py @@ -21,7 +21,11 @@ class AuthRoute(Route): post_data = await request.json if post_data["username"] == username and post_data["password"] == password: change_pwd_hint = False - if username == "astrbot" and password == "77b90590a8945a7d36c963981a307dc9": + if ( + username == "astrbot" + and password == "77b90590a8945a7d36c963981a307dc9" + and not DEMO_MODE + ): change_pwd_hint = True logger.warning("为了保证安全,请尽快修改默认密码。") 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文件内容") diff --git a/dashboard/src/components/shared/ExtensionCard.vue b/dashboard/src/components/shared/ExtensionCard.vue index b9d4d8c6c..5956e1f78 100644 --- a/dashboard/src/components/shared/ExtensionCard.vue +++ b/dashboard/src/components/shared/ExtensionCard.vue @@ -77,7 +77,7 @@ const viewReadme = () => {