Files
neuro-reply-bot-reworked/handlers/middlewares/user.py
2023-10-28 16:31:26 +03:00

17 lines
584 B
Python

from typing import Any, Awaitable, Callable, Dict
from aiogram import BaseMiddleware
from aiogram.types import Message
ADMIN_LIST = [248770879, 395543883]
class AdminMiddleware(BaseMiddleware):
def __init__(self) -> None:
pass
async def __call__(self, handler: Callable[[Message, Dict[str, Any]], Awaitable[Any]], event: Message, data: Dict[str, Any]) -> Any:
if event.from_user.id in ADMIN_LIST:
await event.answer('Команда только для админов!')
return None
return await handler(event, data)