⚗️ fix load builtin plugin

This commit is contained in:
yanyongyu 2022-01-10 22:52:10 +08:00
parent 1b035ed19b
commit 742d1f1f02
3 changed files with 17 additions and 1 deletions

View File

@ -21,6 +21,7 @@
- ``load_all_plugins`` => ``nonebot.plugin.load_all_plugins`` - ``load_all_plugins`` => ``nonebot.plugin.load_all_plugins``
- ``load_from_json`` => ``nonebot.plugin.load_from_json`` - ``load_from_json`` => ``nonebot.plugin.load_from_json``
- ``load_from_toml`` => ``nonebot.plugin.load_from_toml`` - ``load_from_toml`` => ``nonebot.plugin.load_from_toml``
- ``load_builtin_plugin`` => ``nonebot.plugin.load_builtin_plugin``
- ``load_builtin_plugins`` => ``nonebot.plugin.load_builtin_plugins`` - ``load_builtin_plugins`` => ``nonebot.plugin.load_builtin_plugins``
- ``get_plugin`` => ``nonebot.plugin.get_plugin`` - ``get_plugin`` => ``nonebot.plugin.get_plugin``
- ``get_loaded_plugins`` => ``nonebot.plugin.get_loaded_plugins`` - ``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 load_all_plugins as load_all_plugins
from nonebot.plugin import on_shell_command as on_shell_command 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 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 from nonebot.plugin import load_builtin_plugins as load_builtin_plugins

View File

@ -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 .load import load_from_toml as load_from_toml
from .on import on_shell_command as on_shell_command from .on import on_shell_command as on_shell_command
from .load import load_all_plugins as load_all_plugins 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 .plugin import get_loaded_plugins as get_loaded_plugins
from .load import load_builtin_plugins as load_builtin_plugins from .load import load_builtin_plugins as load_builtin_plugins

View File

@ -131,7 +131,7 @@ def load_from_toml(file_path: str, encoding: str = "utf-8") -> Set[Plugin]:
return load_all_plugins(plugins, plugin_dirs) 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}") 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: def require(name: str) -> Export:
""" """
:说明: :说明: