From be3947e20bf837904ab36c9abac2135c35cb1976 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Tue, 2 Jul 2019 00:00:59 +0200
Subject: [PATCH] Fix some methods not working correctly with the new Text
Parser
---
pyrogram/client/methods/messages/edit_inline_media.py | 4 ++--
pyrogram/client/methods/messages/edit_message_media.py | 4 ++--
pyrogram/client/methods/messages/send_media_group.py | 4 +---
pyrogram/client/types/input_media/input_media_animation.py | 4 +++-
pyrogram/client/types/input_media/input_media_audio.py | 4 +++-
pyrogram/client/types/input_media/input_media_document.py | 4 +++-
pyrogram/client/types/input_media/input_media_photo.py | 4 +++-
pyrogram/client/types/input_media/input_media_video.py | 4 +++-
8 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/pyrogram/client/methods/messages/edit_inline_media.py b/pyrogram/client/methods/messages/edit_inline_media.py
index 87e692fd..0ed89d17 100644
--- a/pyrogram/client/methods/messages/edit_inline_media.py
+++ b/pyrogram/client/methods/messages/edit_inline_media.py
@@ -55,8 +55,8 @@ class EditInlineMedia(BaseClient):
Raises:
RPCError: In case of a Telegram RPC error.
"""
- style = self.html if media.parse_mode.lower() == "html" else self.markdown
caption = media.caption
+ parse_mode = media.parse_mode
if isinstance(media, InputMediaPhoto):
if media.media.startswith("http"):
@@ -99,6 +99,6 @@ class EditInlineMedia(BaseClient):
id=utils.unpack_inline_message_id(inline_message_id),
media=media,
reply_markup=reply_markup.write() if reply_markup else None,
- **style.parse(caption)
+ **self.parser.parse(caption, parse_mode)
)
)
diff --git a/pyrogram/client/methods/messages/edit_message_media.py b/pyrogram/client/methods/messages/edit_message_media.py
index b65804fd..72077710 100644
--- a/pyrogram/client/methods/messages/edit_message_media.py
+++ b/pyrogram/client/methods/messages/edit_message_media.py
@@ -63,8 +63,8 @@ class EditMessageMedia(BaseClient):
Raises:
RPCError: In case of a Telegram RPC error.
"""
- style = self.html if media.parse_mode.lower() == "html" else self.markdown
caption = media.caption
+ parse_mode = media.parse_mode
if isinstance(media, InputMediaPhoto):
if os.path.exists(media.media):
@@ -239,7 +239,7 @@ class EditMessageMedia(BaseClient):
id=message_id,
media=media,
reply_markup=reply_markup.write() if reply_markup else None,
- **style.parse(caption)
+ **self.parser.parse(caption, parse_mode)
)
)
diff --git a/pyrogram/client/methods/messages/send_media_group.py b/pyrogram/client/methods/messages/send_media_group.py
index 194a2202..681e1850 100644
--- a/pyrogram/client/methods/messages/send_media_group.py
+++ b/pyrogram/client/methods/messages/send_media_group.py
@@ -66,8 +66,6 @@ class SendMediaGroup(BaseClient):
multi_media = []
for i in media:
- style = self.html if i.parse_mode.lower() == "html" else self.markdown
-
if isinstance(i, pyrogram.InputMediaPhoto):
if os.path.exists(i.media):
while True:
@@ -138,7 +136,7 @@ class SendMediaGroup(BaseClient):
types.InputSingleMedia(
media=media,
random_id=self.rnd_id(),
- **style.parse(i.caption)
+ **self.parser.parse(i.caption, i.parse_mode)
)
)
diff --git a/pyrogram/client/types/input_media/input_media_animation.py b/pyrogram/client/types/input_media/input_media_animation.py
index e5b8edb4..14920723 100644
--- a/pyrogram/client/types/input_media/input_media_animation.py
+++ b/pyrogram/client/types/input_media/input_media_animation.py
@@ -16,6 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+from typing import Union
+
from . import InputMedia
@@ -61,7 +63,7 @@ class InputMediaAnimation(InputMedia):
media: str,
thumb: str = None,
caption: str = "",
- parse_mode: str = "",
+ parse_mode: Union[str, None] = "",
width: int = 0,
height: int = 0,
duration: int = 0
diff --git a/pyrogram/client/types/input_media/input_media_audio.py b/pyrogram/client/types/input_media/input_media_audio.py
index 02299a12..f360d3c6 100644
--- a/pyrogram/client/types/input_media/input_media_audio.py
+++ b/pyrogram/client/types/input_media/input_media_audio.py
@@ -16,6 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+from typing import Union
+
from . import InputMedia
@@ -63,7 +65,7 @@ class InputMediaAudio(InputMedia):
media: str,
thumb: str = None,
caption: str = "",
- parse_mode: str = "",
+ parse_mode: Union[str, None] = "",
duration: int = 0,
performer: int = "",
title: str = ""
diff --git a/pyrogram/client/types/input_media/input_media_document.py b/pyrogram/client/types/input_media/input_media_document.py
index 46a5b446..629f7469 100644
--- a/pyrogram/client/types/input_media/input_media_document.py
+++ b/pyrogram/client/types/input_media/input_media_document.py
@@ -16,6 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+from typing import Union
+
from . import InputMedia
@@ -52,7 +54,7 @@ class InputMediaDocument(InputMedia):
media: str,
thumb: str = None,
caption: str = "",
- parse_mode: str = ""
+ parse_mode: Union[str, None] = ""
):
super().__init__(media, caption, parse_mode)
diff --git a/pyrogram/client/types/input_media/input_media_photo.py b/pyrogram/client/types/input_media/input_media_photo.py
index 064065e3..97077d1d 100644
--- a/pyrogram/client/types/input_media/input_media_photo.py
+++ b/pyrogram/client/types/input_media/input_media_photo.py
@@ -16,6 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+from typing import Union
+
from . import InputMedia
@@ -47,6 +49,6 @@ class InputMediaPhoto(InputMedia):
self,
media: str,
caption: str = "",
- parse_mode: str = ""
+ parse_mode: Union[str, None] = ""
):
super().__init__(media, caption, parse_mode)
diff --git a/pyrogram/client/types/input_media/input_media_video.py b/pyrogram/client/types/input_media/input_media_video.py
index 4584ffbe..50d70004 100644
--- a/pyrogram/client/types/input_media/input_media_video.py
+++ b/pyrogram/client/types/input_media/input_media_video.py
@@ -16,6 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+from typing import Union
+
from . import InputMedia
@@ -66,7 +68,7 @@ class InputMediaVideo(InputMedia):
media: str,
thumb: str = None,
caption: str = "",
- parse_mode: str = "",
+ parse_mode: Union[str, None] = "",
width: int = 0,
height: int = 0,
duration: int = 0,