Refactor bot initialization and routing logic to enforce webhook mode requirement

- Updated the bot's startup logic to require a configured WEBHOOK_BASE_URL, exiting if not set, and logging appropriate error messages.
- Simplified the decision-making process for running the AIOHTTP server, ensuring it only runs in webhook mode.
- Enhanced the router configuration to filter updates for private chats, improving message handling security.
This commit is contained in:
machka-pasla
2025-08-25 13:24:30 +03:00
parent 60c6e0e961
commit f707662125
2 changed files with 22 additions and 42 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
from aiogram import Router
from aiogram import Router, F
from bot.handlers.user import user_router_aggregate
from bot.handlers import inline_mode
@@ -10,6 +10,10 @@ from config.settings import Settings
def build_root_router(settings: Settings) -> Router:
root = Router(name="root")
# Allow all updates only in private chats (messages, callback queries, etc.)
root.message.filter(F.chat.type == "private")
root.callback_query.filter(F.message.chat.type == "private")
# Public routers
root.include_router(user_router_aggregate)
root.include_router(inline_mode.router)