Getting all personal chat id in Telethon

Viewed 252

this is the code that currently I use.

from telethon.sync import TelegramClient
from telethon import functions, types

api_id = 'xxxx'
api_hash = 'xxxx'
phone_number = 'xxx'

with TelegramClient('session_name', api_id, api_hash) as client:
    all_chats = client(functions.messages.GetAllChatsRequest(except_ids = []))
    for _, chat in enumerate(all_chats.chats):
        print(chat.title)

Its only extract the group and channel. I would like to know how I can extract my personal chats.

1 Answers
Related