X Tutup
Skip to content

Commit 1f29093

Browse files
committed
Merge branch 'unittest-bot2.0' of https://github.com/python-telegram-bot/python-telegram-bot into unittest-bot2.0
2 parents 0e34c03 + 1425533 commit 1f29093

File tree

59 files changed

+2110
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2110
-177
lines changed

telegram/bot.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,14 +1164,14 @@ def answerCallbackQuery(self,
11641164
return result
11651165

11661166
@log
1167+
@message
11671168
def editMessageText(self,
11681169
text,
11691170
chat_id=None,
11701171
message_id=None,
11711172
inline_message_id=None,
11721173
parse_mode=None,
11731174
disable_web_page_preview=None,
1174-
reply_markup=None,
11751175
**kwargs):
11761176
"""Use this method to edit text messages sent by the bot or via the bot
11771177
(for inline bots).
@@ -1194,10 +1194,10 @@ def editMessageText(self,
11941194
italic, fixed-width text or inline URLs in your bot's message.
11951195
disable_web_page_preview:
11961196
Disables link previews for links in this message.
1197-
reply_markup:
1198-
A JSON-serialized object for an inline keyboard.
11991197
12001198
Keyword Args:
1199+
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
1200+
A JSON-serialized object for an inline keyboard.
12011201
timeout (Optional[float]): If this value is specified, use it as
12021202
the definitive timeout (in seconds) for urlopen() operations.
12031203
network_delay (Optional[float]): If using the timeout (which is
@@ -1229,17 +1229,8 @@ def editMessageText(self,
12291229
data['parse_mode'] = parse_mode
12301230
if disable_web_page_preview:
12311231
data['disable_web_page_preview'] = disable_web_page_preview
1232-
if reply_markup:
1233-
if isinstance(reply_markup, ReplyMarkup):
1234-
data['reply_markup'] = reply_markup.to_json()
1235-
else:
1236-
data['reply_markup'] = reply_markup
1237-
1238-
result = request.post(url, data,
1239-
timeout=kwargs.get('timeout'),
1240-
network_delay=kwargs.get('network_delay'))
12411232

1242-
return Message.de_json(result)
1233+
return url, data
12431234

12441235
@log
12451236
@message

telegram/inlinekeyboardmarkup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def __init__(self,
4141

4242
@staticmethod
4343
def de_json(data):
44+
data = super(InlineKeyboardMarkup, InlineKeyboardMarkup).de_json(data)
45+
4446
if not data:
4547
return None
4648

telegram/inlinequeryresultcachedaudio.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,35 @@
2525

2626

2727
class InlineQueryResultCachedAudio(InlineQueryResult):
28+
"""Represents a link to an mp3 audio file stored on the Telegram
29+
servers. By default, this audio file will be sent by the user.
30+
Alternatively, you can use input_message_content to send a message with
31+
the specified content instead of the audio.
32+
33+
Attributes:
34+
id (str):
35+
audio_file_id (str):
36+
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
37+
input_message_content (Optional[
38+
:class:`telegram.input_message_content`]):
39+
40+
Deprecated: 4.0
41+
message_text (str): Use :class:`InputTextMessageContent` instead.
42+
43+
parse_mode (str): Use :class:`InputTextMessageContent` instead.
44+
45+
disable_web_page_preview (bool): Use :class:`InputTextMessageContent`
46+
instead.
47+
48+
Args:
49+
audio_file_id (str):
50+
**kwargs: Arbitrary keyword arguments.
51+
52+
Keyword Args:
53+
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
54+
input_message_content (Optional[
55+
:class:`telegram.input_message_content`]):
56+
"""
2857
def __init__(self,
2958
id,
3059
audio_file_id,

telegram/inputcontactmessagecontent.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,18 @@
2424

2525

2626
class InputContactMessageContent(InputMessageContent):
27-
pass
27+
"""Base class for Telegram InputContactMessageContent Objects"""
28+
29+
def __init__(self,
30+
phone_number,
31+
first_name,
32+
last_name=None):
33+
# Required
34+
self.phone_number = phone_number
35+
self.first_name = first_name
36+
# Optionals
37+
self.last_name = last_name
38+
39+
@staticmethod
40+
def de_json(data):
41+
return InputContactMessageContent(**data)

telegram/inputlocationmessagecontent.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,4 @@ def __init__(self,
3535

3636
@staticmethod
3737
def de_json(data):
38-
data = super(InputLocationMessageContent,
39-
InputLocationMessageContent).de_json(data)
40-
4138
return InputLocationMessageContent(**data)

telegram/inputmessagecontent.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,33 @@ class InputMessageContent(TelegramObject):
2828

2929
@staticmethod
3030
def de_json(data):
31-
pass
31+
data = super(InputMessageContent, InputMessageContent).de_json(data)
32+
33+
if not data:
34+
return None
35+
36+
try:
37+
from telegram import InputTextMessageContent
38+
return InputTextMessageContent.de_json(data)
39+
except TypeError:
40+
pass
41+
42+
try:
43+
from telegram import InputLocationMessageContent
44+
return InputLocationMessageContent.de_json(data)
45+
except TypeError:
46+
pass
47+
48+
try:
49+
from telegram import InputVenueMessageContent
50+
return InputVenueMessageContent.de_json(data)
51+
except TypeError:
52+
pass
53+
54+
try:
55+
from telegram import InputContactMessageContent
56+
return InputContactMessageContent.de_json(data)
57+
except TypeError:
58+
pass
59+
60+
return None

telegram/inputtextmessagecontent.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,4 @@ def __init__(self,
3838

3939
@staticmethod
4040
def de_json(data):
41-
data = super(InputTextMessageContent,
42-
InputTextMessageContent).de_json(data)
43-
4441
return InputTextMessageContent(**data)

telegram/inputvenuemessagecontent.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,4 @@ def __init__(self,
4242

4343
@staticmethod
4444
def de_json(data):
45-
data = super(InputVenueMessageContent,
46-
InputVenueMessageContent).de_json(data)
47-
4845
return InputVenueMessageContent(**data)

telegram/replymarkup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ class ReplyMarkup(TelegramObject):
2727

2828
@staticmethod
2929
def de_json(data):
30-
pass
30+
data = super(ReplyMarkup, ReplyMarkup).de_json(data)
31+
32+
if not data:
33+
return None
34+
35+
return data

telegram/venue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ def __init__(self,
4747

4848
@staticmethod
4949
def de_json(data):
50+
data = super(Venue, Venue).de_json(data)
51+
5052
if not data:
5153
return None
5254

53-
data = super(Venue, Venue).de_json(data)
54-
5555
data['location'] = Location.de_json(data.get('location'))
5656

5757
return Venue(**data)

0 commit comments

Comments
 (0)
X Tutup