From 8753df27ed53ecf17ac9d634fcfe70daa2778a00 Mon Sep 17 00:00:00 2001 From: Belegnar Date: Fri, 10 Mar 2017 14:14:51 +0300 Subject: [PATCH] * reconnect in TelegramClient.connect() forces reconnect only if client was connected --- telethon/telegram_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 68ca06d0..510c8a8c 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -90,7 +90,7 @@ class TelegramClient: Note that authenticating to the Telegram servers is not the same as authenticating the app, which requires to send a code first.""" try: - if not self.session.auth_key or reconnect: + if not self.session.auth_key or (reconnect and self.sender is not None): self.session.auth_key, self.session.time_offset = \ authenticator.do_authentication(self.transport) @@ -146,6 +146,7 @@ class TelegramClient: """Disconnects from the Telegram server **and pauses all the spawned threads**""" if self.sender: self.sender.disconnect() + self.sender = None # endregion