iter_dialogs()

Client.iter_dialogs()

Iterate through a user’s dialogs sequentially.

This convenience method does the same as repeatedly calling get_dialogs() in a loop, thus saving you from the hassle of setting up boilerplate code. It is useful for getting the whole dialogs list with a single call.

Parameters
  • offset_date (int) – The offset date in Unix time taken from the top message of a Dialog. Defaults to 0 (most recent dialog).

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

Returns

Generator – A generator yielding Dialog objects.

Example

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