From 1d3273a3065744f9ee6162f305c633b2e35416cc Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 19 Sep 2017 13:17:40 +0200 Subject: [PATCH] Fix UpdateState calling handlers with updates with lower pts --- telethon/update_state.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/telethon/update_state.py b/telethon/update_state.py index 2f313dea..8c160184 100644 --- a/telethon/update_state.py +++ b/telethon/update_state.py @@ -75,12 +75,16 @@ class UpdateState: with self._updates_lock: if isinstance(update, tl.updates.State): self._state = update - elif not hasattr(update, 'pts') or update.pts > self._state.pts: - self._state.pts = getattr(update, 'pts', self._state.pts) + return # Nothing else to be done - if self._polling: - self._updates.append(update) - self._updates_available.set() + pts = getattr(update, 'pts', self._state.pts) + if pts <= self._state.pts: + return # We already handled this update + + self._state.pts = pts + if self._polling: + self._updates.append(update) + self._updates_available.set() for handler in self.handlers: handler(update)