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. True means 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__

None when the plugin loading type is PluginLoadType.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 bot: Bot

bot object.

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 returns True. 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.

final skip() NoReturn[source]

Skips itself and continues propagation of the current event.

property state: StateT

plugin status.

final stop() NoReturn[source]

Stop propagation of current events.

class iamai.plugin.PluginLoadType(value)[source]

Bases: Enum

Plugins loaded types.

CLASS = 'class'
DIR = 'dir'
FILE = 'file'
NAME = 'name'