From 50d413b1c93119635b8e27efc8b77a8f9683438a Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 28 Dec 2017 14:55:02 +0100 Subject: [PATCH] Fix slicing dialogs was turning UserList into list --- telethon/telegram_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 3b17e4c2..72f9f98b 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -341,9 +341,11 @@ class TelegramClient(TelegramBareClient): offset_peer = entities[utils.get_peer_id(r.dialogs[-1].peer)] offset_id = r.messages[-1].id & 4294967296 # Telegram/danog magic - dialogs = UserList(dialogs.values()) + dialogs = UserList( + itertools.islice(dialogs.values(), min(limit, len(dialogs))) + ) dialogs.total = total_count - return dialogs[:limit] if limit < float('inf') else dialogs + return dialogs def get_drafts(self): # TODO: Ability to provide a `filter` """