async def main():
config = load_config('config/.env')
storage = MemoryStorage()
bot = Bot(token=config.bot.token, parse_mode=config.bot.parse_mode)
dp = Dispatcher(bot, storage=storage)
register_all_middlewares(dp, data=config.data)
register_all_handlers(dp)
bot.config = config
try:
print(f"Bot {config.bot.name} {config.bot.version} started!")
await asyncio.gather(
dp.start_polling(),
update(bot)
)
finally:
await bot.session.close()
if name == 'main':
try:
asyncio.run(main())
except (KeyboardInterrupt, SystemExit):
print(f'Bot stopped!')