diff --git a/pyrogram/methods/messages/send_photo.py b/pyrogram/methods/messages/send_photo.py index cb9f477b..6c6296b3 100644 --- a/pyrogram/methods/messages/send_photo.py +++ b/pyrogram/methods/messages/send_photo.py @@ -51,6 +51,7 @@ class SendPhoto: schedule_date: datetime = None, protect_content: bool = None, message_effect_id: int = None, + view_once: bool = None, reply_markup: Union[ "types.InlineKeyboardMarkup", "types.ReplyKeyboardMarkup", @@ -136,6 +137,10 @@ class SendPhoto: message_effect_id (``int`` ``64-bit``, *optional*): Unique identifier of the message effect to be added to the message; for private chats only. + view_once (``bool``, *optional*): + Self-Destruct Timer. + If True, the photo will self-destruct after it was viewed. + reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*): Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. @@ -201,23 +206,23 @@ class SendPhoto: file = await self.save_file(photo, progress=progress, progress_args=progress_args) media = raw.types.InputMediaUploadedPhoto( file=file, - ttl_seconds=ttl_seconds, + ttl_seconds=(1 << 31) - 1 if view_once else ttl_seconds, spoiler=has_spoiler, ) elif re.match("^https?://", photo): media = raw.types.InputMediaPhotoExternal( url=photo, - ttl_seconds=ttl_seconds, + ttl_seconds=(1 << 31) - 1 if view_once else ttl_seconds, spoiler=has_spoiler ) else: - media = utils.get_input_media_from_file_id(photo, FileType.PHOTO, ttl_seconds=ttl_seconds) + media = utils.get_input_media_from_file_id(photo, FileType.PHOTO, ttl_seconds=(1 << 31) - 1 if view_once else ttl_seconds) media.spoiler = has_spoiler else: file = await self.save_file(photo, progress=progress, progress_args=progress_args) media = raw.types.InputMediaUploadedPhoto( file=file, - ttl_seconds=ttl_seconds, + ttl_seconds=(1 << 31) - 1 if view_once else ttl_seconds, spoiler=has_spoiler ) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index b1b3439d..7b3f1600 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -2663,6 +2663,7 @@ class Message(Object, Update): reply_in_chat_id: Union[int, str] = None, quote_text: str = None, quote_entities: List["types.MessageEntity"] = None, + view_once: bool = None, reply_markup: Union[ "types.InlineKeyboardMarkup", "types.ReplyKeyboardMarkup", @@ -2725,6 +2726,10 @@ class Message(Object, Update): reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + view_once (``bool``, *optional*): + Self-Destruct Timer. + If True, the photo will self-destruct after it was viewed. + business_connection_id (``str``, *optional*): Business connection identifier. for business bots only. @@ -2809,6 +2814,7 @@ class Message(Object, Update): reply_to_chat_id=reply_to_chat_id, quote_text=quote_text, quote_entities=quote_entities, + view_once=view_once, reply_markup=reply_markup, progress=progress, progress_args=progress_args diff --git a/pyrogram/types/messages_and_media/story.py b/pyrogram/types/messages_and_media/story.py index 785d6e62..a58e734a 100644 --- a/pyrogram/types/messages_and_media/story.py +++ b/pyrogram/types/messages_and_media/story.py @@ -823,6 +823,7 @@ class Story(Object, Update): caption_entities: List["types.MessageEntity"] = None, has_spoiler: bool = None, ttl_seconds: int = None, + view_once: bool = None, disable_notification: bool = None, reply_to_story_id: int = None, reply_markup: Union[ @@ -876,6 +877,10 @@ class Story(Object, Update): If you set a timer, the photo will self-destruct in *ttl_seconds* seconds after it was viewed. + view_once (``bool``, *optional*): + Self-Destruct Timer. + If True, the photo will self-destruct after it was viewed. + disable_notification (``bool``, *optional*): Sends the message silently. Users will receive a notification with no sound. @@ -928,6 +933,7 @@ class Story(Object, Update): caption_entities=caption_entities, has_spoiler=has_spoiler, ttl_seconds=ttl_seconds, + view_once=view_once, disable_notification=disable_notification, reply_to_story_id=reply_to_story_id, reply_markup=reply_markup,