Last active
December 9, 2021 09:02
-
-
Save sh4dowb/861934f2d0472400c6f9a764b4b7589d to your computer and use it in GitHub Desktop.
telethon get if participant is admin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from telethon.tl.types import ChannelParticipantCreator, ChannelParticipantAdmin | |
from telethon.tl.functions.channels import GetParticipantRequest | |
#.. | |
@client.on(events.NewMessage) | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 :-)