mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Add ability to edit video messages
This commit is contained in:
parent
51eb2f90b9
commit
f3074f04b0
@ -17,6 +17,7 @@
|
|||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import binascii
|
import binascii
|
||||||
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ from pyrogram.api import functions, types
|
|||||||
from pyrogram.api.errors import FileIdInvalid
|
from pyrogram.api.errors import FileIdInvalid
|
||||||
from pyrogram.client.ext import BaseClient, utils
|
from pyrogram.client.ext import BaseClient, utils
|
||||||
from pyrogram.client.types import (
|
from pyrogram.client.types import (
|
||||||
InputMediaPhoto
|
InputMediaPhoto, InputMediaVideo
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +82,34 @@ class EditMessageMedia(BaseClient):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if isinstance(media, InputMediaVideo):
|
||||||
|
if os.path.exists(media.media):
|
||||||
|
media = self.send(
|
||||||
|
functions.messages.UploadMedia(
|
||||||
|
peer=self.resolve_peer(chat_id),
|
||||||
|
media=types.InputMediaUploadedDocument(
|
||||||
|
mime_type=mimetypes.types_map[".mp4"],
|
||||||
|
file=self.save_file(media.media),
|
||||||
|
attributes=[
|
||||||
|
types.DocumentAttributeVideo(
|
||||||
|
supports_streaming=media.supports_streaming or None,
|
||||||
|
duration=media.duration,
|
||||||
|
w=media.width,
|
||||||
|
h=media.height
|
||||||
|
),
|
||||||
|
types.DocumentAttributeFilename(os.path.basename(media.media))
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
media = types.InputMediaDocument(
|
||||||
|
id=types.InputDocument(
|
||||||
|
id=media.document.id,
|
||||||
|
access_hash=media.document.access_hash
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
r = self.send(
|
r = self.send(
|
||||||
functions.messages.EditMessage(
|
functions.messages.EditMessage(
|
||||||
peer=self.resolve_peer(chat_id),
|
peer=self.resolve_peer(chat_id),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user