diff --git a/telethon/client/updates.py b/telethon/client/updates.py index 00f43e38..a9d5c9aa 100644 --- a/telethon/client/updates.py +++ b/telethon/client/updates.py @@ -295,7 +295,10 @@ class UpdateMethods(UserMethods): # We could add a lock to not fetch the same pts twice if we are # already fetching it. However this does not happen in practice, # which makes sense, because different updates have different pts. - await self._get_difference(update, channel_id, pts_date) + if self._state_cache.update(update, check_only=True): + # If the update doesn't have pts, fetching won't do anything. + # For example, UpdateUserStatus or UpdateChatUserTyping. + await self._get_difference(update, channel_id, pts_date) built = EventBuilderDict(self, update) if self._conversations: diff --git a/telethon/statecache.py b/telethon/statecache.py index ea3214ba..6125d101 100644 --- a/telethon/statecache.py +++ b/telethon/statecache.py @@ -87,12 +87,16 @@ class StateCache: types.updates.ChannelDifferenceEmpty, types.updates.ChannelDifferenceTooLong, types.updates.ChannelDifference - )) + )), + check_only=False ): """ Update the state with the given update. """ cid = update.CONSTRUCTOR_ID + if check_only: + return cid in has_pts or cid in has_date or cid in has_channel_pts + if cid in has_pts: if cid in has_date: self._pts_date = update.pts, update.date