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:
+5
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user