restrict moderator access

This commit is contained in:
Capybara-z
2026-02-10 01:51:37 +03:00
parent 355f210b8c
commit 0aa4cf0996
4 changed files with 59 additions and 40 deletions
+19
View File
@@ -17,3 +17,22 @@ class IsAdminFilter(BaseFilter):
return result.scalar()
except (Exception,):
return False
class IsSuperAdminFilter(BaseFilter):
async def __call__(self, event: Message | CallbackQuery) -> bool:
if not event.from_user:
return False
try:
async with async_session_maker() as session:
admin = (
await session.execute(
select(Admin).where(Admin.tg_id == event.from_user.id)
)
).scalar_one_or_none()
if not admin:
return False
return admin.role != "moderator"
except (Exception,):
return False