19 lines
533 B
Python
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)
|