From 742d1f1f028903727a878e63e63c1e8c81bada02 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Mon, 10 Jan 2022 22:52:10 +0800 Subject: [PATCH] :alembic: fix load builtin plugin --- nonebot/__init__.py | 2 ++ nonebot/plugin/__init__.py | 1 + nonebot/plugin/load.py | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/nonebot/__init__.py b/nonebot/__init__.py index 8d2a78f3..e5dc5aa3 100644 --- a/nonebot/__init__.py +++ b/nonebot/__init__.py @@ -21,6 +21,7 @@ - ``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_plugin`` => ``nonebot.plugin.load_builtin_plugin`` - ``load_builtin_plugins`` => ``nonebot.plugin.load_builtin_plugins`` - ``get_plugin`` => ``nonebot.plugin.get_plugin`` - ``get_loaded_plugins`` => ``nonebot.plugin.get_loaded_plugins`` @@ -322,4 +323,5 @@ from nonebot.plugin import load_from_toml as load_from_toml from nonebot.plugin import load_all_plugins as load_all_plugins from nonebot.plugin import on_shell_command as on_shell_command from nonebot.plugin import get_loaded_plugins as get_loaded_plugins +from nonebot.plugin import load_builtin_plugin as load_builtin_plugin from nonebot.plugin import load_builtin_plugins as load_builtin_plugins diff --git a/nonebot/plugin/__init__.py b/nonebot/plugin/__init__.py index e55e1180..e9cd0538 100644 --- a/nonebot/plugin/__init__.py +++ b/nonebot/plugin/__init__.py @@ -37,5 +37,6 @@ from .load import load_from_json as load_from_json from .load import load_from_toml as load_from_toml from .on import on_shell_command as on_shell_command from .load import load_all_plugins as load_all_plugins +from .load import load_builtin_plugin as load_builtin_plugin from .plugin import get_loaded_plugins as get_loaded_plugins from .load import load_builtin_plugins as load_builtin_plugins diff --git a/nonebot/plugin/load.py b/nonebot/plugin/load.py index 26d2d7e3..642d7bcc 100644 --- a/nonebot/plugin/load.py +++ b/nonebot/plugin/load.py @@ -131,7 +131,7 @@ def load_from_toml(file_path: str, encoding: str = "utf-8") -> Set[Plugin]: return load_all_plugins(plugins, plugin_dirs) -def load_builtin_plugins(name: str) -> Optional[Plugin]: +def load_builtin_plugin(name: str) -> Optional[Plugin]: """ :说明: @@ -144,6 +144,19 @@ def load_builtin_plugins(name: str) -> Optional[Plugin]: return load_plugin(f"nonebot.plugins.{name}") +def load_builtin_plugins(*plugins) -> Set[Plugin]: + """ + :说明: + + 导入多个 NoneBot 内置插件 + + :返回: + + - ``Set[Plugin]`` + """ + return load_all_plugins([f"nonebot.plugins.{p}" for p in plugins], []) + + def require(name: str) -> Export: """ :说明: