get_dialogs()

Client.get_dialogs(limit: int = 0, exclude_pinned: bool | None = None, from_archive: bool | None = None, chat_list: int | None = None, offset_date: int | None = None, offset_message_id: int | None = None, pinned_only: bool | None = None) AsyncGenerator[Dialog, None]

Get a user’s dialogs sequentially.

Usable by Users Bots
Parameters:
  • limit (int, optional) – Limits the number of dialogs to be retrieved. By default, no limit is applied and all dialogs are returned.

  • exclude_pinned (bool, optional) – Exclude pinned dialogs.

  • from_archive (bool, optional) – Pass True to get dialogs from archive.

Returns:

Generator – A generator yielding Dialog objects.

Example

# Iterate through all dialogs
async for dialog in app.get_dialogs():
    print(dialog.chat.first_name or dialog.chat.title)

# Iterate through dialogs from archive
async for dialog in app.get_dialogs(from_archive=True):
    print(dialog.chat.first_name or dialog.chat.title)