2022-01-22 15:23:07 +08:00
|
|
|
"""本模块定义插件对象。
|
|
|
|
|
|
|
|
FrontMatter:
|
|
|
|
sidebar_position: 3
|
|
|
|
description: nonebot.plugin.plugin 模块
|
|
|
|
"""
|
2021-11-08 01:02:35 +08:00
|
|
|
from types import ModuleType
|
|
|
|
from dataclasses import field, dataclass
|
2022-05-26 16:35:47 +08:00
|
|
|
from typing import TYPE_CHECKING, Set, Type, Optional
|
2021-11-08 01:02:35 +08:00
|
|
|
|
2021-11-11 17:33:30 +08:00
|
|
|
from nonebot.matcher import Matcher
|
2021-11-08 01:02:35 +08:00
|
|
|
|
2022-01-15 21:27:43 +08:00
|
|
|
from .export import Export
|
2022-05-26 16:35:47 +08:00
|
|
|
from . import _plugins as plugins # FIXME: backport for nonebug
|
2022-01-15 21:27:43 +08:00
|
|
|
|
2021-12-20 00:28:17 +08:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
from .manager import PluginManager
|
|
|
|
|
2021-11-08 01:02:35 +08:00
|
|
|
|
|
|
|
@dataclass(eq=False)
|
|
|
|
class Plugin(object):
|
|
|
|
"""存储插件信息"""
|
2021-11-22 23:21:26 +08:00
|
|
|
|
2021-11-08 01:02:35 +08:00
|
|
|
name: str
|
2022-01-22 15:23:07 +08:00
|
|
|
"""插件名称,使用 文件/文件夹 名称作为插件名"""
|
2021-11-08 01:02:35 +08:00
|
|
|
module: ModuleType
|
2022-01-22 15:23:07 +08:00
|
|
|
"""插件模块对象"""
|
2021-11-08 01:02:35 +08:00
|
|
|
module_name: str
|
2022-01-22 15:23:07 +08:00
|
|
|
"""点分割模块路径"""
|
2021-12-20 00:28:17 +08:00
|
|
|
manager: "PluginManager"
|
2022-01-22 15:23:07 +08:00
|
|
|
"""导入该插件的插件管理器"""
|
2021-11-08 01:02:35 +08:00
|
|
|
export: Export = field(default_factory=Export)
|
2022-05-26 16:35:47 +08:00
|
|
|
"""**Deprecated:** 插件内定义的导出内容"""
|
2021-11-08 01:02:35 +08:00
|
|
|
matcher: Set[Type[Matcher]] = field(default_factory=set)
|
2022-01-22 15:23:07 +08:00
|
|
|
"""插件内定义的 `Matcher`"""
|
2021-11-08 01:02:35 +08:00
|
|
|
parent_plugin: Optional["Plugin"] = None
|
2022-01-22 15:23:07 +08:00
|
|
|
"""父插件"""
|
2021-11-08 01:02:35 +08:00
|
|
|
sub_plugins: Set["Plugin"] = field(default_factory=set)
|
2022-01-22 15:23:07 +08:00
|
|
|
"""子插件集合"""
|