From 55d0b93cf079aa4622375b5d4e954ce6f89577e4 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 8 Jul 2020 17:16:06 +0200 Subject: [PATCH] Extend set_slow_mode to accept None --- pyrogram/client/methods/chats/set_slow_mode.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pyrogram/client/methods/chats/set_slow_mode.py b/pyrogram/client/methods/chats/set_slow_mode.py index cf6c7096..8215c3b9 100644 --- a/pyrogram/client/methods/chats/set_slow_mode.py +++ b/pyrogram/client/methods/chats/set_slow_mode.py @@ -26,7 +26,7 @@ class SetSlowMode(BaseClient): def set_slow_mode( self, chat_id: Union[int, str], - seconds: int, + seconds: Union[int, None] ) -> bool: """Set the slow mode interval for a chat. @@ -34,9 +34,9 @@ class SetSlowMode(BaseClient): chat_id (``int`` | ``str``): Unique identifier (int) or username (str) of the target chat. - seconds (``int`` | ``str``): + seconds (``int`` | ``None``): Seconds in which members will be able to send only one message per this interval. - Valid values are: 0 (off), 10, 30, 60 (1m), 300 (5m), 900 (15m) or 3600 (1h). + Valid values are: 0 or None (off), 10, 30, 60 (1m), 300 (5m), 900 (15m) or 3600 (1h). Returns: ``bool``: True on success. @@ -44,13 +44,17 @@ class SetSlowMode(BaseClient): Example: .. code-block:: python + # Set slow mode to 60 seconds app.set_slow_mode("pyrogramchat", 60) + + # Disable slow mode + app.set_slow_mode("pyrogramchat", None) """ self.send( functions.channels.ToggleSlowMode( channel=self.resolve_peer(chat_id), - seconds=seconds + seconds=0 if seconds is None else seconds ) )