31 lines
644 B
Python
31 lines
644 B
Python
#!/usr/bin/python
|
|
import logging
|
|
import os
|
|
import asyncio
|
|
|
|
from aiogram import Bot, Dispatcher
|
|
from handlers.commands import register_command_handlers
|
|
|
|
|
|
async def main():
|
|
"""Configures and runs the bot, connects to the db"""
|
|
logging.basicConfig(level=logging.INFO)
|
|
API_TOKEN = os.getenv("API_TOKEN")
|
|
|
|
bot = Bot(API_TOKEN)
|
|
dp = Dispatcher(bot)
|
|
|
|
# Register handlers
|
|
register_command_handlers(dp)
|
|
|
|
try:
|
|
await dp.start_polling()
|
|
finally:
|
|
await dp.storage.close()
|
|
bot_session = await bot.get_session()
|
|
await bot_session.close()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main())
|