BotBuilder (Factory) — Project Assembly
BotBuilder is a Builder pattern for creating Bot and Dispatcher objects with automated infrastructure configuration.
🏗 Rock-solid Core
The builder ensures that system middlewares are connected in a strict, unchangeable order:
- Database (optional) — opens transactions.
- Container — dependency injection.
- Throttling (optional) — anti-spam protection.
- Director — navigation initialization.
- User Validation — RBAC and user context.
⚡️ Auto-integration
You no longer need to manually link the Bot and Container. The build() method automatically calls container.set_bot(bot), initializing all internal services (like ViewSender).
builder = BotBuilder(bot_token=settings.bot_token)
builder.setup_core(container=container) # Integration happens here
bot, dp = builder.build()
🧩 Custom Middlewares
You can add your own layers via the CUSTOM_MIDDLEWARES list in settings.py. They will be automatically registered after the core framework ones, with full access to all services and the Director.