diff --git a/README.md b/README.md index ed33004da..eca615c99 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,6 @@ AstrBot 是一个开源的一站式 Agentic 个人和群聊助手,可在 QQ、 -陪伴与能力**从来不应该是**对立面。我们希望创造的是一个既能理解情绪、给予陪伴,也能可靠完成工作的机器人——致敬[ATRI](https://zh.wikipedia.org/zh-cn/ATRI_-My_Dear_Moments-)。 - ## 快速开始 #### Docker 部署(推荐 🥳) @@ -268,6 +266,6 @@ pre-commit install _私は、高性能ですから!_ - - list[str]: + """根据模块路径前缀注销平台适配器。 + + 在插件热重载时调用,用于清理该插件注册的所有平台适配器。 + + Args: + module_path_prefix: 模块路径前缀,如 "data.plugins.my_plugin" + + Returns: + 被注销的平台适配器名称列表 + """ + unregistered = [] + to_remove = [] + + for pm in platform_registry: + if pm.module_path and pm.module_path.startswith(module_path_prefix): + to_remove.append(pm) + unregistered.append(pm.name) + + for pm in to_remove: + platform_registry.remove(pm) + if pm.name in platform_cls_map: + del platform_cls_map[pm.name] + logger.debug(f"平台适配器 {pm.name} 已注销 (来自模块 {pm.module_path})") + + return unregistered diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index c59fa314e..567397107 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -15,6 +15,7 @@ import yaml from astrbot.core import logger, pip_installer, sp from astrbot.core.agent.handoff import FunctionTool, HandoffTool from astrbot.core.config.astrbot_config import AstrBotConfig +from astrbot.core.platform.register import unregister_platform_adapters_by_module from astrbot.core.provider.register import llm_tools from astrbot.core.utils.astrbot_path import ( get_astrbot_config_path, @@ -842,6 +843,18 @@ class PluginManager: for func_tool in to_remove: llm_tools.func_list.remove(func_tool) + # Unregister platform adapters registered by this plugin + # module_path is like "data.plugins.my_plugin.main", extract prefix like "data.plugins.my_plugin" + module_prefix = ".".join(plugin_module_path.split(".")[:-1]) + if module_prefix: + unregistered_adapters = unregister_platform_adapters_by_module( + module_prefix + ) + for adapter_name in unregistered_adapters: + logger.info( + f"移除了插件 {plugin_name} 的平台适配器 {adapter_name}", + ) + if plugin is None: return diff --git a/dashboard/public/robots.txt b/dashboard/public/robots.txt new file mode 100644 index 000000000..1f53798bb --- /dev/null +++ b/dashboard/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/dashboard/src/i18n/locales/en-US/features/console.json b/dashboard/src/i18n/locales/en-US/features/console.json index 3c7448586..34f65540a 100644 --- a/dashboard/src/i18n/locales/en-US/features/console.json +++ b/dashboard/src/i18n/locales/en-US/features/console.json @@ -11,5 +11,8 @@ "mirrorLabel": "Force PyPI repository URL (optional)", "mirrorHint": "Force PyPI repository URL > Config item `PyPI Repository Address`", "installButton": "Install" + }, + "debugHint": { + "text": "Debug logs can be enabled in \"Configuration File → System → Console Log Level\"" } -} \ No newline at end of file +} diff --git a/dashboard/src/i18n/locales/zh-CN/features/console.json b/dashboard/src/i18n/locales/zh-CN/features/console.json index 321bda339..844662650 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/console.json +++ b/dashboard/src/i18n/locales/zh-CN/features/console.json @@ -11,5 +11,8 @@ "mirrorLabel": "强制 PyPI 软件仓库链接(可选)", "mirrorHint": "强制 PyPI 软件仓库链接 > 配置项 `PyPI 软件仓库地址`", "installButton": "安装" + }, + "debugHint": { + "text": "Debug 日志需要在「配置文件 → 系统 → 控制台日志级别」中开启" } -} \ No newline at end of file +} diff --git a/dashboard/src/views/ConsolePage.vue b/dashboard/src/views/ConsolePage.vue index 0ffff380d..b4c813f49 100644 --- a/dashboard/src/views/ConsolePage.vue +++ b/dashboard/src/views/ConsolePage.vue @@ -10,7 +10,18 @@ const { tm } = useModuleI18n('features/console');
-

{{ tm('title') }}

+
+

{{ tm('title') }}

+ + {{ tm('debugHint.text') }} + +
\ No newline at end of file + diff --git a/pyproject.toml b/pyproject.toml index 35eb5a73d..2ce53ad39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,14 +69,14 @@ dev = [ "pytest>=8.4.1", "pytest-asyncio>=1.1.0", "pytest-cov>=6.2.1", - "ruff>=0.12.8", + "ruff>=0.15.0", ] [project.scripts] astrbot = "astrbot.cli.__main__:cli" [tool.ruff] -exclude = ["astrbot/core/utils/t2i/local_strategy.py", "astrbot/api/all.py"] +exclude = ["astrbot/core/utils/t2i/local_strategy.py", "astrbot/api/all.py", "tests"] line-length = 88 target-version = "py310" @@ -97,6 +97,7 @@ ignore = [ "F405", "E501", "ASYNC230", # TODO: handle ASYNC230 in AstrBot + "ASYNC240", # TODO: handle ASYNC240 in AstrBot ] [tool.pyright]