import logging
from aiogram import Bot, Dispatcher, executor
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from config import load_config
from database import setup_database
from middlewares.logging import LoggingMiddleware
from handlers import start, admin, polls

logging.basicConfig(level=logging.INFO)

config = load_config()
bot = Bot(token=config['BOT_TOKEN'])
dp = Dispatcher(bot, storage=MemoryStorage())

dp.middleware.setup(LoggingMiddleware())

start.register_handlers(dp)
admin.register_handlers(dp)
polls.register_handlers(dp)

setup_database()

if __name__ == '__main__':
    executor.start_polling(dp, skip_updates=True)
