mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Add view_once parameter to send_photo
This commit is contained in:
parent
cdcd805cb5
commit
cee41a0531
@ -49,6 +49,7 @@ class SendPhoto:
|
||||
quote_offset: int = None,
|
||||
schedule_date: datetime = None,
|
||||
protect_content: bool = None,
|
||||
view_once: bool = None,
|
||||
business_connection_id: str = None,
|
||||
reply_markup: Union[
|
||||
"types.InlineKeyboardMarkup",
|
||||
@ -126,6 +127,10 @@ class SendPhoto:
|
||||
protect_content (``bool``, *optional*):
|
||||
Protects the contents of the sent message from forwarding and saving.
|
||||
|
||||
view_once (``bool``, *optional*):
|
||||
Self-Destruct Timer.
|
||||
If True, the photo will self-destruct after it was viewed.
|
||||
|
||||
business_connection_id (``str``, *optional*):
|
||||
Unique identifier of the business connection on behalf of which the message will be sent.
|
||||
|
||||
@ -182,22 +187,22 @@ 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, has_spoiler=has_spoiler)
|
||||
media = utils.get_input_media_from_file_id(photo, FileType.PHOTO, ttl_seconds=(1 << 31) - 1 if view_once else ttl_seconds, has_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
|
||||
)
|
||||
|
||||
|
@ -2521,6 +2521,7 @@ class Message(Object, Update):
|
||||
reply_to_message_id: int = None,
|
||||
quote_text: str = None,
|
||||
quote_entities: List["types.MessageEntity"] = None,
|
||||
view_once: bool = None,
|
||||
business_connection_id: str = None,
|
||||
reply_markup: Union[
|
||||
"types.InlineKeyboardMarkup",
|
||||
@ -2594,6 +2595,10 @@ class Message(Object, Update):
|
||||
quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
||||
List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
|
||||
|
||||
view_once (``bool``, *optional*):
|
||||
Self-Destruct Timer.
|
||||
If True, the photo will self-destruct after it was viewed.
|
||||
|
||||
business_connection_id (``str``, *optional*):
|
||||
Unique identifier of the business connection on behalf of which the message will be sent.
|
||||
|
||||
@ -2656,6 +2661,7 @@ class Message(Object, Update):
|
||||
reply_to_message_id=reply_to_message_id,
|
||||
quote_text=quote_text,
|
||||
quote_entities=quote_entities,
|
||||
view_once=view_once,
|
||||
business_connection_id=business_connection_id,
|
||||
reply_markup=reply_markup,
|
||||
progress=progress,
|
||||
|
@ -828,6 +828,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_markup: Union[
|
||||
"types.InlineKeyboardMarkup",
|
||||
@ -880,6 +881,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.
|
||||
@ -926,6 +931,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=self.id,
|
||||
reply_markup=reply_markup,
|
||||
|
Loading…
Reference in New Issue
Block a user