diff --git a/bot.py b/bot.py index 1a3d2d5..0b75e33 100644 --- a/bot.py +++ b/bot.py @@ -1,10 +1,25 @@ #!/usr/bin/python -from aiogram import executor +import logging +import os + import asyncio +from aiogram import Bot, Dispatcher async def main(): - """TODO: Create and configure bot, connect to db""" + """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) + + try: + await dp.start_polling() + finally: + await dp.storage.close() + await dp.storage.wait_closed() + await bot.session.close() if __name__ == '__main__':