From 2889bd5bf36a792e0de696b3f7794ba7ba16cfe5 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 3 May 2023 17:55:38 +0200 Subject: [PATCH] except and propagate TypeNotFoundError during update handling --- telethon/client/updates.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/telethon/client/updates.py b/telethon/client/updates.py index a8ad3a10b..e4ac608bc 100644 --- a/telethon/client/updates.py +++ b/telethon/client/updates.py @@ -319,6 +319,13 @@ async def _update_loop(self: 'TelegramClient'): await self.disconnect() break continue + except errors.TypeNotFoundError as e: + # User is likely doing weird things with their account or session and Telegram gets confused as to what layer they use + self._log[__name__].warning('Cannot get difference since the account is likely misusing the session: %s', e) + self._message_box.end_difference() + self._updates_error = e + await self.disconnect() + break except OSError as e: # Network is likely down, but it's unclear for how long. # If disconnect is called this task will be cancelled along with the sleep. @@ -354,6 +361,19 @@ async def _update_loop(self: 'TelegramClient'): await self.disconnect() break continue + except errors.TypeNotFoundError as e: + self._log[__name__].warning( + 'Cannot get difference since the account is likely misusing the session: %s', + get_diff.channel.channel_id, e + ) + self._message_box.end_channel_difference( + get_diff, + PrematureEndReason.TEMPORARY_SERVER_ISSUES, + self._mb_entity_cache + ) + self._updates_error = e + await self.disconnect() + break except ( errors.PersistentTimestampOutdatedError, errors.PersistentTimestampInvalidError,