import asyncio from aiogram import Dispatcher from aiogram.filters import Command from app.handlers.events import start_bot, stop_bot from app.handlers.message import parse_message from app.handlers.simple import start_command from app.middlewares.admin_middleware import AdminMiddleware from app.middlewares.album_middleware import MediaGroupMiddleware from app.settings import bot async def start(): dp = Dispatcher() dp.update.middleware(AdminMiddleware()) dp.message.middleware(MediaGroupMiddleware()) dp.startup.register(start_bot) dp.shutdown.register(stop_bot) dp.message.register(start_command, Command(commands="start")) dp.message.register(parse_message) try: await dp.start_polling(bot) finally: await bot.session.close() if __name__ == "__main__": asyncio.run(start())