diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 4547429d..23cb0946 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -52,7 +52,8 @@ from pyrogram.session.internals import MsgId from . import message_parser from . import utils from .dispatcher import Dispatcher -from .input_media import InputMedia +from .input_media_photo import InputMediaPhoto +from .input_media_video import InputMediaVideo from .style import Markdown, HTML from .syncer import Syncer @@ -1980,6 +1981,8 @@ class Client: return message_parser.parse_message(self, i.message, users, chats) # TODO: Add progress parameter + # TODO: Return new Message object + # TODO: Figure out how to send albums using URLs def send_media_group(self, chat_id: int or str, media: list, @@ -1996,7 +1999,7 @@ class Client: For a private channel/supergroup you can use its *t.me/joinchat/* link. media (``list``): - A list containing either :obj:`pyrogram.InputMedia.Photo` or :obj:`pyrogram.InputMedia.Video` objects + A list containing either :obj:`pyrogram.InputMediaPhoto` or :obj:`pyrogram.InputMediaVideo` objects describing photos and videos to be sent, must include 2–10 items. disable_notification (``bool``, optional): @@ -2009,66 +2012,104 @@ class Client: multi_media = [] for i in media: - if isinstance(i, InputMedia.Photo): - style = self.html if i.parse_mode.lower() == "html" else self.markdown - media = self.save_file(i.media) + style = self.html if i.parse_mode.lower() == "html" else self.markdown - media = self.send( - functions.messages.UploadMedia( - peer=self.resolve_peer(chat_id), - media=types.InputMediaUploadedPhoto( - file=media + if isinstance(i, InputMediaPhoto): + if os.path.exists(i.media): + media = self.send( + functions.messages.UploadMedia( + peer=self.resolve_peer(chat_id), + media=types.InputMediaUploadedPhoto( + file=self.save_file(i.media) + ) ) ) - ) - single_media = types.InputSingleMedia( - media=types.InputMediaPhoto( + media = types.InputMediaPhoto( id=types.InputPhoto( id=media.photo.id, access_hash=media.photo.access_hash ) - ), - random_id=self.rnd_id(), - **style.parse(i.caption) - ) + ) + else: + try: + decoded = utils.decode(i.media) + fmt = " 24 else " 24 else "` or :obj:`HTML ` if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption. Defaults to Markdown. diff --git a/pyrogram/client/input_media_video.py b/pyrogram/client/input_media_video.py index c14767e5..a25a65df 100644 --- a/pyrogram/client/input_media_video.py +++ b/pyrogram/client/input_media_video.py @@ -23,8 +23,10 @@ class InputMediaVideo: Args: media (:obj:`str`): - Video file to send. - Pass a file path as string to send a video that exists on your local machine. + Video to send. + Pass a file_id as string to send a video that exists on the Telegram servers or + pass a file path as string to upload a new video that exists on your local machine. + Sending video by a URL is currently unsupported. caption (:obj:`str`, optional): Caption of the video to be sent, 0-200 characters