from typing import Union
from aiogram.filters import BaseFilter
from aiogram.types import Message, CallbackQuery
import os

class IsAdmin(BaseFilter):
    async def __call__(self, event: Union[Message, CallbackQuery]) -> bool:
        admin_ids = list(map(int, os.getenv("ADMIN_IDS", "").split(",")))
        
        if isinstance(event, Message):
            return event.from_user.id in admin_ids
        elif isinstance(event, CallbackQuery):
            return event.from_user.id in admin_ids
        return False 