from asyncio import run from aiogram import Bot, Dispatcher from core.utils.registry import registry from core.utils.settings import settings async def start(bot: Bot, dp: Dispatcher): try: await dp.start_polling(bot) finally: await bot.session.close() # close db connection here def main(): bot = Bot(token=settings.app.telegram_token) dp = Dispatcher() registry(dp) run(start(bot, dp)) if __name__ == "__main__": main()