hyperboria/nexus/bot/handlers/admin.py
the-superpirate 681817ceae No description
GitOrigin-RevId: 83514338be1d662518bab9fe5ab6eefef98f229f
2021-04-09 13:29:10 +03:00

23 lines
704 B
Python

from abc import ABC
from library.telegram.base import RequestContext
from nexus.bot.widgets.admin_widget import AdminWidget
from telethon import events
from .base import BaseHandler
class BaseAdminHandler(BaseHandler, ABC):
def _has_access(self, chat):
return chat.is_admin
class AdminHandler(BaseAdminHandler):
filter = events.NewMessage(incoming=True, pattern='^/admin$')
async def handler(self, event, request_context: RequestContext):
request_context.statbox(action='show', mode='admin')
admin_widget_view = AdminWidget(application=self.application, chat=request_context.chat)
text = await admin_widget_view.render()
await event.reply(text)