Skip to content

Commit 5035e0c

Browse files
committed
Added parse mode for objects in Inline mode
1 parent 7061091 commit 5035e0c

1 file changed

Lines changed: 51 additions & 19 deletions

File tree

‎telebot/types.py‎

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ def to_json(self):
11911191

11921192
class InlineQueryResultPhoto(JsonSerializable):
11931193
def __init__(self, id, photo_url, thumb_url, photo_width=None, photo_height=None, title=None,
1194-
description=None, caption=None, reply_markup=None, input_message_content=None):
1194+
description=None, caption=None, parse_mode=None, reply_markup=None, input_message_content=None):
11951195
"""
11961196
Represents a link to a photo.
11971197
:param id: Unique identifier for this result, 1-64 bytes
@@ -1202,6 +1202,8 @@ def __init__(self, id, photo_url, thumb_url, photo_width=None, photo_height=None
12021202
:param title: Title for the result.
12031203
:param description: Short description of the result.
12041204
:param caption: Caption of the photo to be sent, 0-200 characters.
1205+
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
1206+
inline URLs in the media caption.
12051207
:param reply_markup: InlineKeyboardMarkup : Inline keyboard attached to the message
12061208
:param input_message_content: InputMessageContent : Content of the message to be sent instead of the photo
12071209
:return:
@@ -1215,6 +1217,7 @@ def __init__(self, id, photo_url, thumb_url, photo_width=None, photo_height=None
12151217
self.title = title
12161218
self.description = description
12171219
self.caption = caption
1220+
self.parse_mode = parse_mode
12181221
self.reply_markup = reply_markup
12191222
self.input_message_content = input_message_content
12201223

@@ -1230,6 +1233,8 @@ def to_json(self):
12301233
json_dict['description'] = self.description
12311234
if self.caption:
12321235
json_dict['caption'] = self.caption
1236+
if self.parse_mode:
1237+
json_dict['parse_mode'] = self.parse_mode
12331238
if self.reply_markup:
12341239
json_dict['reply_markup'] = self.reply_markup.to_dic()
12351240
if self.input_message_content:
@@ -1286,7 +1291,7 @@ def to_json(self):
12861291

12871292
class InlineQueryResultMpeg4Gif(JsonSerializable):
12881293
def __init__(self, id, mpeg4_url, thumb_url, mpeg4_width=None, mpeg4_height=None, title=None, caption=None,
1289-
reply_markup=None, input_message_content=None, mpeg4_duration=None):
1294+
parse_mode=None, reply_markup=None, input_message_content=None, mpeg4_duration=None):
12901295
"""
12911296
Represents a link to a video animation (H.264/MPEG-4 AVC video without sound).
12921297
:param id: Unique identifier for this result, 1-64 bytes
@@ -1296,6 +1301,8 @@ def __init__(self, id, mpeg4_url, thumb_url, mpeg4_width=None, mpeg4_height=None
12961301
:param mpeg4_height: Video height
12971302
:param title: Title for the result
12981303
:param caption: Caption of the MPEG-4 file to be sent, 0-200 characters
1304+
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text
1305+
or inline URLs in the media caption.
12991306
:param reply_markup: InlineKeyboardMarkup : Inline keyboard attached to the message
13001307
:param input_message_content: InputMessageContent : Content of the message to be sent instead of the photo
13011308
:return:
@@ -1308,6 +1315,7 @@ def __init__(self, id, mpeg4_url, thumb_url, mpeg4_width=None, mpeg4_height=None
13081315
self.thumb_url = thumb_url
13091316
self.title = title
13101317
self.caption = caption
1318+
self.parse_mode = parse_mode
13111319
self.reply_markup = reply_markup
13121320
self.input_message_content = input_message_content
13131321
self.mpeg4_duration = mpeg4_duration
@@ -1322,6 +1330,8 @@ def to_json(self):
13221330
json_dict['title'] = self.title
13231331
if self.caption:
13241332
json_dict['caption'] = self.caption
1333+
if self.parse_mode:
1334+
json_dict['parse_mode'] = self.parse_mode
13251335
if self.reply_markup:
13261336
json_dict['reply_markup'] = self.reply_markup.to_dic()
13271337
if self.input_message_content:
@@ -1333,15 +1343,17 @@ def to_json(self):
13331343

13341344
class InlineQueryResultVideo(JsonSerializable):
13351345
def __init__(self, id, video_url, mime_type, thumb_url, title,
1336-
caption=None, video_width=None, video_height=None, video_duration=None, description=None,
1337-
reply_markup=None, input_message_content=None):
1346+
caption=None, parse_mode=None, video_width=None, video_height=None, video_duration=None,
1347+
description=None, reply_markup=None, input_message_content=None):
13381348
"""
13391349
Represents link to a page containing an embedded video player or a video file.
13401350
:param id: Unique identifier for this result, 1-64 bytes
13411351
:param video_url: A valid URL for the embedded video player or video file
13421352
:param mime_type: Mime type of the content of video url, “text/html” or “video/mp4”
13431353
:param thumb_url: URL of the thumbnail (jpeg only) for the video
13441354
:param title: Title for the result
1355+
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
1356+
inline URLs in the media caption.
13451357
:param video_width: Video width
13461358
:param video_height: Video height
13471359
:param video_duration: Video duration in seconds
@@ -1358,6 +1370,7 @@ def __init__(self, id, video_url, mime_type, thumb_url, title,
13581370
self.thumb_url = thumb_url
13591371
self.title = title
13601372
self.caption = caption
1373+
self.parse_mode = parse_mode
13611374
self.description = description
13621375
self.input_message_content = input_message_content
13631376
self.reply_markup = reply_markup
@@ -1375,6 +1388,8 @@ def to_json(self):
13751388
json_dict['description'] = self.description
13761389
if self.caption:
13771390
json_dict['caption'] = self.caption
1391+
if self.parse_mode:
1392+
json_dict['parse_mode'] = self.parse_mode
13781393
if self.reply_markup:
13791394
json_dict['reply_markup'] = self.reply_markup.to_dic()
13801395
if self.input_message_content:
@@ -1383,13 +1398,14 @@ def to_json(self):
13831398

13841399

13851400
class InlineQueryResultAudio(JsonSerializable):
1386-
def __init__(self, id, audio_url, title, caption=None, performer=None, audio_duration=None, reply_markup=None,
1387-
input_message_content=None):
1401+
def __init__(self, id, audio_url, title, caption=None, parse_mode=None, performer=None, audio_duration=None,
1402+
reply_markup=None, input_message_content=None):
13881403
self.type = 'audio'
13891404
self.id = id
13901405
self.audio_url = audio_url
13911406
self.title = title
13921407
self.caption = caption
1408+
self.parse_mode = parse_mode
13931409
self.performer = performer
13941410
self.audio_duration = audio_duration
13951411
self.reply_markup = reply_markup
@@ -1399,6 +1415,8 @@ def to_json(self):
13991415
json_dict = {'type': self.type, 'id': self.id, 'audio_url': self.audio_url, 'title': self.title}
14001416
if self.caption:
14011417
json_dict['caption'] = self.caption
1418+
if self.parse_mode:
1419+
json_dict['parse_mode'] = self.parse_mode
14021420
if self.performer:
14031421
json_dict['performer'] = self.performer
14041422
if self.audio_duration:
@@ -1411,13 +1429,14 @@ def to_json(self):
14111429

14121430

14131431
class InlineQueryResultVoice(JsonSerializable):
1414-
def __init__(self, id, voice_url, title, caption=None, performer=None, voice_duration=None, reply_markup=None,
1415-
input_message_content=None):
1432+
def __init__(self, id, voice_url, title, caption=None, parse_mode=None, performer=None, voice_duration=None,
1433+
reply_markup=None, input_message_content=None):
14161434
self.type = 'voice'
14171435
self.id = id
14181436
self.voice_url = voice_url
14191437
self.title = title
14201438
self.caption = caption
1439+
self.parse_mode = parse_mode
14211440
self.performer = performer
14221441
self.voice_duration = voice_duration
14231442
self.reply_markup = reply_markup
@@ -1427,6 +1446,8 @@ def to_json(self):
14271446
json_dict = {'type': self.type, 'id': self.id, 'voice_url': self.voice_url, 'title': self.title}
14281447
if self.caption:
14291448
json_dict['caption'] = self.caption
1449+
if self.parse_mode:
1450+
json_dict['parse_mode'] = self.parse_mode
14301451
if self.performer:
14311452
json_dict['performer'] = self.performer
14321453
if self.voice_duration:
@@ -1439,14 +1460,15 @@ def to_json(self):
14391460

14401461

14411462
class InlineQueryResultDocument(JsonSerializable):
1442-
def __init__(self, id, title, document_url, mime_type, caption=None, description=None, reply_markup=None,
1443-
input_message_content=None, thumb_url=None, thumb_width=None, thumb_height=None):
1463+
def __init__(self, id, title, document_url, mime_type, caption=None, parse_mode=None, description=None,
1464+
reply_markup=None, input_message_content=None, thumb_url=None, thumb_width=None, thumb_height=None):
14441465
self.type = 'document'
14451466
self.id = id
14461467
self.title = title
14471468
self.document_url = document_url
14481469
self.mime_type = mime_type
14491470
self.caption = caption
1471+
self.parse_mode = parse_mode
14501472
self.description = description
14511473
self.reply_markup = reply_markup
14521474
self.input_message_content = input_message_content
@@ -1459,6 +1481,8 @@ def to_json(self):
14591481
'mime_type': self.mime_type}
14601482
if self.caption:
14611483
json_dict['caption'] = self.caption
1484+
if self.parse_mode:
1485+
json_dict['parse_mode'] = self.parse_mode
14621486
if self.description:
14631487
json_dict['description'] = self.description
14641488
if self.thumb_url:
@@ -1601,8 +1625,8 @@ def to_json(self):
16011625

16021626

16031627
class InlineQueryResultCachedPhoto(BaseInlineQueryResultCached):
1604-
def __init__(self, id, photo_file_id, title=None, description=None, caption=None, reply_markup=None,
1605-
input_message_content=None):
1628+
def __init__(self, id, photo_file_id, title=None, description=None, caption=None, parse_mode=None,
1629+
reply_markup=None, input_message_content=None):
16061630
BaseInlineQueryResultCached.__init__(self)
16071631
self.type = 'photo'
16081632
self.id = id
@@ -1613,10 +1637,11 @@ def __init__(self, id, photo_file_id, title=None, description=None, caption=None
16131637
self.reply_markup = reply_markup
16141638
self.input_message_content = input_message_content
16151639
self.payload_dic['photo_file_id'] = photo_file_id
1640+
self.payload_dic['parse_mode'] = parse_mode
16161641

16171642

16181643
class InlineQueryResultCachedGif(BaseInlineQueryResultCached):
1619-
def __init__(self, id, gif_file_id, title=None, description=None, caption=None, reply_markup=None,
1644+
def __init__(self, id, gif_file_id, title=None, description=None, caption=None, parse_mode=None, reply_markup=None,
16201645
input_message_content=None):
16211646
BaseInlineQueryResultCached.__init__(self)
16221647
self.type = 'gif'
@@ -1628,11 +1653,12 @@ def __init__(self, id, gif_file_id, title=None, description=None, caption=None,
16281653
self.reply_markup = reply_markup
16291654
self.input_message_content = input_message_content
16301655
self.payload_dic['gif_file_id'] = gif_file_id
1656+
self.payload_dic['parse_mode'] = parse_mode
16311657

16321658

16331659
class InlineQueryResultCachedMpeg4Gif(BaseInlineQueryResultCached):
1634-
def __init__(self, id, mpeg4_file_id, title=None, description=None, caption=None, reply_markup=None,
1635-
input_message_content=None):
1660+
def __init__(self, id, mpeg4_file_id, title=None, description=None, caption=None, parse_mode=None,
1661+
reply_markup=None, input_message_content=None):
16361662
BaseInlineQueryResultCached.__init__(self)
16371663
self.type = 'mpeg4_gif'
16381664
self.id = id
@@ -1643,6 +1669,7 @@ def __init__(self, id, mpeg4_file_id, title=None, description=None, caption=None
16431669
self.reply_markup = reply_markup
16441670
self.input_message_content = input_message_content
16451671
self.payload_dic['mpeg4_file_id'] = mpeg4_file_id
1672+
self.payload_dic['parse_mode'] = parse_mode
16461673

16471674

16481675
class InlineQueryResultCachedSticker(BaseInlineQueryResultCached):
@@ -1657,7 +1684,7 @@ def __init__(self, id, sticker_file_id, reply_markup=None, input_message_content
16571684

16581685

16591686
class InlineQueryResultCachedDocument(BaseInlineQueryResultCached):
1660-
def __init__(self, id, document_file_id, title, description=None, caption=None, reply_markup=None,
1687+
def __init__(self, id, document_file_id, title, description=None, caption=None, parse_mode=None, reply_markup=None,
16611688
input_message_content=None):
16621689
BaseInlineQueryResultCached.__init__(self)
16631690
self.type = 'document'
@@ -1669,10 +1696,11 @@ def __init__(self, id, document_file_id, title, description=None, caption=None,
16691696
self.reply_markup = reply_markup
16701697
self.input_message_content = input_message_content
16711698
self.payload_dic['document_file_id'] = document_file_id
1699+
self.payload_dic['parse_mode'] = parse_mode
16721700

16731701

16741702
class InlineQueryResultCachedVideo(BaseInlineQueryResultCached):
1675-
def __init__(self, id, video_file_id, title, description=None, caption=None, reply_markup=None,
1703+
def __init__(self, id, video_file_id, title, description=None, caption=None, parse_mode=None, reply_markup=None,
16761704
input_message_content=None):
16771705
BaseInlineQueryResultCached.__init__(self)
16781706
self.type = 'video'
@@ -1684,10 +1712,12 @@ def __init__(self, id, video_file_id, title, description=None, caption=None, rep
16841712
self.reply_markup = reply_markup
16851713
self.input_message_content = input_message_content
16861714
self.payload_dic['video_file_id'] = video_file_id
1715+
self.payload_dic['parse_mode'] = parse_mode
16871716

16881717

16891718
class InlineQueryResultCachedVoice(BaseInlineQueryResultCached):
1690-
def __init__(self, id, voice_file_id, title, caption=None, reply_markup=None, input_message_content=None):
1719+
def __init__(self, id, voice_file_id, title, caption=None, parse_mode=None, reply_markup=None,
1720+
input_message_content=None):
16911721
BaseInlineQueryResultCached.__init__(self)
16921722
self.type = 'voice'
16931723
self.id = id
@@ -1697,10 +1727,11 @@ def __init__(self, id, voice_file_id, title, caption=None, reply_markup=None, in
16971727
self.reply_markup = reply_markup
16981728
self.input_message_content = input_message_content
16991729
self.payload_dic['voice_file_id'] = voice_file_id
1730+
self.payload_dic['parse_mode'] = parse_mode
17001731

17011732

17021733
class InlineQueryResultCachedAudio(BaseInlineQueryResultCached):
1703-
def __init__(self, id, audio_file_id, caption=None, reply_markup=None, input_message_content=None):
1734+
def __init__(self, id, audio_file_id, caption=None, parse_mode=None, reply_markup=None, input_message_content=None):
17041735
BaseInlineQueryResultCached.__init__(self)
17051736
self.type = 'audio'
17061737
self.id = id
@@ -1709,6 +1740,7 @@ def __init__(self, id, audio_file_id, caption=None, reply_markup=None, input_mes
17091740
self.reply_markup = reply_markup
17101741
self.input_message_content = input_message_content
17111742
self.payload_dic['audio_file_id'] = audio_file_id
1743+
self.payload_dic['parse_mode'] = parse_mode
17121744

17131745

17141746
# Games

0 commit comments

Comments
 (0)