Answer the question
In order to leave comments, you need to log in
How to get information about users of a TG channel?
I use telethon, at first I tried to use get_participants and inter_participants, but I got errors and then I saw the following code in off documentation and tried it with it
from telethon.tl.functions.channels import GetParticipantsRequest
from telethon.tl.types import ChannelParticipantsSearch
from time import sleep
offset = 0
limit = 100
all_participants = []
while True:
participants = client(GetParticipantsRequest(
channel, ChannelParticipantsSearch(''), offset, limit,
hash=0
))
if not participants.users:
break
all_participants.extend(participants.users)
offset += len(participants.users)
AttributeError: 'coroutine' object has no attribute 'users'
TypeError: 'coroutine' object is not iterable
Answer the question
In order to leave comments, you need to log in
participants in your case is a coroutine. If the result of its execution is needed, then it must be expected. If you've looked at the telethon docs, you should have noticed links to the asyncio docs.
It's done like this.
But I wouldn't use asyncio if I were you. Or read the documentation first.
participants = await client...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question