diff --git a/docs/api/adapters/mirai.md b/docs/api/adapters/mirai.md index 0a304f8f..1f05088b 100644 --- a/docs/api/adapters/mirai.md +++ b/docs/api/adapters/mirai.md @@ -724,7 +724,7 @@ mirai-api-http 正向 Websocket 协议 Bot 适配。 基类:[`nonebot.adapters._base.MessageSegment`](README.md#nonebot.adapters._base.MessageSegment) -CQHTTP 协议 MessageSegment 适配。具体方法参考 [mirai-api-http 消息类型](https://github.com/project-mirai/mirai-api-http/blob/master/docs/MessageType.md) +Mirai-API-HTTP 协议 MessageSegment 适配。具体方法参考 [mirai-api-http 消息类型](https://github.com/project-mirai/mirai-api-http/blob/master/docs/MessageType.md) ### `as_dict()` diff --git a/docs/api/nonebot.md b/docs/api/nonebot.md index c11cf2be..b726f5bd 100644 --- a/docs/api/nonebot.md +++ b/docs/api/nonebot.md @@ -55,6 +55,12 @@ sidebarDepth: 0 * `load_all_plugins` => `nonebot.plugin.load_all_plugins` +* `load_from_json` => `nonebot.plugin.load_from_json` + + +* `load_from_toml` => `nonebot.plugin.load_from_toml` + + * `load_builtin_plugins` => `nonebot.plugin.load_builtin_plugins` diff --git a/docs/api/plugin.md b/docs/api/plugin.md index 8b16427a..a924bb6b 100644 --- a/docs/api/plugin.md +++ b/docs/api/plugin.md @@ -1334,6 +1334,59 @@ def something_else(): +## `load_from_json(file_path, encoding='utf-8')` + + +* **说明** + + 导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件,以 `_` 开头的插件不会被导入! + + + +* **参数** + + + * `file_path: str`: 指定 json 文件路径 + + + * `encoding: str`: 指定 json 文件编码 + + + +* **返回** + + + * `Set[Plugin]` + + + +## `load_from_toml(file_path, encoding='utf-8')` + + +* **说明** + + 导入指定 toml 文件 `[nonebot.plugins]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件, + 以 `_` 开头的插件不会被导入! + + + +* **参数** + + + * `file_path: str`: 指定 toml 文件路径 + + + * `encoding: str`: 指定 toml 文件编码 + + + +* **返回** + + + * `Set[Plugin]` + + + ## `load_builtin_plugins(name='echo')` diff --git a/nonebot/drivers/__init__.py b/nonebot/drivers/__init__.py index fd435704..134b2078 100644 --- a/nonebot/drivers/__init__.py +++ b/nonebot/drivers/__init__.py @@ -73,8 +73,6 @@ class Driver(abc.ABC): * ``name: str``: 适配器名称,用于在连接时进行识别 * ``adapter: Type[Bot]``: 适配器 Class """ - if name in self._adapters: - print("============", name) self._adapters[name] = adapter adapter.register(self, self.config, **kwargs) logger.opt( diff --git a/nonebot/drivers/quart.py b/nonebot/drivers/quart.py index 9d189d64..d3c0ad42 100644 --- a/nonebot/drivers/quart.py +++ b/nonebot/drivers/quart.py @@ -172,7 +172,6 @@ class Driver(BaseDriver): self_id = await BotClass.check_permission(self, 'websocket', headers, None) except RequestDenied as e: - print(e.reason) raise exceptions.HTTPException(status_code=e.status_code, description=e.reason, name='Request Denied') diff --git a/nonebot/plugin/__init__.py b/nonebot/plugin/__init__.py index be96ecfd..b9ed77ed 100644 --- a/nonebot/plugin/__init__.py +++ b/nonebot/plugin/__init__.py @@ -1071,6 +1071,20 @@ def load_all_plugins(module_path: Set[str], def load_from_json(file_path: str, encoding: str = "utf-8") -> Set[Plugin]: + """ + :说明: + + 导入指定 json 文件中的 ``plugins`` 以及 ``plugin_dirs`` 下多个插件,以 ``_`` 开头的插件不会被导入! + + :参数: + + - ``file_path: str``: 指定 json 文件路径 + - ``encoding: str``: 指定 json 文件编码 + + :返回: + + - ``Set[Plugin]`` + """ with open(file_path, "r", encoding=encoding) as f: data = json.load(f) plugins = data.get("plugins") @@ -1082,6 +1096,21 @@ def load_from_json(file_path: str, encoding: str = "utf-8") -> Set[Plugin]: def load_from_toml(file_path: str, encoding: str = "utf-8") -> Set[Plugin]: + """ + :说明: + + 导入指定 toml 文件 ``[nonebot.plugins]`` 中的 ``plugins`` 以及 ``plugin_dirs`` 下多个插件, + 以 ``_`` 开头的插件不会被导入! + + :参数: + + - ``file_path: str``: 指定 toml 文件路径 + - ``encoding: str``: 指定 toml 文件编码 + + :返回: + + - ``Set[Plugin]`` + """ with open(file_path, "r", encoding=encoding) as f: data = tomlkit.parse(f.read())