Dbu-central-bot / app /bot /loader.py
cipher-attacks's picture
fix library taps
4566c49
Raw History Blame Contribute Delete
663 Bytes
from aiogram import Dispatcher
from app.bot.handlers import build_router
from app.bot.handlers.errors import on_error
from app.bot.middlewares.context import ContextMiddleware
from app.bot.middlewares.gate import GateMiddleware
from app.bot.middlewares.throttle import ThrottleMiddleware
def build_dispatcher() -> Dispatcher:
dp = Dispatcher()
for observer in (dp.message, dp.callback_query):
observer.middleware(ThrottleMiddleware())
observer.middleware(ContextMiddleware()) # must come before the gate
observer.middleware(GateMiddleware())
dp.include_router(build_router())
dp.errors.register(on_error)
return dp