raito.core.raito module

class raito.core.raito.Raito(dispatcher, routers_dir, *, developers=None, locales=None, production=True, enable_dangerous_commands=False, configuration=None, storage=None)[исходный код]

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

Main class for managing the Raito utilities.

Provides router management, middleware setup, etc.

Параметры:
  • dispatcher (Dispatcher)

  • routers_dir (StrOrPath)

  • developers (list[int] | None)

  • locales (list[str] | None)

  • production (bool)

  • enable_dangerous_commands (bool)

  • configuration (RaitoConfiguration | None)

  • storage (BaseStorage | None)

property command_parameters_error: EventObserver

Observer for command signature errors.

Устарело, начиная с версии 1.3.7: Use @raito.Router.on_command_signature_error instead.

async setup()[исходный код]

Set up the Raito by loading routers and starting watchdog.

Loads all routers from the specified directory and starts file watching in development mode for automatic reloading.

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

None

add_throttling(rate_limit, mode='chat', max_size=10000)[исходный код]

Add global throttling middleware to prevent spam.

Applies rate limiting to both messages and callback queries.

Параметры:
  • rate_limit (float) – Time in seconds between allowed requests

  • mode (ThrottlingMiddleware.MODE, optional) – Throttling mode - „chat“, „user“, or „bot“, defaults to „chat“

  • max_size (int, optional) – Maximum cache size for throttling records, defaults to 10_000

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

None

async paginate(name, chat_id, bot, from_user, *, existing_message=None, mode=PaginationMode.INLINE, current_page=1, total_pages=None, limit=20)[исходный код]
Параметры:
  • name (str)

  • chat_id (int)

  • bot (Bot)

  • from_user (User)

  • existing_message (Message | None)

  • mode (PaginationMode)

  • current_page (int)

  • total_pages (int | None)

  • limit (int)

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

None

async register_commands(bot)[исходный код]
Параметры:

bot (Bot)

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

None

init_logging(*mute_loggers)[исходный код]

Configure global logging with a colored formatter.

Параметры:

mute_loggers (str) – List of logger names to suppress from output

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

None

async wait_for(context, *filters)[исходный код]

Wait for the next message from user that matches given filters.

This function sets special state raito__conversation in FSM and suspends coroutine execution until user sends a message that passes all provided filters. Result is wrapped into Waiter.

Параметры:
  • context (FSMContext) – FSM context for current chat

  • filters (Callable[[...], Any]) – Sequence of aiogram filters

Результат:

Conversation result with text, parsed number and original message

Исключение:
Тип результата:

Waiter