Allow specifying a threshold to handle flood waits

This commit is contained in:
Lonami Exo
2017-10-08 16:15:30 +02:00
parent 83677fc927
commit 15e90dcb69
2 changed files with 12 additions and 4 deletions

View File

@@ -534,10 +534,16 @@ class TelegramBareClient:
'[ERROR] Telegram is having some internal issues', e
)
except FloodWaitError:
sender.disconnect()
self.disconnect()
raise
except FloodWaitError as e:
if e.seconds > self.session.flood_sleep_threshold | 0:
sender.disconnect()
self.disconnect()
raise
self._logger.debug(
'Sleep of %d seconds below threshold, sleeping' % e.seconds
)
sleep(e.seconds)
# Some really basic functionality