Skip to content

Instantly share code, notes, and snippets.

@yusufpapurcu
Created May 16, 2021 11:23
Show Gist options
  • Save yusufpapurcu/64f7b43af8b46ea8b00814970bc5d60b to your computer and use it in GitHub Desktop.
Save yusufpapurcu/64f7b43af8b46ea8b00814970bc5d60b to your computer and use it in GitHub Desktop.
from telethon import TelegramClient
# These example values won't work. You must get your own api_id and
# api_hash from https://my.telegram.org, under API Development.
api_id = 12345
api_hash = '0123456789abcdef0123456789abcdef'
client = TelegramClient('anon.session', api_id, api_hash) # You need run twice because this part create session in first run.
client.start()
for chat in client.iter_dialogs():
print(chat.name," --- ", chat.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment