Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
telethon get if participant is admin
from import ChannelParticipantCreator, ChannelParticipantAdmin
from import GetParticipantRequest
async def handler(event):
participant = await client(GetParticipantRequest(channel=event.original_update.message.to_id.channel_id,user_id=event.original_update.message.from_id))
isadmin = (type(participant.participant) == ChannelParticipantAdmin)
iscreator = (type(participant.participant) == ChannelParticipantCreator)
print(isadmin, iscreator)
Copy link

jmcambot commented Dec 9, 2021

Hi, thank you very much for this code that works! It was very useful to me to detect the reliability of a user when a post is published in a group, and a bot is reading it.
There is just a mistake, probably changed since the version of your post, you need to replace user_id=... with participant=...
And of course it may be necessary to manage errors when data is not as clean as we expected :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment