| โฌ ๏ธ Back | ๐ Docs Root |
The Router Discovery system provides a centralized way to collect and assemble aiogram.Router instances from all installed features. This ensures that the botโs main dispatcher is automatically updated when new features are added.
Located in: src/telegram_bot/core/routers.py
collect_feature_routers()Scans the features listed in INSTALLED_FEATURES for aiogram routers.
INSTALLED_FEATURES.handlers module for that feature (e.g., src.telegram_bot.features.bot_menu.handlers).router within that module.Router is found, it is added to the collection.Router instances.build_main_router()Assembles the root router for the entire application.
main_router.collect_feature_routers() to get all feature-specific routers.main_router.common_fsm_router (shared FSM handlers).main_router.The main_router is typically included in the Dispatcher during the botโs startup:
main_router = build_main_router()
dispatcher.include_router(main_router)
For a featureโs handlers to be automatically discovered, it must:
INSTALLED_FEATURES (in core/settings.py).handlers.py (or handlers/__init__.py) file.aiogram.Router instance named router in that file.