raito.plugins.conversations.registry module

class raito.plugins.conversations.registry.ConversationData(future, filters)[исходный код]

Базовые классы: NamedTuple

Container for an active conversation.

Stores the Future object awaiting a message and the filters to apply.

Параметры:
  • future (Future[Message]) – asyncio.Future that will hold the incoming Message

  • filters (Sequence[Callable[[...], Any]]) – Sequence of CallbackType filters to validate the message

future: Future[Message]

Alias for field number 0

filters: Sequence[Callable[[...], Any]]

Alias for field number 1

class raito.plugins.conversations.registry.ConversationRegistry[исходный код]

Базовые классы: object

Registry for managing active conversations with users.

This class allows setting up a «wait for message» scenario where a handler can pause and wait for a specific message from a user, optionally filtered by aiogram filters.

STATE = 'raito__conversation'
listen(key, *filters)[исходный код]

Start listening for a message with a specific StorageKey.

Параметры:
  • key (StorageKey) – StorageKey identifying the conversation (user/chat/bot)

  • filters (Callable[[...], Any]) – Optional filters to apply when the message arrives

Результат:

Future that will resolve with the Message when received

Тип результата:

Future[Message]

get_filters(key)[исходный код]

Get the filters associated with an active conversation.

Параметры:

key (StorageKey) – StorageKey identifying the conversation

Результат:

Sequence of CallbackType filters or None if no conversation exists

Тип результата:

Sequence[Callable[[…], Any]] | None

resolve(key, message)[исходный код]

Complete the conversation with a received message.

Параметры:
  • key (StorageKey) – StorageKey identifying the conversation

  • message (Message) – Message object that satisfies the filters

Тип результата:

None

cancel(key)[исходный код]

Cancel an active conversation.

Cancels the Future and removes the conversation from the registry.

Параметры:

key (StorageKey) – StorageKey identifying the conversation

Тип результата:

None