Skip to content

Commit

Permalink
pyrofork: Add spoiler support for copy_message and send_cached_media …
Browse files Browse the repository at this point in the history
…methods #18

Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Aug 8, 2023
1 parent f8507be commit a7d6e91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pyrogram/methods/messages/send_cached_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async def send_cached_media(
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,
Expand Down Expand Up @@ -73,6 +74,9 @@ async def send_cached_media(
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.
Expand Down Expand Up @@ -107,10 +111,13 @@ async def send_cached_media(
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(),
Expand Down
6 changes: 6 additions & 0 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3271,6 +3271,7 @@ async def copy(
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,
Expand Down Expand Up @@ -3318,6 +3319,9 @@ async def copy(
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.
Expand Down Expand Up @@ -3377,6 +3381,7 @@ async def copy(
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
)
Expand Down Expand Up @@ -3464,6 +3469,7 @@ async def copy(
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,
has_spoiler=has_spoiler,
message_thread_id=message_thread_id
)
else:
Expand Down

0 comments on commit a7d6e91

Please sign in to comment.