iamai.plugin module¶
iamai plugins
This module contains the base class for all iamai plugins.
- class iamai.plugin.Plugin[source]¶
Bases:
ABC,Generic[EventT,StateT,ConfigT]Base class for all iamai plugins.
- event¶
The event currently being processed by this plugin.
- Type:
iamai.typing.EventT
- priority¶
The priority of the plugin. The smaller the number, the higher the priority. The default is 0.
- Type:
ClassVar[int]
- block¶
Whether to prevent the propagation of events after the plug-in is executed.
Truemeans blocking.- Type:
ClassVar[bool]
- __plugin_load_type__¶
Plugin load type, automatically set by iamai, reflects how this plugin is loaded.
- Type:
ClassVar[iamai.plugin.PluginLoadType]
- __plugin_file_path__¶
Nonewhen the plugin loading type isPluginLoadType.CLASS, Otherwise, the location of the Python module in which the plugin is defined.- Type:
ClassVar[str | None]
- Config: Type[ConfigT]¶
- block: ClassVar[bool] = False¶
- property config: ConfigT¶
plugin configuration.
- event: EventT = InnerDepends(Event)¶
- abstract async handle() None[source]¶
Method to handle events. iamai will call this method when the
rule()method returnsTrue. Each plugin must implement this method.
- property name: str¶
plugin class name.
- priority: ClassVar[int] = 0¶
- abstract async rule() bool[source]¶
Method to match the event. When the event is processed, this method will be called in sequence according to the priority of the plugin. When this method returns
True, the event will be handed over to this plugin for processing. Each plugin must implement this method.Note
It is not recommended to implement event processing directly in this method. Please leave the specific processing of events to the
handle()method.
- property state: StateT¶
plugin status.