From 3a56c8b0f4c417b6c9429674a84c3b949ac26cc7 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Mon, 18 Nov 2019 12:51:18 +0100 Subject: [PATCH] Correctly handle flood_sleep_threshold=None and large values The docstring said large values would be converted to 1 day, but they were not. With this change None and large values are handled correctly. Prevents https://github.com/tulir/mautrix-telegram/issues/380. --- telethon/client/telegrambaseclient.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/telethon/client/telegrambaseclient.py b/telethon/client/telegrambaseclient.py index 26f17a92..b05b76a9 100644 --- a/telethon/client/telegrambaseclient.py +++ b/telethon/client/telegrambaseclient.py @@ -382,6 +382,15 @@ class TelegramBaseClient(abc.ABC): """ return self._sender.disconnected + @property + def flood_sleep_threshold(self): + return self._flood_sleep_threshold + + @flood_sleep_threshold.setter + def flood_sleep_threshold(self, value): + # None -> 0, negative values don't really matter + self._flood_sleep_threshold = min(value or 0, 24 * 60 * 60) + # endregion # region Connecting