mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-25 01:25:04 +08:00
123 lines
2.3 KiB
Markdown
123 lines
2.3 KiB
Markdown
|
---
|
||
|
sidebar_position: 5
|
||
|
description: nonebot.plugin.manager 模块
|
||
|
---
|
||
|
|
||
|
# nonebot.plugin.manager
|
||
|
|
||
|
本模块实现插件加载流程。
|
||
|
|
||
|
参考: [import hooks](https://docs.python.org/3/reference/import.html#import-hooks), [PEP302](https://www.python.org/dev/peps/pep-0302/)
|
||
|
|
||
|
## _class_ `PluginManager(plugins=None, search_path=None)` {#PluginManager}
|
||
|
|
||
|
- **说明**
|
||
|
|
||
|
插件管理器。
|
||
|
|
||
|
- **参数**
|
||
|
|
||
|
- `plugins` (Iterable[str] | None): 独立插件模块名集合。
|
||
|
|
||
|
- `search_path` (Iterable[str] | None): 插件搜索路径(文件夹)。
|
||
|
|
||
|
### _property_ `available_plugins` {#PluginManager-available_plugins}
|
||
|
|
||
|
- **类型:** set[str]
|
||
|
|
||
|
- **说明:** 返回当前插件管理器中可用的插件名称。
|
||
|
|
||
|
### _property_ `searched_plugins` {#PluginManager-searched_plugins}
|
||
|
|
||
|
- **类型:** set[str]
|
||
|
|
||
|
- **说明:** 返回已搜索到的插件名称。
|
||
|
|
||
|
### _property_ `third_party_plugins` {#PluginManager-third_party_plugins}
|
||
|
|
||
|
- **类型:** set[str]
|
||
|
|
||
|
- **说明:** 返回所有独立插件名称。
|
||
|
|
||
|
### _method_ `load_all_plugins(self)` {#PluginManager-load_all_plugins}
|
||
|
|
||
|
- **说明**
|
||
|
|
||
|
加载所有可用插件。
|
||
|
|
||
|
- **返回**
|
||
|
|
||
|
- set[[Plugin](./plugin.md#Plugin)]
|
||
|
|
||
|
### _method_ `load_plugin(self, name)` {#PluginManager-load_plugin}
|
||
|
|
||
|
- **说明**
|
||
|
|
||
|
加载指定插件。
|
||
|
|
||
|
对于独立插件,可以使用完整插件模块名或者插件名称。
|
||
|
|
||
|
- **参数**
|
||
|
|
||
|
- `name` (str): 插件名称。
|
||
|
|
||
|
- **返回**
|
||
|
|
||
|
- [Plugin](./plugin.md#Plugin) | None
|
||
|
|
||
|
### _method_ `prepare_plugins(self)` {#PluginManager-prepare_plugins}
|
||
|
|
||
|
- **说明**
|
||
|
|
||
|
搜索插件并缓存插件名称。
|
||
|
|
||
|
- **返回**
|
||
|
|
||
|
- set[str]
|
||
|
|
||
|
## _class_ `PluginFinder()` {#PluginFinder}
|
||
|
|
||
|
### _method_ `find_spec(self, fullname, path, target=None)` {#PluginFinder-find_spec}
|
||
|
|
||
|
- **参数**
|
||
|
|
||
|
- `fullname` (str)
|
||
|
|
||
|
- `path` (Sequence[str] | None)
|
||
|
|
||
|
- `target` (module | None)
|
||
|
|
||
|
- **返回**
|
||
|
|
||
|
- Unknown
|
||
|
|
||
|
## _class_ `PluginLoader(manager, fullname, path)` {#PluginLoader}
|
||
|
|
||
|
- **参数**
|
||
|
|
||
|
- `manager` ([PluginManager](#PluginManager))
|
||
|
|
||
|
- `fullname` (str)
|
||
|
|
||
|
- `path`
|
||
|
|
||
|
### _method_ `create_module(self, spec)` {#PluginLoader-create_module}
|
||
|
|
||
|
- **参数**
|
||
|
|
||
|
- `spec`
|
||
|
|
||
|
- **返回**
|
||
|
|
||
|
- module | None
|
||
|
|
||
|
### _method_ `exec_module(self, module)` {#PluginLoader-exec_module}
|
||
|
|
||
|
- **参数**
|
||
|
|
||
|
- `module` (module)
|
||
|
|
||
|
- **返回**
|
||
|
|
||
|
- None
|