diff --git a/pyrogram/methods/messages/edit_message_media.py b/pyrogram/methods/messages/edit_message_media.py index 17625115..bd8ba606 100644 --- a/pyrogram/methods/messages/edit_message_media.py +++ b/pyrogram/methods/messages/edit_message_media.py @@ -80,6 +80,11 @@ class EditMessageMedia(Scaffold): caption = media.caption parse_mode = media.parse_mode + message, entities = None, None + + if caption is not None: + message, entities = (await self.parser.parse(caption, parse_mode)).values() + if isinstance(media, types.InputMediaPhoto): if os.path.isfile(media.media): media = await self.send( @@ -253,7 +258,8 @@ class EditMessageMedia(Scaffold): id=message_id, media=media, reply_markup=reply_markup.write() if reply_markup else None, - **await self.parser.parse(caption, parse_mode) + message=message, + entities=entities ) ) diff --git a/pyrogram/methods/messages/send_media_group.py b/pyrogram/methods/messages/send_media_group.py index d591c99b..eb1660ec 100644 --- a/pyrogram/methods/messages/send_media_group.py +++ b/pyrogram/methods/messages/send_media_group.py @@ -265,7 +265,7 @@ class SendMediaGroup(Scaffold): raw.types.InputSingleMedia( media=media, random_id=self.rnd_id(), - **await self.parser.parse(i.caption, i.parse_mode) + **await self.parser.parse(i.caption or "", i.parse_mode) ) ) diff --git a/pyrogram/types/input_media/input_media_animation.py b/pyrogram/types/input_media/input_media_animation.py index 82e75919..a209b80d 100644 --- a/pyrogram/types/input_media/input_media_animation.py +++ b/pyrogram/types/input_media/input_media_animation.py @@ -38,7 +38,8 @@ class InputMediaAnimation(InputMedia): Thumbnails can't be reused and can be only uploaded as a new file. caption (``str``, *optional*): - Caption of the animation to be sent, 0-1024 characters + Caption of the animation to be sent, 0-1024 characters. + If not specified, the original caption is kept. Pass "" (empty string) to remove the caption. parse_mode (``str``, *optional*): By default, texts are parsed using both Markdown and HTML styles. @@ -64,7 +65,7 @@ class InputMediaAnimation(InputMedia): self, media: str, thumb: str = None, - caption: str = "", + caption: str = None, parse_mode: Optional[str] = object, caption_entities: List[MessageEntity] = None, width: int = 0, diff --git a/pyrogram/types/input_media/input_media_audio.py b/pyrogram/types/input_media/input_media_audio.py index ff7bd085..e98d283c 100644 --- a/pyrogram/types/input_media/input_media_audio.py +++ b/pyrogram/types/input_media/input_media_audio.py @@ -40,7 +40,8 @@ class InputMediaAudio(InputMedia): Thumbnails can't be reused and can be only uploaded as a new file. caption (``str``, *optional*): - Caption of the audio to be sent, 0-1024 characters + Caption of the audio to be sent, 0-1024 characters. + If not specified, the original caption is kept. Pass "" (empty string) to remove the caption. parse_mode (``str``, *optional*): By default, texts are parsed using both Markdown and HTML styles. @@ -66,7 +67,7 @@ class InputMediaAudio(InputMedia): self, media: str, thumb: str = None, - caption: str = "", + caption: str = None, parse_mode: Optional[str] = object, caption_entities: List[MessageEntity] = None, duration: int = 0, diff --git a/pyrogram/types/input_media/input_media_document.py b/pyrogram/types/input_media/input_media_document.py index b1d6b4a1..2701c0ae 100644 --- a/pyrogram/types/input_media/input_media_document.py +++ b/pyrogram/types/input_media/input_media_document.py @@ -38,7 +38,8 @@ class InputMediaDocument(InputMedia): Thumbnails can't be reused and can be only uploaded as a new file. caption (``str``, *optional*): - Caption of the document to be sent, 0-1024 characters + Caption of the document to be sent, 0-1024 characters. + If not specified, the original caption is kept. Pass "" (empty string) to remove the caption. parse_mode (``str``, *optional*): By default, texts are parsed using both Markdown and HTML styles. @@ -55,7 +56,7 @@ class InputMediaDocument(InputMedia): self, media: str, thumb: str = None, - caption: str = "", + caption: str = None, parse_mode: Optional[str] = object, caption_entities: List[MessageEntity] = None ): diff --git a/pyrogram/types/input_media/input_media_photo.py b/pyrogram/types/input_media/input_media_photo.py index d675ad19..ac1cc444 100644 --- a/pyrogram/types/input_media/input_media_photo.py +++ b/pyrogram/types/input_media/input_media_photo.py @@ -34,7 +34,8 @@ class InputMediaPhoto(InputMedia): Sending photo by a URL is currently unsupported. caption (``str``, *optional*): - Caption of the photo to be sent, 0-1024 characters + Caption of the photo to be sent, 0-1024 characters. + If not specified, the original caption is kept. Pass "" (empty string) to remove the caption. parse_mode (``str``, *optional*): By default, texts are parsed using both Markdown and HTML styles. @@ -50,7 +51,7 @@ class InputMediaPhoto(InputMedia): def __init__( self, media: str, - caption: str = "", + caption: str = None, parse_mode: Optional[str] = object, caption_entities: List[MessageEntity] = None ): diff --git a/pyrogram/types/input_media/input_media_video.py b/pyrogram/types/input_media/input_media_video.py index aef5edf1..13ce18d6 100644 --- a/pyrogram/types/input_media/input_media_video.py +++ b/pyrogram/types/input_media/input_media_video.py @@ -40,7 +40,8 @@ class InputMediaVideo(InputMedia): Thumbnails can't be reused and can be only uploaded as a new file. caption (``str``, *optional*): - Caption of the video to be sent, 0-1024 characters + Caption of the video to be sent, 0-1024 characters. + If not specified, the original caption is kept. Pass "" (empty string) to remove the caption. parse_mode (``str``, *optional*): By default, texts are parsed using both Markdown and HTML styles. @@ -69,7 +70,7 @@ class InputMediaVideo(InputMedia): self, media: str, thumb: str = None, - caption: str = "", + caption: str = None, parse_mode: Optional[str] = object, caption_entities: List[MessageEntity] = None, width: int = 0,