diff --git a/pyrogram/methods/chats/update_chat_notifications.py b/pyrogram/methods/chats/update_chat_notifications.py index c7905e15..355df421 100644 --- a/pyrogram/methods/chats/update_chat_notifications.py +++ b/pyrogram/methods/chats/update_chat_notifications.py @@ -29,7 +29,7 @@ class UpdateChatNotifications: self: "pyrogram.Client", chat_id: Union[int, str], mute: bool = None, - mute_until: datetime = utils.zero_datetime(), + mute_until: datetime = None, stories_muted: bool = None, stories_hide_sender: bool = None, show_previews: bool = None @@ -44,7 +44,7 @@ class UpdateChatNotifications: Pass True if you want to mute chat. until_date (:py:obj:`~datetime.datetime`, *optional*): - Date when the user will be unmuted. Defaults to epoch (mute forever). + Date when the user will be unmuted. Works only if the mute parameter is set to True. Defaults to forever. stories_muted (``bool``, *optional*): N/A @@ -74,6 +74,9 @@ class UpdateChatNotifications: # Unmute a chat app.update_chat_notifications(chat_id, mute=False) """ + if not mute_until: + mute_until = utils.max_datetime() if mute else utils.zero_datetime() + if isinstance(mute_until, datetime.timedelta): mute_until = datetime.datetime.now() + mute_until diff --git a/pyrogram/utils.py b/pyrogram/utils.py index fdf57fcf..7ecb1e97 100644 --- a/pyrogram/utils.py +++ b/pyrogram/utils.py @@ -461,6 +461,10 @@ def zero_datetime() -> datetime: return datetime.fromtimestamp(0, timezone.utc) +def max_datetime() -> datetime: + return datetime.fromtimestamp((1 << 31) - 1, timezone.utc) + + def timestamp_to_datetime(ts: Optional[int]) -> Optional[datetime]: return datetime.fromtimestamp(ts) if ts else None