首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使被删除的用户从频道(电视)?

如何使被删除的用户从频道(电视)?
EN

Stack Overflow用户
提问于 2021-12-19 10:53:05
回答 2查看 402关注 0票数 1

在电报中,当我点击订阅者时,它显示了大约50个最后的用户和大约150-200个被删除的用户。

我试过这个:

代码语言:javascript
复制
async for user in client.iter_participants(chat_id):
    if user.deleted:
        print(user)

这只给了我最后50个用户和6-8个删除用户。我需要所有150-200个被删除的用户。我怎么弄到它们?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-12-20 10:07:42

我使用带有偏移参数的GetParticipantsRequest解决了这个问题,具体如下:

代码语言:javascript
复制
from telethon.tl.functions.channels import GetParticipantsRequest
from telethon.tl.types import ChannelParticipantsSearch

chat_id = -123456

offset = 0
while True:
    participants = await client(GetParticipantsRequest(
        channel=chat_id,
        filter=ChannelParticipantsSearch(''),
        offset=offset,
        limit=10000,
        hash=0
    ))

    deleted_users = []
    for user in participants:
        if user.deleted:
            deleted_users.append(user)

    if not deleted_users:
        break

    # doings with deleted_users
票数 1
EN

Stack Overflow用户

发布于 2021-12-20 08:29:29

不确定iter_participants,但get_participants适用于我的情况。

代码语言:javascript
复制
channel_id = -1234567890 # TODO: add channel id
users = client.get_participants(client.get_input_entity(channel_id))
for user in users:
    if user.deleted:
        print(user)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70410762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档