From a39ddaf588edfa42630a76f036b5f3c9176b15e5 Mon Sep 17 00:00:00 2001 From: Nick80835 Date: Sat, 20 Jun 2020 10:13:45 -0400 Subject: [PATCH] actually good admin check this time --- ubot/command_handler.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ubot/command_handler.py b/ubot/command_handler.py index 521bfb9..07bf9f6 100644 --- a/ubot/command_handler.py +++ b/ubot/command_handler.py @@ -3,7 +3,7 @@ import asyncio from re import escape, search -from telethon import events, types +from telethon import events, functions, types from .fixes import inline_photos @@ -204,13 +204,12 @@ class CommandHandler(): return False async def is_admin(self, event): - admin_list = await event.client.get_participants(event.chat, filter=types.ChannelParticipantsAdmins) + channel_participant = await event.client(functions.channels.GetParticipantRequest(event.chat, event.from_id)) - for user in admin_list: - if user.id == event.from_id: - return True - - return False + if isinstance(channel_participant.participant, (types.ChannelParticipantAdmin, types.ChannelParticipantCreator)): + return True + else: + return False def is_blacklisted(self, event, inline=False): if inline: