With telethon
you can do pretty much anything you want around Telegram. However, I cannot find a way to get a list of removed (banned) users in a group/channel. Any ideas?
For the record, you can do that via Telegram's GUI by going to Edit > Permissions > Removed Users
.
In order to get a list of all the removed users in a Telegram group/channel using Telethon you need to use get_participants()
with filter
parameter set to ChannelParticipantsKicked
.
from telethon.tl.types import ChannelParticipantsKicked # import type to use as filter
kicked_members = await client.get_participants(chat, filter=ChannelParticipantsKicked)
If you'd prefer to loop over the result without assign it to a variable you can use iter_participants()
instead.
from telethon.tl.types import ChannelParticipantsKicked
async for user in client.iter_participants(chat, filter=ChannelParticipantsKicked):
print(user.first_name)
NR: here is a list of all the avaible filters
usable with get/iter_participants()
.