pyrofork: Add view_once parameter to send_photo

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
KurimuzonAkuma 2024-05-19 16:30:21 +03:00 committed by wulan17
parent 40b679a878
commit ed6403db3c
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
3 changed files with 21 additions and 4 deletions

View file

@ -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
)

View file

@ -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

View file

@ -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,