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
limit (
int, optional) – Limits the number of dialogs to be retrieved. By default, no limit is applied and all dialogs are returned.offset_date (
int) – The offset date in Unix time taken from the top message of aDialog. Defaults to 0 (most recent dialog).
- Returns
Generator– A generator yieldingDialogobjects.
Example
# Iterate through all dialogs for dialog in app.iter_dialogs(): print(dialog.chat.first_name or dialog.chat.title)