From 8ecd2c2e060db034900a18e434fa89a3e3334821 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 30 Sep 2017 16:11:16 +0200 Subject: [PATCH] Call .sync_updates on .connect iff exported_auth is None Calling this method on exported clients would trigger a UserMigrateError because it was being used on a non-native data center. For .connects like this, don't attempt syncing updates. --- telethon/telegram_bare_client.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/telethon/telegram_bare_client.py b/telethon/telegram_bare_client.py index 4355be3c..cf26c465 100644 --- a/telethon/telegram_bare_client.py +++ b/telethon/telegram_bare_client.py @@ -201,13 +201,16 @@ class TelegramBareClient: self(GetConfigRequest()).dc_options # Connection was successful! Try syncing the update state + # IF we don't have an exported authorization (hence we're + # not in our NATIVE data center or we'd get UserMigrateError) # to also assert whether the user is logged in or not. self._user_connected = True - try: - self.sync_updates() - self._set_connected_and_authorized() - except UnauthorizedError: - self._authorized = False + if not exported_auth: + try: + self.sync_updates() + self._set_connected_and_authorized() + except UnauthorizedError: + self._authorized = False return True