diff --git a/ncatbot/app/client.py b/ncatbot/app/client.py index 682dc857..3fd0c06b 100644 --- a/ncatbot/app/client.py +++ b/ncatbot/app/client.py @@ -51,8 +51,6 @@ def __init__( adapter: Optional[BaseAdapter] = None, *, adapters: Optional[Sequence[BaseAdapter]] = None, - plugin_dir: str = "plugins", - debug: bool = False, ) -> None: setup_logging(debug=ncatbot_config.debug) @@ -80,9 +78,7 @@ def __init__( self._dispatcher: Optional[AsyncEventDispatcher] = None self._handler_dispatcher: Optional[HandlerDispatcher] = None self._service_manager = ServiceManager() - self._plugin_loader = PluginLoader(debug=debug) - self._plugin_dir = Path(plugin_dir) - self._debug = debug + self._plugin_loader = PluginLoader(debug=ncatbot_config.debug) self._running = False self._listen_task: Optional[asyncio.Task] = None self._listen_tasks: List[asyncio.Task] = [] @@ -348,7 +344,7 @@ def _setup_handler_dispatcher(self) -> None: async def _setup_services(self) -> None: """注册并加载所有内置服务。""" self._service_manager.set_event_callback(self.dispatcher.callback) - self._service_manager.register_builtin(debug=self._debug) + self._service_manager.register_builtin(debug=ncatbot_config.debug) await self._service_manager.load_all() async def _setup_plugins(self) -> None: @@ -367,9 +363,9 @@ def _inject_plugin_deps(plugin, manifest): self._plugin_loader._on_plugin_init = _inject_plugin_deps await self._plugin_loader.load_builtin_plugins() - await self._plugin_loader.load_all(self._plugin_dir) + await self._plugin_loader.load_all(ncatbot_config.plugin.plugins_dir) - if self._debug and self._service_manager.has("file_watcher"): + if ncatbot_config.debug and self._service_manager.has("file_watcher"): fw = self._service_manager.file_watcher - fw.add_watch_dir(str(self._plugin_dir.resolve())) + fw.add_watch_dir(ncatbot_config.plugin.plugins_dir) self._plugin_loader.setup_hot_reload(fw) diff --git a/pyproject.toml b/pyproject.toml index 1249e172..4af7abc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ncatbot5" -version = "5.2.11.post2" +version = "5.2.11.post3" description = "NcatBot, NapCat Python SDK" readme = "README.md" license = { text = "MIT" } diff --git a/uv.lock b/uv.lock index 65769575..2fa2b9ec 100644 --- a/uv.lock +++ b/uv.lock @@ -1243,7 +1243,7 @@ wheels = [ [[package]] name = "ncatbot5" -version = "5.2.11" +version = "5.2.11.post1" source = { editable = "." } dependencies = [ { name = "aiohttp" },