import asyncio, cfg
from typing import Any, Callable, Dict, Awaitable
from aiogram import BaseMiddleware
from aiogram.types import TelegramObject
from dbase.db import DataBase



class AdminMiddleware(BaseMiddleware):
    def __init__(self):
        pass

    async def __call__(
            self,
            handler: Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]],
            event: TelegramObject,
            data: Dict[str, Any],
    ):
        id = data['event_from_user'].id
        if str(id) in cfg.ADMIN_LIST:
            return await handler(event, data)
    
        else:
            pass
