Notion_Bot/app/middlewares/admin_middleware.py
2024-04-27 21:42:08 +04:00

19 lines
533 B
Python

from typing import Callable, Dict, Any, Awaitable
from aiogram import BaseMiddleware
from aiogram.types import TelegramObject, User
from app.settings import secrets
class AdminMiddleware(BaseMiddleware):
async def __call__(
self,
handler: Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]],
event: TelegramObject,
data: Dict[str, Any],
) -> Any:
user: User = data.get("event_from_user")
if user.id == secrets.admin_id:
return await handler(event, data)