Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Using Python 3 is very simple:
from time import sleep
from telethon import TelegramClient
from telethon.tl.functions.channels import GetParticipantsRequest
from telethon.tl.types import ChannelParticipantsSearch
api_id = <app_id>
api_hash = '<app_hash>'
phone = '+88005553535'
group_link = 't.me/joinchat/<group_hash>'
client = TelegramClient('session_name', api_id, api_hash)
client.connect()
channel = client.get_entity(group_link)
if not client.is_user_authorized():
client.send_code_request(phone)
client.sign_in(phone, input('Please Enter the verification code: '))
def get_users(a_channel):
offset = 0
limit = 100
all_participants = []
while True:
participants = client.invoke(GetParticipantsRequest(
a_channel, ChannelParticipantsSearch(''), offset, limit, hash=0
))
if not participants.users:
break
all_participants.extend(participants.users)
offset += len(participants.users)
sleep(1)
return all_participants
def print_users(a_users):
for user in a_users:
print(user.username)
print_users(get_users(channel))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question