Skip to content

Commit 6459ce0

Browse files
committed
Fix lots of bound methods breaking due to latest changes on parse_mode
Addresses pyrogram#287
1 parent 62a3952 commit 6459ce0

5 files changed

Lines changed: 21 additions & 16 deletions

File tree

pyrogram/client/methods/messages/edit_inline_caption.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
from typing import Union
20+
1921
import pyrogram
2022
from pyrogram.client.ext import BaseClient
2123

@@ -25,7 +27,7 @@ def edit_inline_caption(
2527
self,
2628
inline_message_id: str,
2729
caption: str,
28-
parse_mode: str = "",
30+
parse_mode: Union[str, None] = object,
2931
reply_markup: "pyrogram.InlineKeyboardMarkup" = None
3032
) -> bool:
3133
"""Edit the caption of **inline** media messages.

pyrogram/client/methods/messages/edit_message_caption.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def edit_message_caption(
2828
chat_id: Union[int, str],
2929
message_id: int,
3030
caption: str,
31-
parse_mode: str = "",
31+
parse_mode: Union[str, None] = object,
3232
reply_markup: "pyrogram.InlineKeyboardMarkup" = None
3333
) -> "pyrogram.Message":
3434
"""Edit the caption of media messages.

pyrogram/client/parser/parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ def parse(self, text: str, mode: Union[str, None] = object):
3434
text = str(text or "").strip()
3535

3636
if mode == object:
37-
mode = self.client.parse_mode
37+
if self.client:
38+
mode = self.client.parse_mode
39+
else:
40+
mode = "combined"
3841

3942
if mode is None:
4043
return OrderedDict([
@@ -54,7 +57,7 @@ def parse(self, text: str, mode: Union[str, None] = object):
5457
return self.html.parse(text)
5558

5659
raise ValueError('parse_mode must be one of {} or None. Not "{}"'.format(
57-
", ".join('"{}"'.format(m) for m in self.client.PARSE_MODES[:-1]),
60+
", ".join('"{}"'.format(m) for m in pyrogram.Client.PARSE_MODES[:-1]),
5861
mode
5962
))
6063

pyrogram/client/types/bots_and_keyboards/callback_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def answer(self, text: str = None, show_alert: bool = None, url: str = None, cac
176176
def edit_message_text(
177177
self,
178178
text: str,
179-
parse_mode: str = "",
179+
parse_mode: Union[str, None] = object,
180180
disable_web_page_preview: bool = None,
181181
reply_markup: "pyrogram.InlineKeyboardMarkup" = None
182182
) -> Union["pyrogram.Message", bool]:
@@ -229,7 +229,7 @@ def edit_message_text(
229229
def edit_message_caption(
230230
self,
231231
caption: str,
232-
parse_mode: str = "",
232+
parse_mode: Union[str, None] = object,
233233
reply_markup: "pyrogram.InlineKeyboardMarkup" = None
234234
) -> Union["pyrogram.Message", bool]:
235235
"""Edit the caption of media messages attached to callback queries.

pyrogram/client/types/messages_and_media/message.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ def reply_text(
654654
self,
655655
text: str,
656656
quote: bool = None,
657-
parse_mode: str = "",
657+
parse_mode: Union[str, None] = object,
658658
disable_web_page_preview: bool = None,
659659
disable_notification: bool = None,
660660
reply_to_message_id: int = None,
@@ -736,7 +736,7 @@ def reply_animation(
736736
animation: str,
737737
quote: bool = None,
738738
caption: str = "",
739-
parse_mode: str = "",
739+
parse_mode: Union[str, None] = object,
740740
duration: int = 0,
741741
width: int = 0,
742742
height: int = 0,
@@ -873,7 +873,7 @@ def reply_audio(
873873
audio: str,
874874
quote: bool = None,
875875
caption: str = "",
876-
parse_mode: str = "",
876+
parse_mode: Union[str, None] = object,
877877
duration: int = 0,
878878
performer: str = None,
879879
title: str = None,
@@ -1010,7 +1010,7 @@ def reply_cached_media(
10101010
file_id: str,
10111011
quote: bool = None,
10121012
caption: str = "",
1013-
parse_mode: str = "",
1013+
parse_mode: Union[str, None] = object,
10141014
disable_notification: bool = None,
10151015
reply_to_message_id: int = None,
10161016
reply_markup: Union[
@@ -1218,7 +1218,7 @@ def reply_document(
12181218
quote: bool = None,
12191219
thumb: str = None,
12201220
caption: str = "",
1221-
parse_mode: str = "",
1221+
parse_mode: Union[str, None] = object,
12221222
disable_notification: bool = None,
12231223
reply_to_message_id: int = None,
12241224
reply_markup: Union[
@@ -1613,7 +1613,7 @@ def reply_photo(
16131613
photo: str,
16141614
quote: bool = None,
16151615
caption: str = "",
1616-
parse_mode: str = "",
1616+
parse_mode: Union[str, None] = object,
16171617
ttl_seconds: int = None,
16181618
disable_notification: bool = None,
16191619
reply_to_message_id: int = None,
@@ -2007,7 +2007,7 @@ def reply_video(
20072007
video: str,
20082008
quote: bool = None,
20092009
caption: str = "",
2010-
parse_mode: str = "",
2010+
parse_mode: Union[str, None] = object,
20112011
duration: int = 0,
20122012
width: int = 0,
20132013
height: int = 0,
@@ -2267,7 +2267,7 @@ def reply_voice(
22672267
voice: str,
22682268
quote: bool = None,
22692269
caption: str = "",
2270-
parse_mode: str = "",
2270+
parse_mode: Union[str, None] = object,
22712271
duration: int = 0,
22722272
disable_notification: bool = None,
22732273
reply_to_message_id: int = None,
@@ -2384,7 +2384,7 @@ def reply_voice(
23842384
def edit_text(
23852385
self,
23862386
text: str,
2387-
parse_mode: str = "",
2387+
parse_mode: Union[str, None] = object,
23882388
disable_web_page_preview: bool = None,
23892389
reply_markup: "pyrogram.InlineKeyboardMarkup" = None
23902390
) -> "Message":
@@ -2442,7 +2442,7 @@ def edit_text(
24422442
def edit_caption(
24432443
self,
24442444
caption: str,
2445-
parse_mode: str = "",
2445+
parse_mode: Union[str, None] = object,
24462446
reply_markup: "pyrogram.InlineKeyboardMarkup" = None
24472447
) -> "Message":
24482448
"""Bound method *edit_caption* of :obj:`Message`.

0 commit comments

Comments
 (0)