heavenbean / RnD

0 stars 0 forks source link

Get list of user in telegram group #5

Open heavenbean opened 3 years ago

heavenbean commented 3 years ago

Create an App and get App ID, App Hash

from telethon import TelegramClient, sync

api_id = 'APP_ID'
api_hash = 'APP_HASH'

client = TelegramClient('+84_YOUR_PHONE', api_id, api_hash).start()

# get all the channels that I can access
channels = {d.entity.username: d.entity
            for d in client.get_dialogs()
            if d.is_channel}

print(channels)
# choose the one that I want to list users from
channel = channels['YOUR_GROUP_NAME']

# get all the users and print them
for u in client.get_participants(channel):
    print(u.id, u.first_name, u.last_name, u.username)