Connection checks

Instead of rasing an exception when running client.start() without an active internet connection, Telethon will handle it itself, advising the user to check his internet connection. The connection will be tried in a loop, until the connection is established, breaking the loop.
This commit is contained in:
ferferga 2018-04-10 20:56:35 +02:00 committed by GitHub
parent bd1b0ecdb4
commit ed091422b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -297,7 +297,14 @@ class TelegramClient(TelegramBareClient):
'must only provide one of either')
if not self.is_connected():
self.connect()
connected = self.connect()
while connected is not True:
print("Couldn't establish a connection to Telegram's servers. Check your connection. Trying again...")
connected2 = self.connect()
if connected2 is True:
break
else:
continue
if self.is_user_authorized():
self._check_events_pending_resolve()