diff --git a/pyrogram/client/methods/messages/edit_message_media.py b/pyrogram/client/methods/messages/edit_message_media.py index 5993f1c9..ae468813 100644 --- a/pyrogram/client/methods/messages/edit_message_media.py +++ b/pyrogram/client/methods/messages/edit_message_media.py @@ -26,7 +26,7 @@ from pyrogram.api.errors import FileIdInvalid from pyrogram.client.ext import BaseClient, utils from pyrogram.client.types import ( InputMediaPhoto, InputMediaVideo, InputMediaAudio, - InputMediaAnimation + InputMediaAnimation, InputMediaDocument ) @@ -245,6 +245,54 @@ class EditMessageMedia(BaseClient): ) ) + if isinstance(media, InputMediaDocument): + if os.path.exists(media.media): + media = await self.send( + functions.messages.UploadMedia( + peer=await self.resolve_peer(chat_id), + media=types.InputMediaUploadedDocument( + mime_type=mimetypes.types_map.get("." + media.media.split(".")[-1], "text/plain"), + file=await self.save_file(media.media), + attributes=[ + types.DocumentAttributeFilename(os.path.basename(media.media)) + ] + ) + ) + ) + + media = types.InputMediaDocument( + id=types.InputDocument( + id=media.document.id, + access_hash=media.document.access_hash + ) + ) + elif media.media.startswith("http"): + media = types.InputMediaDocumentExternal( + url=media.media + ) + else: + try: + decoded = utils.decode(media.media) + fmt = " 24 else "