mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Fix captions not being preserved when editing media
This commit is contained in:
parent
15f95a0706
commit
51f771457c
@ -80,6 +80,11 @@ class EditMessageMedia(Scaffold):
|
|||||||
caption = media.caption
|
caption = media.caption
|
||||||
parse_mode = media.parse_mode
|
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 isinstance(media, types.InputMediaPhoto):
|
||||||
if os.path.isfile(media.media):
|
if os.path.isfile(media.media):
|
||||||
media = await self.send(
|
media = await self.send(
|
||||||
@ -253,7 +258,8 @@ class EditMessageMedia(Scaffold):
|
|||||||
id=message_id,
|
id=message_id,
|
||||||
media=media,
|
media=media,
|
||||||
reply_markup=reply_markup.write() if reply_markup else None,
|
reply_markup=reply_markup.write() if reply_markup else None,
|
||||||
**await self.parser.parse(caption, parse_mode)
|
message=message,
|
||||||
|
entities=entities
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ class SendMediaGroup(Scaffold):
|
|||||||
raw.types.InputSingleMedia(
|
raw.types.InputSingleMedia(
|
||||||
media=media,
|
media=media,
|
||||||
random_id=self.rnd_id(),
|
random_id=self.rnd_id(),
|
||||||
**await self.parser.parse(i.caption, i.parse_mode)
|
**await self.parser.parse(i.caption or "", i.parse_mode)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ class InputMediaAnimation(InputMedia):
|
|||||||
Thumbnails can't be reused and can be only uploaded as a new file.
|
Thumbnails can't be reused and can be only uploaded as a new file.
|
||||||
|
|
||||||
caption (``str``, *optional*):
|
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*):
|
parse_mode (``str``, *optional*):
|
||||||
By default, texts are parsed using both Markdown and HTML styles.
|
By default, texts are parsed using both Markdown and HTML styles.
|
||||||
@ -64,7 +65,7 @@ class InputMediaAnimation(InputMedia):
|
|||||||
self,
|
self,
|
||||||
media: str,
|
media: str,
|
||||||
thumb: str = None,
|
thumb: str = None,
|
||||||
caption: str = "",
|
caption: str = None,
|
||||||
parse_mode: Optional[str] = object,
|
parse_mode: Optional[str] = object,
|
||||||
caption_entities: List[MessageEntity] = None,
|
caption_entities: List[MessageEntity] = None,
|
||||||
width: int = 0,
|
width: int = 0,
|
||||||
|
@ -40,7 +40,8 @@ class InputMediaAudio(InputMedia):
|
|||||||
Thumbnails can't be reused and can be only uploaded as a new file.
|
Thumbnails can't be reused and can be only uploaded as a new file.
|
||||||
|
|
||||||
caption (``str``, *optional*):
|
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*):
|
parse_mode (``str``, *optional*):
|
||||||
By default, texts are parsed using both Markdown and HTML styles.
|
By default, texts are parsed using both Markdown and HTML styles.
|
||||||
@ -66,7 +67,7 @@ class InputMediaAudio(InputMedia):
|
|||||||
self,
|
self,
|
||||||
media: str,
|
media: str,
|
||||||
thumb: str = None,
|
thumb: str = None,
|
||||||
caption: str = "",
|
caption: str = None,
|
||||||
parse_mode: Optional[str] = object,
|
parse_mode: Optional[str] = object,
|
||||||
caption_entities: List[MessageEntity] = None,
|
caption_entities: List[MessageEntity] = None,
|
||||||
duration: int = 0,
|
duration: int = 0,
|
||||||
|
@ -38,7 +38,8 @@ class InputMediaDocument(InputMedia):
|
|||||||
Thumbnails can't be reused and can be only uploaded as a new file.
|
Thumbnails can't be reused and can be only uploaded as a new file.
|
||||||
|
|
||||||
caption (``str``, *optional*):
|
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*):
|
parse_mode (``str``, *optional*):
|
||||||
By default, texts are parsed using both Markdown and HTML styles.
|
By default, texts are parsed using both Markdown and HTML styles.
|
||||||
@ -55,7 +56,7 @@ class InputMediaDocument(InputMedia):
|
|||||||
self,
|
self,
|
||||||
media: str,
|
media: str,
|
||||||
thumb: str = None,
|
thumb: str = None,
|
||||||
caption: str = "",
|
caption: str = None,
|
||||||
parse_mode: Optional[str] = object,
|
parse_mode: Optional[str] = object,
|
||||||
caption_entities: List[MessageEntity] = None
|
caption_entities: List[MessageEntity] = None
|
||||||
):
|
):
|
||||||
|
@ -34,7 +34,8 @@ class InputMediaPhoto(InputMedia):
|
|||||||
Sending photo by a URL is currently unsupported.
|
Sending photo by a URL is currently unsupported.
|
||||||
|
|
||||||
caption (``str``, *optional*):
|
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*):
|
parse_mode (``str``, *optional*):
|
||||||
By default, texts are parsed using both Markdown and HTML styles.
|
By default, texts are parsed using both Markdown and HTML styles.
|
||||||
@ -50,7 +51,7 @@ class InputMediaPhoto(InputMedia):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
media: str,
|
media: str,
|
||||||
caption: str = "",
|
caption: str = None,
|
||||||
parse_mode: Optional[str] = object,
|
parse_mode: Optional[str] = object,
|
||||||
caption_entities: List[MessageEntity] = None
|
caption_entities: List[MessageEntity] = None
|
||||||
):
|
):
|
||||||
|
@ -40,7 +40,8 @@ class InputMediaVideo(InputMedia):
|
|||||||
Thumbnails can't be reused and can be only uploaded as a new file.
|
Thumbnails can't be reused and can be only uploaded as a new file.
|
||||||
|
|
||||||
caption (``str``, *optional*):
|
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*):
|
parse_mode (``str``, *optional*):
|
||||||
By default, texts are parsed using both Markdown and HTML styles.
|
By default, texts are parsed using both Markdown and HTML styles.
|
||||||
@ -69,7 +70,7 @@ class InputMediaVideo(InputMedia):
|
|||||||
self,
|
self,
|
||||||
media: str,
|
media: str,
|
||||||
thumb: str = None,
|
thumb: str = None,
|
||||||
caption: str = "",
|
caption: str = None,
|
||||||
parse_mode: Optional[str] = object,
|
parse_mode: Optional[str] = object,
|
||||||
caption_entities: List[MessageEntity] = None,
|
caption_entities: List[MessageEntity] = None,
|
||||||
width: int = 0,
|
width: int = 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user