From bfe6632de4a3003f84db4baf2655fb85d73671b1 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 30 Apr 2018 19:21:58 +0200 Subject: [PATCH] Fix index out of range for new messages --- pyrogram/client/client.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 7adb7297..2fb1ee55 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -860,15 +860,18 @@ class Client: ) ) - self.dispatcher.updates.put(( - types.UpdateNewMessage( - message=diff.new_messages[0], - pts=updates.pts, - pts_count=updates.pts_count - ), - diff.users, - diff.chats - )) + if diff.new_messages: + self.dispatcher.updates.put(( + types.UpdateNewMessage( + message=diff.new_messages[0], + pts=updates.pts, + pts_count=updates.pts_count + ), + diff.users, + diff.chats + )) + else: + self.dispatcher.updates.put((diff.other_updates[0], [], [])) elif isinstance(updates, types.UpdateShort): self.dispatcher.updates.put((updates.update, [], [])) except Exception as e: