iamai.plugin module#
iamai 插件。
所有 iamai 插件的基类。所有用户编写的插件必须继承自 Plugin 类。
- class iamai.plugin.Plugin[source]#
Bases:
ABC
,Generic
[EventT
,StateT
,ConfigT
]所有 iamai 插件的基类。
- event#
当前正在被此插件处理的事件。
- Type:
iamai.typing.EventT
- priority#
插件的优先级,数字越小表示优先级越高,默认为 0。
- Type:
ClassVar[int]
- block#
插件执行结束后是否阻止事件的传播。True 表示阻止。
- Type:
ClassVar[bool]
- __plugin_load_type__#
插件加载类型,由 iamai 自动设置,反映了此插件是如何被加载的。
- Type:
ClassVar[iamai.plugin.PluginLoadType]
- __plugin_file_path__#
当插件加载类型为 PluginLoadType.CLASS 时为 None, 否则为定义插件在的 Python 模块的位置。
- Type:
ClassVar[str | None]
- Config: Type[ConfigT]#
- block: ClassVar[bool] = False#
- property config: ConfigT#
插件配置。
- event: EventT = InnerDepends(Event)#
- property name: str#
插件类名称。
- priority: ClassVar[int] = 0#
- abstract async rule() bool [source]#
匹配事件的方法。事件处理时,会按照插件的优先级依次调用此方法,当此方法返回 True 时将事件交由此插件处理。每个插件必须实现此方法。
注意:不建议直接在此方法内实现对事件的处理,事件的具体处理请交由 handle() 方法。
- property state: StateT#
插件状态。