mirror of
https://github.com/MrSedan/neuro-reply-bot-reworked.git
synced 2026-01-14 13:39:42 +03:00
20 lines
714 B
Python
20 lines
714 B
Python
from typing import Any, Awaitable, Callable, Dict
|
|
|
|
from aiogram import BaseMiddleware
|
|
from aiogram.types import Message
|
|
|
|
from neuroapi import neuroapi
|
|
|
|
|
|
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:
|
|
await neuroapi.user.get(str(event.from_user.id), event.from_user.username)
|
|
isAdmin = await neuroapi.admin.is_admin(str(event.from_user.id))
|
|
if not isAdmin:
|
|
await event.answer('Команда только для админов!')
|
|
return None
|
|
return await handler(event, data)
|
|
|