pyrofork: Add spoiler support for copy_message and send_cached_media methods #18

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-08-08 20:30:42 +07:00
parent f44c80c1a2
commit 4cf50e6e04
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
2 changed files with 14 additions and 1 deletions

View file

@ -34,6 +34,7 @@ class SendCachedMedia:
caption: str = "",
parse_mode: Optional["enums.ParseMode"] = None,
caption_entities: List["types.MessageEntity"] = None,
has_spoiler: bool = None,
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
@ -74,6 +75,9 @@ class SendCachedMedia:
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
has_spoiler (``bool``, *optional*):
Pass True if the photo needs to be covered with a spoiler animation.
disable_notification (``bool``, *optional*):
Sends the message silently.
Users will receive a notification with no sound.
@ -108,10 +112,13 @@ class SendCachedMedia:
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
media = utils.get_input_media_from_file_id(file_id)
media.spoiler = has_spoiler
r = await self.invoke(
raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id),
media=utils.get_input_media_from_file_id(file_id),
media=media,
silent=disable_notification or None,
reply_to=reply_to,
random_id=self.rnd_id(),

View file

@ -3262,6 +3262,7 @@ class Message(Object, Update):
caption: str = None,
parse_mode: Optional["enums.ParseMode"] = None,
caption_entities: List["types.MessageEntity"] = None,
has_spoiler: bool = None,
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
@ -3309,6 +3310,9 @@ class Message(Object, Update):
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
List of special entities that appear in the new caption, which can be specified instead of *parse_mode*.
has_spoiler (``bool``, *optional*):
Pass True if the photo needs to be covered with a spoiler animation.
disable_notification (``bool``, *optional*):
Sends the message silently.
Users will receive a notification with no sound.
@ -3368,6 +3372,7 @@ class Message(Object, Update):
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
schedule_date=schedule_date,
has_spoiler=has_spoiler,
protect_content=protect_content,
reply_markup=self.reply_markup if reply_markup is object else reply_markup
)
@ -3455,6 +3460,7 @@ class Message(Object, Update):
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,
has_spoiler=has_spoiler,
message_thread_id=message_thread_id
)
else: