iamai.event module¶
iamai event.
Base class for event classes. Adapter developers should implement a subclass of this event class base class.
- class iamai.event.Event(*, adapter: Any, type: str | None, **extra_data: Any)[源代码]¶
基类:
ABC,BaseModel,Generic[AdapterT]The base class of event classes.
- adapter¶
The adapter object that generated the current event.
- Type:
Any
- type¶
event type.
- Type:
str | None
- __handled__¶
Indicates whether the event has been handled, used for adapter processing. Warning: Do not change the value of this property manually.
- Type:
bool
- adapter: Any¶
- model_config: ClassVar[ConfigDict] = {'extra': 'allow'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: str | None¶
- class iamai.event.MessageEvent(*, adapter: Any, type: str | None, **extra_data: Any)[源代码]¶
基类:
Event,Generic[AdapterT]Base class for general message event classes.
- adapter: Any¶
- async ask(message: str, max_try_times: int | None = None, timeout: int | float | None = None) Self[源代码]¶
Ask for news.
Indicates getting the user's reply after replying to a message. Equivalent to executing
get()afterreply().- 参数:
message -- The content of the reply message.
max_try_times -- Maximum number of events.
timeout -- timeout period.
- 返回:
Message event that the user replies to.
- async get(*, max_try_times: int | None = None, timeout: int | float | None = None) Self[源代码]¶
Get the user's reply message.
Equivalent to get() of
Bot, the condition is that the adapter, event type and sender are the same.- 参数:
max_try_times -- Maximum number of events.
timeout -- timeout period.
- 返回:
Message event that the user replies to.
- 抛出:
GetEventTimeout -- Maximum number of events exceeded or timeout.
- abstract get_plain_text() str[源代码]¶
Get the plain text content of the message.
- 返回:
The plain text content of the message.
- abstract async is_same_sender(other: Self) bool[源代码]¶
Determine whether itself and another event are the same sender.
- 参数:
other -- another event.
- 返回:
Is it the same sender?
- model_config: ClassVar[ConfigDict] = {'extra': 'allow'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- abstract async reply(message: str) Any[源代码]¶
Reply message.
- 参数:
message -- The content of the reply message.
- 返回:
The response to the reply message action.
- type: str | None¶