| ⬅️ Back | 🏠 Docs Root |
The Bot Factory is responsible for creating and configuring the core aiogram components: the Bot and the Dispatcher. It also handles the initialization of the internationalization (i18n) system.
Located in: src/telegram_bot/core/factory.py
compile_locales(base_path: pathlib.Path) -> strThis helper function prepares the localization files for the aiogram-i18n engine.
/tmp/bot_locales/.ru, de) in src/telegram_bot/resources/locales/..ftl (Fluent) files within each language folder.messages.ftl file per language in the temporary directory.FluentRuntimeCore to have a single entry point per locale. It also ensures compatibility with Docker environments by using /tmp.build_bot(settings: BotSettings, redis_client: Redis) -> tuple[Bot, Dispatcher]The main entry point for bot initialization.
BOT_TOKEN is present in the settings. Raises a RuntimeError if missing.aiogram.Bot instance with HTML as the default parse mode.ping on the provided Redis client to ensure the bot can store FSM states and handle caching.RedisStorage using the verified Redis client.compile_locales to prepare translation files.I18nMiddleware using FluentRuntimeCore.FSMContextI18nManager to manage user locales via FSM.de).Dispatcher.aiogram.Dispatcher instance, injecting the Redis storage and bot settings.settings = BotSettings()
redis = Redis.from_url(settings.redis_url)
bot, dp = await build_bot(settings, redis)