1

有了telethon你,你几乎可以在 Telegram 周围做任何你想做的事情。但是,我找不到获取组/频道中已删除(禁止)用户列表的方法。有任何想法吗?

作为记录,您可以通过 Telegram 的 GUI 转到Edit > Permissions > Removed Users.

4

2 回答 2

2

为了使用 Telethon 获取 Telegram 组/频道中所有已删除用户的列表,您需要将get_participants()参数filter设置为ChannelParticipantsKicked.

from telethon.tl.types import ChannelParticipantsKicked # import type to use as filter
kicked_members = await client.get_participants(chat, filter=ChannelParticipantsKicked)

如果您希望循环遍历结果而不将其分配给您可以使用的变量iter_participants()

from telethon.tl.types import ChannelParticipantsKicked 
async for user in client.iter_participants(chat, filter=ChannelParticipantsKicked):
    print(user.first_name)

NR:这里列出了所有filters可用的get/iter_participants().

于 2021-03-12T15:27:49.770 回答
0

@client.on(events.NewMessage(pattern="/[Bb]anlist",from_users=admin)) async def banlist(event): text = (event.raw_text).split(" ") try: bans = await client .get_participants(text[1] , filter=ChannelParticipantsKicked) ban_list = "" for i in bans: if (i.username != None): ban_list += "@" + i.username +'\n' await event.reply ("BAN LSIT: {}".format(ban_list)) 除外:await event.reply("ERROR!")

于 2021-07-07T10:41:54.507 回答