diff --git a/.travis.yml b/.travis.yml index b00b8eaf0..0f4c7de8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ python: - "3.5" - "3.6" - "pypy-5.7.1" - - "pypy3.5-5.8.0" + - "pypy3.5-5.10.0" dist: trusty sudo: false @@ -35,4 +35,4 @@ script: after_success: - coverage combine - - codecov -F Travis \ No newline at end of file + - codecov -F Travis diff --git a/telegram/bot.py b/telegram/bot.py index 55e17a60c..22dd20d49 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -339,6 +339,7 @@ class Bot(TelegramObject): reply_to_message_id=None, reply_markup=None, timeout=20, + parse_mode=None, **kwargs): """Use this method to send photos. @@ -356,6 +357,9 @@ class Bot(TelegramObject): an existing :class:`telegram.PhotoSize` object to send. caption (:obj:`str`, optional): Photo caption (may also be used when resending photos by file_id), 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to + show bold, italic, fixed-width text or inline URLs in the media caption. See the + constants in :class:`telegram.ParseMode` for the available modes. disable_notification (:obj:`bool`, optional): Sends the message silently. Users will receive a notification with no sound. reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the @@ -382,6 +386,8 @@ class Bot(TelegramObject): if caption: data['caption'] = caption + if parse_mode: + data['parse_mode'] = parse_mode return url, data @@ -398,6 +404,7 @@ class Bot(TelegramObject): reply_to_message_id=None, reply_markup=None, timeout=20, + parse_mode=None, **kwargs): """ Use this method to send audio files, if you want Telegram clients to display them in the @@ -420,6 +427,9 @@ class Bot(TelegramObject): the Internet, or upload a new one using multipart/form-data. Lastly you can pass an existing :class:`telegram.Audio` object to send. caption (:obj:`str`, optional): Audio caption, 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to + show bold, italic, fixed-width text or inline URLs in the media caption. See the + constants in :class:`telegram.ParseMode` for the available modes. duration (:obj:`int`, optional): Duration of sent audio in seconds. performer (:obj:`str`, optional): Performer. title (:obj:`str`, optional): Track name. @@ -455,6 +465,8 @@ class Bot(TelegramObject): data['title'] = title if caption: data['caption'] = caption + if parse_mode: + data['parse_mode'] = parse_mode return url, data @@ -469,6 +481,7 @@ class Bot(TelegramObject): reply_to_message_id=None, reply_markup=None, timeout=20, + parse_mode=None, **kwargs): """Use this method to send general files. @@ -488,6 +501,9 @@ class Bot(TelegramObject): when you send file generated by temp module, for example). Undocumented. caption (:obj:`str`, optional): Document caption (may also be used when resending documents by file_id), 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to + show bold, italic, fixed-width text or inline URLs in the media caption. See the + constants in :class:`telegram.ParseMode` for the available modes. disable_notification (:obj:`bool`, optional): Sends the message silently. Users will receive a notification with no sound. reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the @@ -516,6 +532,8 @@ class Bot(TelegramObject): data['filename'] = filename if caption: data['caption'] = caption + if parse_mode: + data['parse_mode'] = parse_mode return url, data @@ -582,6 +600,8 @@ class Bot(TelegramObject): timeout=20, width=None, height=None, + parse_mode=None, + supports_streaming=None, **kwargs): """ Use this method to send video files, Telegram clients support mp4 videos @@ -604,6 +624,11 @@ class Bot(TelegramObject): height (:obj:`int`, optional): Video height. caption (:obj:`str`, optional): Video caption (may also be used when resending videos by file_id), 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to + show bold, italic, fixed-width text or inline URLs in the media caption. See the + constants in :class:`telegram.ParseMode` for the available modes. + supports_streaming (:obj:`bool`, optional): Pass True, if the uploaded video is + suitable for streaming. disable_notification (:obj:`bool`, optional): Sends the message silently. Users will receive a notification with no sound. reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the @@ -632,6 +657,10 @@ class Bot(TelegramObject): data['duration'] = duration if caption: data['caption'] = caption + if parse_mode: + data['parse_mode'] = parse_mode + if supports_streaming: + data['supports_streaming'] = supports_streaming if width: data['width'] = width if height: @@ -650,6 +679,7 @@ class Bot(TelegramObject): reply_to_message_id=None, reply_markup=None, timeout=20, + parse_mode=None, **kwargs): """ Use this method to send audio files, if you want Telegram clients to display the file @@ -669,6 +699,9 @@ class Bot(TelegramObject): the Internet, or upload a new one using multipart/form-data. Lastly you can pass an existing :class:`telegram.Voice` object to send. caption (:obj:`str`, optional): Voice message caption, 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to + show bold, italic, fixed-width text or inline URLs in the media caption. See the + constants in :class:`telegram.ParseMode` for the available modes. duration (:obj:`int`, optional): Duration of the voice message in seconds. disable_notification (:obj:`bool`, optional): Sends the message silently. Users will receive a notification with no sound. @@ -698,6 +731,8 @@ class Bot(TelegramObject): data['duration'] = duration if caption: data['caption'] = caption + if parse_mode: + data['parse_mode'] = parse_mode return url, data @@ -1504,6 +1539,8 @@ class Bot(TelegramObject): parse_mode (:obj:`str`): Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. See the constants in :class:`telegram.ParseMode` for the available modes. + disable_web_page_preview (:obj:`bool`, optional): Disables link previews for links in + this message. reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. @@ -1546,6 +1583,7 @@ class Bot(TelegramObject): caption=None, reply_markup=None, timeout=None, + parse_mode=None, **kwargs): """ Use this method to edit captions of messages sent by the bot or via the bot @@ -1559,6 +1597,9 @@ class Bot(TelegramObject): inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not specified. Identifier of the inline message. caption (:obj:`str`, optional): New caption of the message. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to + show bold, italic, fixed-width text or inline URLs in the media caption. See the + constants in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. @@ -1586,6 +1627,8 @@ class Bot(TelegramObject): if caption: data['caption'] = caption + if parse_mode: + data['parse_mode'] = parse_mode if chat_id: data['chat_id'] = chat_id if message_id: diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index 41c74507d..0f244da14 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -346,13 +346,23 @@ class Filters(object): pinned_message = _PinnedMessage() """:obj:`Filter`: Messages that contain :attr:`telegram.Message.pinned_message`.""" + class _ConnectedWebsite(BaseFilter): + name = 'Filters.status_update.connected_website' + + def filter(self, message): + return bool(message.connected_website) + + connected_website = _ConnectedWebsite() + """:obj:`Filter`: Messages that contain :attr:`telegram.Message.connected_website`.""" + name = 'Filters.status_update' def filter(self, message): return bool(self.new_chat_members(message) or self.left_chat_member(message) or self.new_chat_title(message) or self.new_chat_photo(message) or self.delete_chat_photo(message) or self.chat_created(message) or - self.migrate(message) or self.pinned_message(message)) + self.migrate(message) or self.pinned_message(message) or + self.connected_website(message)) status_update = _StatusUpdate() """Subset for messages containing a status update. diff --git a/telegram/files/inputmediaphoto.py b/telegram/files/inputmediaphoto.py index b280217ce..9e3f4d985 100644 --- a/telegram/files/inputmediaphoto.py +++ b/telegram/files/inputmediaphoto.py @@ -29,12 +29,18 @@ class InputMediaPhoto(InputMedia): Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet. Lastly you can pass an existing :class:`telegram.PhotoSize` object to send. caption (:obj:`str`): Optional. Caption of the photo to be sent, 0-200 characters. + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. Args: media (:obj:`str`): File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet. Lastly you can pass an existing :class:`telegram.PhotoSize` object to send. caption (:obj:`str`, optional ): Caption of the photo to be sent, 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. Note: At the moment using a new file is not yet supported. @@ -42,7 +48,7 @@ class InputMediaPhoto(InputMedia): # TODO: Make InputMediaPhoto, InputMediaVideo and send_media_group work with new files - def __init__(self, media, caption=None): + def __init__(self, media, caption=None, parse_mode=None): self.type = 'photo' if isinstance(media, PhotoSize): @@ -55,3 +61,5 @@ class InputMediaPhoto(InputMedia): if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode diff --git a/telegram/files/inputmediavideo.py b/telegram/files/inputmediavideo.py index cdb274e54..977c7ea39 100644 --- a/telegram/files/inputmediavideo.py +++ b/telegram/files/inputmediavideo.py @@ -29,18 +29,28 @@ class InputMediaVideo(InputMedia): servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet. Lastly you can pass an existing :class:`telegram.Video` object to send. caption (:obj:`str`): Optional. Caption of the video to be sent, 0-200 characters. + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. width (:obj:`int`): Optional. Video width. height (:obj:`int`): Optional. Video height. duration (:obj:`int`): Optional. Video duration. + supports_streaming (:obj:`bool`): Optional. Pass True, if the uploaded video is suitable + for streaming. Args: media (:obj:`str`): File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet. Lastly you can pass an existing :class:`telegram.Video` object to send. caption (:obj:`str`, optional): Caption of the video to be sent, 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. width (:obj:`int`, optional): Video width. height (:obj:`int`, optional): Video height. duration (:obj:`int`, optional): Video duration. + supports_streaming (:obj:`bool`, optional): Pass True, if the uploaded video is suitable + for streaming. Note: When using a :class:`telegram.Video` for the :attr:`media` attribute. It will take the @@ -51,7 +61,8 @@ class InputMediaVideo(InputMedia): # TODO: Make InputMediaPhoto, InputMediaVideo and send_media_group work with new files - def __init__(self, media, caption=None, width=None, height=None, duration=None): + def __init__(self, media, caption=None, width=None, height=None, duration=None, + supports_streaming=None, parse_mode=None): self.type = 'video' if isinstance(media, Video): @@ -66,9 +77,13 @@ class InputMediaVideo(InputMedia): if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if width: self.width = width if height: self.height = height if duration: self.duration = duration + if supports_streaming: + self.supports_streaming = supports_streaming diff --git a/telegram/inline/inlinequeryresultaudio.py b/telegram/inline/inlinequeryresultaudio.py index 267a5bdec..10b1cb9c2 100644 --- a/telegram/inline/inlinequeryresultaudio.py +++ b/telegram/inline/inlinequeryresultaudio.py @@ -35,6 +35,9 @@ class InlineQueryResultAudio(InlineQueryResult): performer (:obj:`str`): Optional. Caption, 0-200 characters. audio_duration (:obj:`str`): Optional. Performer. caption (:obj:`str`): Optional. Audio duration in seconds. + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -47,6 +50,9 @@ class InlineQueryResultAudio(InlineQueryResult): performer (:obj:`str`, optional): Caption, 0-200 characters. audio_duration (:obj:`str`, optional): Performer. caption (:obj:`str`, optional): Audio duration in seconds. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -64,6 +70,7 @@ class InlineQueryResultAudio(InlineQueryResult): caption=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required @@ -78,6 +85,8 @@ class InlineQueryResultAudio(InlineQueryResult): self.audio_duration = audio_duration if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultcachedaudio.py b/telegram/inline/inlinequeryresultcachedaudio.py index 90157bb7b..405274957 100644 --- a/telegram/inline/inlinequeryresultcachedaudio.py +++ b/telegram/inline/inlinequeryresultcachedaudio.py @@ -32,6 +32,9 @@ class InlineQueryResultCachedAudio(InlineQueryResult): id (:obj:`str`): Unique identifier for this result, 1-64 bytes. audio_file_id (:obj:`str`): A valid file identifier for the audio file. caption (:obj:`str`): Optional. Caption, 0-200 characters + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -41,6 +44,9 @@ class InlineQueryResultCachedAudio(InlineQueryResult): id (:obj:`str`): Unique identifier for this result, 1-64 bytes. audio_file_id (:obj:`str`): A valid file identifier for the audio file. caption (:obj:`str`, optional): Caption, 0-200 characters + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -55,6 +61,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult): caption=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required super(InlineQueryResultCachedAudio, self).__init__('audio', id) @@ -63,6 +70,8 @@ class InlineQueryResultCachedAudio(InlineQueryResult): # Optionals if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultcacheddocument.py b/telegram/inline/inlinequeryresultcacheddocument.py index 28e6f7f53..49816b522 100644 --- a/telegram/inline/inlinequeryresultcacheddocument.py +++ b/telegram/inline/inlinequeryresultcacheddocument.py @@ -34,6 +34,9 @@ class InlineQueryResultCachedDocument(InlineQueryResult): document_file_id (:obj:`str`): A valid file identifier for the file. description (:obj:`str`): Optional. Short description of the result. caption (:obj:`str`): Optional. Caption, 0-200 characters + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -45,6 +48,9 @@ class InlineQueryResultCachedDocument(InlineQueryResult): document_file_id (:obj:`str`): A valid file identifier for the file. description (:obj:`str`, optional): Short description of the result. caption (:obj:`str`, optional): Caption, 0-200 characters + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -61,6 +67,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult): caption=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required super(InlineQueryResultCachedDocument, self).__init__('document', id) @@ -72,6 +79,8 @@ class InlineQueryResultCachedDocument(InlineQueryResult): self.description = description if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultcachedgif.py b/telegram/inline/inlinequeryresultcachedgif.py index 7e0217bae..107031432 100644 --- a/telegram/inline/inlinequeryresultcachedgif.py +++ b/telegram/inline/inlinequeryresultcachedgif.py @@ -34,6 +34,9 @@ class InlineQueryResultCachedGif(InlineQueryResult): gif_file_id (:obj:`str`): A valid file identifier for the GIF file. title (:obj:`str`): Optional. Title for the result. caption (:obj:`str`): Optional. Caption, 0-200 characters + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -44,6 +47,9 @@ class InlineQueryResultCachedGif(InlineQueryResult): gif_file_id (:obj:`str`): A valid file identifier for the GIF file. title (:obj:`str`, optional): Title for the result.caption (:obj:`str`, optional): caption (:obj:`str`, optional): Caption, 0-200 characters + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -59,6 +65,7 @@ class InlineQueryResultCachedGif(InlineQueryResult): caption=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required super(InlineQueryResultCachedGif, self).__init__('gif', id) @@ -69,6 +76,8 @@ class InlineQueryResultCachedGif(InlineQueryResult): self.title = title if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultcachedmpeg4gif.py b/telegram/inline/inlinequeryresultcachedmpeg4gif.py index b047d8588..027241a24 100644 --- a/telegram/inline/inlinequeryresultcachedmpeg4gif.py +++ b/telegram/inline/inlinequeryresultcachedmpeg4gif.py @@ -34,6 +34,9 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): mpeg4_file_id (:obj:`str`): A valid file identifier for the MP4 file. title (:obj:`str`): Optional. Title for the result. caption (:obj:`str`): Optional. Caption, 0-200 characters + parse_mode (:obj:`str`): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -44,6 +47,9 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): mpeg4_file_id (:obj:`str`): A valid file identifier for the MP4 file. title (:obj:`str`, optional): Title for the result. caption (:obj:`str`, optional): Caption, 0-200 characters + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -59,6 +65,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): caption=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required super(InlineQueryResultCachedMpeg4Gif, self).__init__('mpeg4_gif', id) @@ -69,6 +76,8 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): self.title = title if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultcachedphoto.py b/telegram/inline/inlinequeryresultcachedphoto.py index 679f2052f..49742e4a0 100644 --- a/telegram/inline/inlinequeryresultcachedphoto.py +++ b/telegram/inline/inlinequeryresultcachedphoto.py @@ -35,6 +35,9 @@ class InlineQueryResultCachedPhoto(InlineQueryResult): title (:obj:`str`): Optional. Title for the result. description (:obj:`str`): Optional. Short description of the result. caption (:obj:`str`): Optional. Caption, 0-200 characters + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -46,6 +49,9 @@ class InlineQueryResultCachedPhoto(InlineQueryResult): title (:obj:`str`, optional): Title for the result. description (:obj:`str`, optional): Short description of the result. caption (:obj:`str`, optional): Caption, 0-200 characters + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -62,6 +68,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult): caption=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required super(InlineQueryResultCachedPhoto, self).__init__('photo', id) @@ -74,6 +81,8 @@ class InlineQueryResultCachedPhoto(InlineQueryResult): self.description = description if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultcachedvideo.py b/telegram/inline/inlinequeryresultcachedvideo.py index 8dac6157c..51006d9c5 100644 --- a/telegram/inline/inlinequeryresultcachedvideo.py +++ b/telegram/inline/inlinequeryresultcachedvideo.py @@ -35,6 +35,9 @@ class InlineQueryResultCachedVideo(InlineQueryResult): title (:obj:`str`): Title for the result. description (:obj:`str`): Optional. Short description of the result. caption (:obj:`str`): Optional. Caption, 0-200 characters. + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -46,6 +49,9 @@ class InlineQueryResultCachedVideo(InlineQueryResult): title (:obj:`str`): Title for the result. description (:obj:`str`, optional): Short description of the result. caption (:obj:`str`, optional): Caption, 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -62,6 +68,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult): caption=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required super(InlineQueryResultCachedVideo, self).__init__('video', id) @@ -73,6 +80,8 @@ class InlineQueryResultCachedVideo(InlineQueryResult): self.description = description if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultcachedvoice.py b/telegram/inline/inlinequeryresultcachedvoice.py index f5a5f0f6d..9247a9e39 100644 --- a/telegram/inline/inlinequeryresultcachedvoice.py +++ b/telegram/inline/inlinequeryresultcachedvoice.py @@ -33,6 +33,9 @@ class InlineQueryResultCachedVoice(InlineQueryResult): voice_file_id (:obj:`str`): A valid file identifier for the voice message. title (:obj:`str`): Voice message title. caption (:obj:`str`): Optional. Caption, 0-200 characters. + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -43,6 +46,9 @@ class InlineQueryResultCachedVoice(InlineQueryResult): voice_file_id (:obj:`str`): A valid file identifier for the voice message. title (:obj:`str`): Voice message title. caption (:obj:`str`, optional): Caption, 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -58,6 +64,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult): caption=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required super(InlineQueryResultCachedVoice, self).__init__('voice', id) @@ -67,6 +74,8 @@ class InlineQueryResultCachedVoice(InlineQueryResult): # Optionals if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultdocument.py b/telegram/inline/inlinequeryresultdocument.py index 6a7fa59c3..5dadcd63a 100644 --- a/telegram/inline/inlinequeryresultdocument.py +++ b/telegram/inline/inlinequeryresultdocument.py @@ -33,6 +33,9 @@ class InlineQueryResultDocument(InlineQueryResult): id (:obj:`str`): Unique identifier for this result, 1-64 bytes. title (:obj:`str`): Title for the result. caption (:obj:`str`): Optional. Caption, 0-200 characters + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. document_url (:obj:`str`): A valid URL for the file. mime_type (:obj:`str`): Mime type of the content of the file, either "application/pdf" or "application/zip". @@ -49,6 +52,9 @@ class InlineQueryResultDocument(InlineQueryResult): id (:obj:`str`): Unique identifier for this result, 1-64 bytes. title (:obj:`str`): Title for the result. caption (:obj:`str`, optional): Caption, 0-200 characters + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. document_url (:obj:`str`): A valid URL for the file. mime_type (:obj:`str`): Mime type of the content of the file, either "application/pdf" or "application/zip". @@ -76,6 +82,7 @@ class InlineQueryResultDocument(InlineQueryResult): thumb_url=None, thumb_width=None, thumb_height=None, + parse_mode=None, **kwargs): # Required super(InlineQueryResultDocument, self).__init__('document', id) @@ -86,6 +93,8 @@ class InlineQueryResultDocument(InlineQueryResult): # Optionals if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if description: self.description = description if reply_markup: diff --git a/telegram/inline/inlinequeryresultgif.py b/telegram/inline/inlinequeryresultgif.py index 8601d8209..410afda4f 100644 --- a/telegram/inline/inlinequeryresultgif.py +++ b/telegram/inline/inlinequeryresultgif.py @@ -37,6 +37,9 @@ class InlineQueryResultGif(InlineQueryResult): thumb_url (:obj:`str`): URL of the static thumbnail for the result (jpeg or gif). title (:obj:`str`): Optional. Title for the result. caption (:obj:`str`): Optional. Caption, 0-200 characters + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -51,6 +54,9 @@ class InlineQueryResultGif(InlineQueryResult): thumb_url (:obj:`str`): URL of the static thumbnail for the result (jpeg or gif). title (:obj:`str`, optional): Title for the result.caption (:obj:`str`, optional): caption (:obj:`str`, optional): Caption, 0-200 characters + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -70,6 +76,7 @@ class InlineQueryResultGif(InlineQueryResult): reply_markup=None, input_message_content=None, gif_duration=None, + parse_mode=None, **kwargs): # Required @@ -88,6 +95,8 @@ class InlineQueryResultGif(InlineQueryResult): self.title = title if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultmpeg4gif.py b/telegram/inline/inlinequeryresultmpeg4gif.py index 1d731fd3d..e00073812 100644 --- a/telegram/inline/inlinequeryresultmpeg4gif.py +++ b/telegram/inline/inlinequeryresultmpeg4gif.py @@ -38,6 +38,9 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): thumb_url (:obj:`str`): URL of the static thumbnail (jpeg or gif) for the result. title (:obj:`str`): Optional. Title for the result. caption (:obj:`str`): Optional. Caption, 0-200 characters + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -52,6 +55,9 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): thumb_url (:obj:`str`): URL of the static thumbnail (jpeg or gif) for the result. title (:obj:`str`, optional): Title for the result. caption (:obj:`str`, optional): Caption, 0-200 characters + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -71,6 +77,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): reply_markup=None, input_message_content=None, mpeg4_duration=None, + parse_mode=None, **kwargs): # Required @@ -89,6 +96,8 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): self.title = title if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultphoto.py b/telegram/inline/inlinequeryresultphoto.py index b4b078422..0b474e839 100644 --- a/telegram/inline/inlinequeryresultphoto.py +++ b/telegram/inline/inlinequeryresultphoto.py @@ -38,6 +38,9 @@ class InlineQueryResultPhoto(InlineQueryResult): title (:obj:`str`): Optional. Title for the result. description (:obj:`str`): Optional. Short description of the result. caption (:obj:`str`): Optional. Caption, 0-200 characters + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the @@ -53,6 +56,9 @@ class InlineQueryResultPhoto(InlineQueryResult): title (:obj:`str`, optional): Title for the result. description (:obj:`str`, optional): Short description of the result. caption (:obj:`str`, optional): Caption, 0-200 characters + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the @@ -72,6 +78,7 @@ class InlineQueryResultPhoto(InlineQueryResult): caption=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required super(InlineQueryResultPhoto, self).__init__('photo', id) @@ -89,6 +96,8 @@ class InlineQueryResultPhoto(InlineQueryResult): self.description = description if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/inline/inlinequeryresultvideo.py b/telegram/inline/inlinequeryresultvideo.py index 026e74bf1..a55161d22 100644 --- a/telegram/inline/inlinequeryresultvideo.py +++ b/telegram/inline/inlinequeryresultvideo.py @@ -36,6 +36,9 @@ class InlineQueryResultVideo(InlineQueryResult): thumb_url (:obj:`str`): URL of the thumbnail (jpeg only) for the video. title (:obj:`str`): Title for the result. caption (:obj:`str`): Optional. Caption, 0-200 characters + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. video_width (:obj:`int`): Optional. Video width. video_height (:obj:`int`): Optional. Video height. video_duration (:obj:`int`): Optional. Video duration in seconds. @@ -52,6 +55,9 @@ class InlineQueryResultVideo(InlineQueryResult): thumb_url (:obj:`str`): URL of the thumbnail (jpeg only) for the video. title (:obj:`str`): Title for the result. caption (:obj:`str`, optional): Caption, 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. video_width (:obj:`int`, optional): Video width. video_height (:obj:`int`, optional): Video height. video_duration (:obj:`int`, optional): Video duration in seconds. @@ -77,6 +83,7 @@ class InlineQueryResultVideo(InlineQueryResult): description=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required @@ -89,6 +96,8 @@ class InlineQueryResultVideo(InlineQueryResult): # Optional if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if video_width: self.video_width = video_width if video_height: diff --git a/telegram/inline/inlinequeryresultvoice.py b/telegram/inline/inlinequeryresultvoice.py index aa57e84c6..817eca4bc 100644 --- a/telegram/inline/inlinequeryresultvoice.py +++ b/telegram/inline/inlinequeryresultvoice.py @@ -34,6 +34,9 @@ class InlineQueryResultVoice(InlineQueryResult): voice_url (:obj:`str`): A valid URL for the voice recording. title (:obj:`str`): Voice message title. caption (:obj:`str`): Optional. Caption, 0-200 characters. + parse_mode (:obj:`str`): Optional. Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. voice_duration (:obj:`int`): Optional. Recording duration in seconds. reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. @@ -45,6 +48,9 @@ class InlineQueryResultVoice(InlineQueryResult): voice_url (:obj:`str`): A valid URL for the voice recording. title (:obj:`str`): Voice message title. caption (:obj:`str`, optional): Caption, 0-200 characters. + parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show + bold, italic, fixed-width text or inline URLs in the media caption.. See the constants + in :class:`telegram.ParseMode` for the available modes. voice_duration (:obj:`int`, optional): Recording duration in seconds. reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. @@ -62,6 +68,7 @@ class InlineQueryResultVoice(InlineQueryResult): caption=None, reply_markup=None, input_message_content=None, + parse_mode=None, **kwargs): # Required @@ -74,6 +81,8 @@ class InlineQueryResultVoice(InlineQueryResult): self.voice_duration = voice_duration if caption: self.caption = caption + if parse_mode: + self.parse_mode = parse_mode if reply_markup: self.reply_markup = reply_markup if input_message_content: diff --git a/telegram/message.py b/telegram/message.py index ec7d430e7..c4686fa07 100644 --- a/telegram/message.py +++ b/telegram/message.py @@ -91,6 +91,8 @@ class Message(TelegramObject): invoice (:class:`telegram.Invoice`): Optional. Information about the invoice. successful_payment (:class:`telegram.SuccessfulPayment`): Optional. Information about the payment. + connected_website (:obj:`str`): Optional. The domain name of the website on which the user + has logged in. forward_signature (:obj:`str`): Optional. Signature of the post author for messages forwarded from channels. author_signature (:obj:`str`): Optional. Signature of the post author for messages @@ -187,6 +189,8 @@ class Message(TelegramObject): information about the invoice. successful_payment (:class:`telegram.SuccessfulPayment`, optional): Message is a service message about a successful payment, information about the payment. + connected_website (:obj:`str`, optional): The domain name of the website on which the user + has logged in. forward_signature (:obj:`str`, optional): Signature of the post author for messages forwarded from channels. author_signature (:obj:`str`, optional): Signature of the post author for messages @@ -246,6 +250,7 @@ class Message(TelegramObject): forward_signature=None, author_signature=None, media_group_id=None, + connected_website=None, bot=None, **kwargs): # Required @@ -289,6 +294,7 @@ class Message(TelegramObject): self.forward_from_message_id = forward_from_message_id self.invoice = invoice self.successful_payment = successful_payment + self.connected_website = connected_website self.forward_signature = forward_signature self.author_signature = author_signature self.media_group_id = media_group_id diff --git a/tests/test_audio.py b/tests/test_audio.py index 94f7053fe..138cbc4a1 100644 --- a/tests/test_audio.py +++ b/tests/test_audio.py @@ -38,7 +38,7 @@ def audio(bot, chat_id): class TestAudio(object): - caption = 'Test audio' + caption = 'Test *audio*' performer = 'Leandro Toledo' title = 'Teste' duration = 3 @@ -66,9 +66,10 @@ class TestAudio(object): def test_send_all_args(self, bot, chat_id, audio_file): message = bot.send_audio(chat_id, audio=audio_file, caption=self.caption, duration=self.duration, performer=self.performer, - title=self.title, disable_notification=False) + title=self.title, disable_notification=False, + parse_mode='Markdown') - assert message.caption == self.caption + assert message.caption == self.caption.replace('*', '') assert isinstance(message.audio, Audio) assert isinstance(message.audio.file_id, str) diff --git a/tests/test_bot.py b/tests/test_bot.py index b9800ef3e..ecf4fde2b 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -258,6 +258,15 @@ class TestBot(object): assert message.caption == 'new_caption' + @flaky(3, 1) + @pytest.mark.timeout(10) + def test_edit_message_caption_with_parse_mode(self, bot, media_message): + message = bot.edit_message_caption(caption='new *caption*', parse_mode='Markdown', + chat_id=media_message.chat_id, + message_id=media_message.message_id) + + assert message.caption == 'new caption' + @pytest.mark.xfail(raises=TelegramError) # TODO: remove when #744 is merged def test_edit_message_caption_without_required(self, bot): with pytest.raises(ValueError, match='Both chat_id and message_id are required when'): diff --git a/tests/test_constants.py b/tests/test_constants.py index 0aba0fc63..056c1f6ae 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -42,7 +42,6 @@ class TestConstants(object): assert good_msg.caption == good_caption bad_caption = good_caption + 'Z' - with open('tests/data/telegram.png', 'rb') as f: - bad_message = bot.send_photo(photo=f, caption=bad_caption, chat_id=chat_id) - assert bad_message.caption != bad_caption - assert len(bad_message.caption) == constants.MAX_CAPTION_LENGTH + with pytest.raises(BadRequest, message="Media_caption_too_long"): + with open('tests/data/telegram.png', 'rb') as f: + bad_message = bot.send_photo(photo=f, caption=bad_caption, chat_id=chat_id) diff --git a/tests/test_document.py b/tests/test_document.py index fdfaa7c89..065b1c195 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -38,7 +38,7 @@ def document(bot, chat_id): class TestDocument(object): - caption = 'DocumentTest - Caption' + caption = 'DocumentTest - *Caption*' document_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.gif' file_size = 12948 mime_type = 'image/png' @@ -64,7 +64,8 @@ class TestDocument(object): @pytest.mark.timeout(10) def test_send_all_args(self, bot, chat_id, document_file, document): message = bot.send_document(chat_id, document=document_file, caption=self.caption, - disable_notification=False, filename='telegram_custom.png') + disable_notification=False, filename='telegram_custom.png', + parse_mode='Markdown') assert isinstance(message.document, Document) assert isinstance(message.document.file_id, str) @@ -74,7 +75,7 @@ class TestDocument(object): assert message.document.mime_type == document.mime_type assert message.document.file_size == document.file_size assert message.document.thumb == document.thumb - assert message.caption == self.caption + assert message.caption == self.caption.replace('*', '') @flaky(3, 1) @pytest.mark.timeout(10) diff --git a/tests/test_filters.py b/tests/test_filters.py index a6163b80b..74cd0f29a 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -162,6 +162,11 @@ class TestFilters(object): assert Filters.status_update.pinned_message(message) message.pinned_message = None + message.connected_website = 'http://example.com/' + assert Filters.status_update(message) + assert Filters.status_update.connected_website(message) + message.connected_website = None + def test_filters_forwarded(self, message): assert not Filters.forwarded(message) message.forward_date = 'test' diff --git a/tests/test_inlinequeryresultaudio.py b/tests/test_inlinequeryresultaudio.py index b46e76793..4e64d9746 100644 --- a/tests/test_inlinequeryresultaudio.py +++ b/tests/test_inlinequeryresultaudio.py @@ -31,6 +31,7 @@ def inline_query_result_audio(): performer=TestInlineQueryResultAudio.performer, audio_duration=TestInlineQueryResultAudio.audio_duration, caption=TestInlineQueryResultAudio.caption, + parse_mode=TestInlineQueryResultAudio.parse_mode, input_message_content=TestInlineQueryResultAudio.input_message_content, reply_markup=TestInlineQueryResultAudio.reply_markup) @@ -43,6 +44,7 @@ class TestInlineQueryResultAudio(object): performer = 'performer' audio_duration = 'audio_duration' caption = 'caption' + parse_mode = 'Markdown' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -54,6 +56,7 @@ class TestInlineQueryResultAudio(object): assert inline_query_result_audio.performer == self.performer assert inline_query_result_audio.audio_duration == self.audio_duration assert inline_query_result_audio.caption == self.caption + assert inline_query_result_audio.parse_mode == self.parse_mode assert inline_query_result_audio.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_audio.reply_markup.to_dict() == self.reply_markup.to_dict() @@ -70,6 +73,7 @@ class TestInlineQueryResultAudio(object): assert inline_query_result_audio_dict['audio_duration'] == \ inline_query_result_audio.audio_duration assert inline_query_result_audio_dict['caption'] == inline_query_result_audio.caption + assert inline_query_result_audio_dict['parse_mode'] == inline_query_result_audio.parse_mode assert inline_query_result_audio_dict['input_message_content'] == \ inline_query_result_audio.input_message_content.to_dict() assert inline_query_result_audio_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultcachedaudio.py b/tests/test_inlinequeryresultcachedaudio.py index 16f855a49..5eba603a9 100644 --- a/tests/test_inlinequeryresultcachedaudio.py +++ b/tests/test_inlinequeryresultcachedaudio.py @@ -28,6 +28,7 @@ def inline_query_result_cached_audio(): return InlineQueryResultCachedAudio(TestInlineQueryResultCachedAudio.id, TestInlineQueryResultCachedAudio.audio_file_id, caption=TestInlineQueryResultCachedAudio.caption, + parse_mode=TestInlineQueryResultCachedAudio.parse_mode, input_message_content=TestInlineQueryResultCachedAudio.input_message_content, reply_markup=TestInlineQueryResultCachedAudio.reply_markup) @@ -37,6 +38,7 @@ class TestInlineQueryResultCachedAudio(object): type = 'audio' audio_file_id = 'audio file id' caption = 'caption' + parse_mode = 'HTML' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -45,6 +47,7 @@ class TestInlineQueryResultCachedAudio(object): assert inline_query_result_cached_audio.id == self.id assert inline_query_result_cached_audio.audio_file_id == self.audio_file_id assert inline_query_result_cached_audio.caption == self.caption + assert inline_query_result_cached_audio.parse_mode == self.parse_mode assert inline_query_result_cached_audio.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_cached_audio.reply_markup.to_dict() == \ @@ -61,6 +64,8 @@ class TestInlineQueryResultCachedAudio(object): inline_query_result_cached_audio.audio_file_id assert inline_query_result_cached_audio_dict['caption'] == \ inline_query_result_cached_audio.caption + assert inline_query_result_cached_audio_dict['parse_mode'] == \ + inline_query_result_cached_audio.parse_mode assert inline_query_result_cached_audio_dict['input_message_content'] == \ inline_query_result_cached_audio.input_message_content.to_dict() assert inline_query_result_cached_audio_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultcacheddocument.py b/tests/test_inlinequeryresultcacheddocument.py index 732f94519..1206a5852 100644 --- a/tests/test_inlinequeryresultcacheddocument.py +++ b/tests/test_inlinequeryresultcacheddocument.py @@ -29,6 +29,7 @@ def inline_query_result_cached_document(): TestInlineQueryResultCachedDocument.title, TestInlineQueryResultCachedDocument.document_file_id, caption=TestInlineQueryResultCachedDocument.caption, + parse_mode=TestInlineQueryResultCachedDocument.parse_mode, description=TestInlineQueryResultCachedDocument.description, input_message_content=TestInlineQueryResultCachedDocument.input_message_content, reply_markup=TestInlineQueryResultCachedDocument.reply_markup) @@ -40,6 +41,7 @@ class TestInlineQueryResultCachedDocument(object): document_file_id = 'document file id' title = 'title' caption = 'caption' + parse_mode = 'Markdown' description = 'description' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -50,6 +52,7 @@ class TestInlineQueryResultCachedDocument(object): assert inline_query_result_cached_document.document_file_id == self.document_file_id assert inline_query_result_cached_document.title == self.title assert inline_query_result_cached_document.caption == self.caption + assert inline_query_result_cached_document.parse_mode == self.parse_mode assert inline_query_result_cached_document.description == self.description assert inline_query_result_cached_document.input_message_content.to_dict() == \ self.input_message_content.to_dict() @@ -70,6 +73,8 @@ class TestInlineQueryResultCachedDocument(object): inline_query_result_cached_document.title assert inline_query_result_cached_document_dict['caption'] == \ inline_query_result_cached_document.caption + assert inline_query_result_cached_document_dict['parse_mode'] == \ + inline_query_result_cached_document.parse_mode assert inline_query_result_cached_document_dict['description'] == \ inline_query_result_cached_document.description assert inline_query_result_cached_document_dict['input_message_content'] == \ diff --git a/tests/test_inlinequeryresultcachedgif.py b/tests/test_inlinequeryresultcachedgif.py index 658b12fac..2165b8b0e 100644 --- a/tests/test_inlinequeryresultcachedgif.py +++ b/tests/test_inlinequeryresultcachedgif.py @@ -29,6 +29,7 @@ def inline_query_result_cached_gif(): TestInlineQueryResultCachedGif.gif_file_id, title=TestInlineQueryResultCachedGif.title, caption=TestInlineQueryResultCachedGif.caption, + parse_mode=TestInlineQueryResultCachedGif.parse_mode, input_message_content=TestInlineQueryResultCachedGif.input_message_content, reply_markup=TestInlineQueryResultCachedGif.reply_markup) @@ -39,6 +40,7 @@ class TestInlineQueryResultCachedGif(object): gif_file_id = 'gif file id' title = 'title' caption = 'caption' + parse_mode = 'HTML' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -48,6 +50,7 @@ class TestInlineQueryResultCachedGif(object): assert inline_query_result_cached_gif.gif_file_id == self.gif_file_id assert inline_query_result_cached_gif.title == self.title assert inline_query_result_cached_gif.caption == self.caption + assert inline_query_result_cached_gif.parse_mode == self.parse_mode assert inline_query_result_cached_gif.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_cached_gif.reply_markup.to_dict() == self.reply_markup.to_dict() @@ -63,6 +66,8 @@ class TestInlineQueryResultCachedGif(object): assert inline_query_result_cached_gif_dict['title'] == inline_query_result_cached_gif.title assert inline_query_result_cached_gif_dict['caption'] == \ inline_query_result_cached_gif.caption + assert inline_query_result_cached_gif_dict['parse_mode'] == \ + inline_query_result_cached_gif.parse_mode assert inline_query_result_cached_gif_dict['input_message_content'] == \ inline_query_result_cached_gif.input_message_content.to_dict() assert inline_query_result_cached_gif_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultcachedmpeg4gif.py b/tests/test_inlinequeryresultcachedmpeg4gif.py index 0a47fb848..799832c2f 100644 --- a/tests/test_inlinequeryresultcachedmpeg4gif.py +++ b/tests/test_inlinequeryresultcachedmpeg4gif.py @@ -29,6 +29,7 @@ def inline_query_result_cached_mpeg4_gif(): TestInlineQueryResultCachedMpeg4Gif.mpeg4_file_id, title=TestInlineQueryResultCachedMpeg4Gif.title, caption=TestInlineQueryResultCachedMpeg4Gif.caption, + parse_mode=TestInlineQueryResultCachedMpeg4Gif.parse_mode, input_message_content=TestInlineQueryResultCachedMpeg4Gif.input_message_content, reply_markup=TestInlineQueryResultCachedMpeg4Gif.reply_markup) @@ -39,6 +40,7 @@ class TestInlineQueryResultCachedMpeg4Gif(object): mpeg4_file_id = 'mpeg4 file id' title = 'title' caption = 'caption' + parse_mode = 'Markdown' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -48,6 +50,7 @@ class TestInlineQueryResultCachedMpeg4Gif(object): assert inline_query_result_cached_mpeg4_gif.mpeg4_file_id == self.mpeg4_file_id assert inline_query_result_cached_mpeg4_gif.title == self.title assert inline_query_result_cached_mpeg4_gif.caption == self.caption + assert inline_query_result_cached_mpeg4_gif.parse_mode == self.parse_mode assert inline_query_result_cached_mpeg4_gif.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_cached_mpeg4_gif.reply_markup.to_dict() == \ @@ -67,6 +70,8 @@ class TestInlineQueryResultCachedMpeg4Gif(object): inline_query_result_cached_mpeg4_gif.title assert inline_query_result_cached_mpeg4_gif_dict['caption'] == \ inline_query_result_cached_mpeg4_gif.caption + assert inline_query_result_cached_mpeg4_gif_dict['parse_mode'] == \ + inline_query_result_cached_mpeg4_gif.parse_mode assert inline_query_result_cached_mpeg4_gif_dict['input_message_content'] == \ inline_query_result_cached_mpeg4_gif.input_message_content.to_dict() assert inline_query_result_cached_mpeg4_gif_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultcachedphoto.py b/tests/test_inlinequeryresultcachedphoto.py index 18c07ffad..c61f0cc8d 100644 --- a/tests/test_inlinequeryresultcachedphoto.py +++ b/tests/test_inlinequeryresultcachedphoto.py @@ -30,6 +30,7 @@ def inline_query_result_cached_photo(): title=TestInlineQueryResultCachedPhoto.title, description=TestInlineQueryResultCachedPhoto.description, caption=TestInlineQueryResultCachedPhoto.caption, + parse_mode=TestInlineQueryResultCachedPhoto.parse_mode, input_message_content=TestInlineQueryResultCachedPhoto.input_message_content, reply_markup=TestInlineQueryResultCachedPhoto.reply_markup) @@ -41,6 +42,7 @@ class TestInlineQueryResultCachedPhoto(object): title = 'title' description = 'description' caption = 'caption' + parse_mode = 'HTML' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -51,6 +53,7 @@ class TestInlineQueryResultCachedPhoto(object): assert inline_query_result_cached_photo.title == self.title assert inline_query_result_cached_photo.description == self.description assert inline_query_result_cached_photo.caption == self.caption + assert inline_query_result_cached_photo.parse_mode == self.parse_mode assert inline_query_result_cached_photo.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_cached_photo.reply_markup.to_dict() == \ @@ -71,6 +74,8 @@ class TestInlineQueryResultCachedPhoto(object): inline_query_result_cached_photo.description assert inline_query_result_cached_photo_dict['caption'] == \ inline_query_result_cached_photo.caption + assert inline_query_result_cached_photo_dict['parse_mode'] == \ + inline_query_result_cached_photo.parse_mode assert inline_query_result_cached_photo_dict['input_message_content'] == \ inline_query_result_cached_photo.input_message_content.to_dict() assert inline_query_result_cached_photo_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultcachedvideo.py b/tests/test_inlinequeryresultcachedvideo.py index 32d0b2066..91769c6ef 100644 --- a/tests/test_inlinequeryresultcachedvideo.py +++ b/tests/test_inlinequeryresultcachedvideo.py @@ -29,6 +29,7 @@ def inline_query_result_cached_video(): TestInlineQueryResultCachedVideo.video_file_id, TestInlineQueryResultCachedVideo.title, caption=TestInlineQueryResultCachedVideo.caption, + parse_mode=TestInlineQueryResultCachedVideo.parse_mode, description=TestInlineQueryResultCachedVideo.description, input_message_content=TestInlineQueryResultCachedVideo.input_message_content, reply_markup=TestInlineQueryResultCachedVideo.reply_markup) @@ -40,6 +41,7 @@ class TestInlineQueryResultCachedVideo(object): video_file_id = 'video file id' title = 'title' caption = 'caption' + parse_mode = 'Markdown' description = 'description' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -51,6 +53,7 @@ class TestInlineQueryResultCachedVideo(object): assert inline_query_result_cached_video.title == self.title assert inline_query_result_cached_video.description == self.description assert inline_query_result_cached_video.caption == self.caption + assert inline_query_result_cached_video.parse_mode == self.parse_mode assert inline_query_result_cached_video.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_cached_video.reply_markup.to_dict() == \ @@ -71,6 +74,8 @@ class TestInlineQueryResultCachedVideo(object): inline_query_result_cached_video.description assert inline_query_result_cached_video_dict['caption'] == \ inline_query_result_cached_video.caption + assert inline_query_result_cached_video_dict['parse_mode'] == \ + inline_query_result_cached_video.parse_mode assert inline_query_result_cached_video_dict['input_message_content'] == \ inline_query_result_cached_video.input_message_content.to_dict() assert inline_query_result_cached_video_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultcachedvoice.py b/tests/test_inlinequeryresultcachedvoice.py index 5562b672b..75284bc07 100644 --- a/tests/test_inlinequeryresultcachedvoice.py +++ b/tests/test_inlinequeryresultcachedvoice.py @@ -29,6 +29,7 @@ def inline_query_result_cached_voice(): TestInlineQueryResultCachedVoice.voice_file_id, TestInlineQueryResultCachedVoice.title, caption=TestInlineQueryResultCachedVoice.caption, + parse_mode=TestInlineQueryResultCachedVoice.parse_mode, input_message_content=TestInlineQueryResultCachedVoice.input_message_content, reply_markup=TestInlineQueryResultCachedVoice.reply_markup) @@ -39,6 +40,7 @@ class TestInlineQueryResultCachedVoice(object): voice_file_id = 'voice file id' title = 'title' caption = 'caption' + parse_mode = 'HTML' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -48,6 +50,7 @@ class TestInlineQueryResultCachedVoice(object): assert inline_query_result_cached_voice.voice_file_id == self.voice_file_id assert inline_query_result_cached_voice.title == self.title assert inline_query_result_cached_voice.caption == self.caption + assert inline_query_result_cached_voice.parse_mode == self.parse_mode assert inline_query_result_cached_voice.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_cached_voice.reply_markup.to_dict() == \ @@ -66,6 +69,8 @@ class TestInlineQueryResultCachedVoice(object): inline_query_result_cached_voice.title assert inline_query_result_cached_voice_dict['caption'] == \ inline_query_result_cached_voice.caption + assert inline_query_result_cached_voice_dict['parse_mode'] == \ + inline_query_result_cached_voice.parse_mode assert inline_query_result_cached_voice_dict['input_message_content'] == \ inline_query_result_cached_voice.input_message_content.to_dict() assert inline_query_result_cached_voice_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultdocument.py b/tests/test_inlinequeryresultdocument.py index 40143e68a..0f831867c 100644 --- a/tests/test_inlinequeryresultdocument.py +++ b/tests/test_inlinequeryresultdocument.py @@ -30,6 +30,7 @@ def inline_query_result_document(): TestInlineQueryResultDocument.title, TestInlineQueryResultDocument.mime_type, caption=TestInlineQueryResultDocument.caption, + parse_mode=TestInlineQueryResultDocument.parse_mode, description=TestInlineQueryResultDocument.description, thumb_url=TestInlineQueryResultDocument.thumb_url, thumb_width=TestInlineQueryResultDocument.thumb_width, @@ -44,6 +45,7 @@ class TestInlineQueryResultDocument(object): document_url = 'document url' title = 'title' caption = 'caption' + parse_mode = 'Markdown' mime_type = 'mime type' description = 'description' thumb_url = 'thumb url' @@ -58,6 +60,7 @@ class TestInlineQueryResultDocument(object): assert inline_query_result_document.document_url == self.document_url assert inline_query_result_document.title == self.title assert inline_query_result_document.caption == self.caption + assert inline_query_result_document.parse_mode == self.parse_mode assert inline_query_result_document.mime_type == self.mime_type assert inline_query_result_document.description == self.description assert inline_query_result_document.thumb_url == self.thumb_url @@ -77,6 +80,8 @@ class TestInlineQueryResultDocument(object): inline_query_result_document.document_url assert inline_query_result_document_dict['title'] == inline_query_result_document.title assert inline_query_result_document_dict['caption'] == inline_query_result_document.caption + assert inline_query_result_document_dict['parse_mode'] == \ + inline_query_result_document.parse_mode assert inline_query_result_document_dict['mime_type'] == \ inline_query_result_document.mime_type assert inline_query_result_document_dict['description'] == \ diff --git a/tests/test_inlinequeryresultgif.py b/tests/test_inlinequeryresultgif.py index bd9cd1fc1..1cf24b62f 100644 --- a/tests/test_inlinequeryresultgif.py +++ b/tests/test_inlinequeryresultgif.py @@ -33,6 +33,7 @@ def inline_query_result_gif(): gif_duration=TestInlineQueryResultGif.gif_duration, title=TestInlineQueryResultGif.title, caption=TestInlineQueryResultGif.caption, + parse_mode=TestInlineQueryResultGif.parse_mode, input_message_content=TestInlineQueryResultGif.input_message_content, reply_markup=TestInlineQueryResultGif.reply_markup) @@ -47,6 +48,7 @@ class TestInlineQueryResultGif(object): thumb_url = 'thumb url' title = 'title' caption = 'caption' + parse_mode = 'HTML' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -60,6 +62,7 @@ class TestInlineQueryResultGif(object): assert inline_query_result_gif.thumb_url == self.thumb_url assert inline_query_result_gif.title == self.title assert inline_query_result_gif.caption == self.caption + assert inline_query_result_gif.parse_mode == self.parse_mode assert inline_query_result_gif.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_gif.reply_markup.to_dict() == self.reply_markup.to_dict() @@ -77,6 +80,7 @@ class TestInlineQueryResultGif(object): assert inline_query_result_gif_dict['thumb_url'] == inline_query_result_gif.thumb_url assert inline_query_result_gif_dict['title'] == inline_query_result_gif.title assert inline_query_result_gif_dict['caption'] == inline_query_result_gif.caption + assert inline_query_result_gif_dict['parse_mode'] == inline_query_result_gif.parse_mode assert inline_query_result_gif_dict['input_message_content'] == \ inline_query_result_gif.input_message_content.to_dict() assert inline_query_result_gif_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultmpeg4gif.py b/tests/test_inlinequeryresultmpeg4gif.py index 4bfa3dfa2..fab2a9f9b 100644 --- a/tests/test_inlinequeryresultmpeg4gif.py +++ b/tests/test_inlinequeryresultmpeg4gif.py @@ -33,6 +33,7 @@ def inline_query_result_mpeg4_gif(): mpeg4_duration=TestInlineQueryResultMpeg4Gif.mpeg4_duration, title=TestInlineQueryResultMpeg4Gif.title, caption=TestInlineQueryResultMpeg4Gif.caption, + parse_mode=TestInlineQueryResultMpeg4Gif.parse_mode, input_message_content=TestInlineQueryResultMpeg4Gif.input_message_content, reply_markup=TestInlineQueryResultMpeg4Gif.reply_markup) @@ -47,6 +48,7 @@ class TestInlineQueryResultMpeg4Gif(object): thumb_url = 'thumb url' title = 'title' caption = 'caption' + parse_mode = 'Markdown' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -60,6 +62,7 @@ class TestInlineQueryResultMpeg4Gif(object): assert inline_query_result_mpeg4_gif.thumb_url == self.thumb_url assert inline_query_result_mpeg4_gif.title == self.title assert inline_query_result_mpeg4_gif.caption == self.caption + assert inline_query_result_mpeg4_gif.parse_mode == self.parse_mode assert inline_query_result_mpeg4_gif.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_mpeg4_gif.reply_markup.to_dict() == self.reply_markup.to_dict() @@ -83,6 +86,8 @@ class TestInlineQueryResultMpeg4Gif(object): assert inline_query_result_mpeg4_gif_dict['title'] == inline_query_result_mpeg4_gif.title assert inline_query_result_mpeg4_gif_dict['caption'] == \ inline_query_result_mpeg4_gif.caption + assert inline_query_result_mpeg4_gif_dict['parse_mode'] == \ + inline_query_result_mpeg4_gif.parse_mode assert inline_query_result_mpeg4_gif_dict['input_message_content'] == \ inline_query_result_mpeg4_gif.input_message_content.to_dict() assert inline_query_result_mpeg4_gif_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultphoto.py b/tests/test_inlinequeryresultphoto.py index abf8f923d..2eb4aa17b 100644 --- a/tests/test_inlinequeryresultphoto.py +++ b/tests/test_inlinequeryresultphoto.py @@ -33,6 +33,7 @@ def inline_query_result_photo(): title=TestInlineQueryResultPhoto.title, description=TestInlineQueryResultPhoto.description, caption=TestInlineQueryResultPhoto.caption, + parse_mode=TestInlineQueryResultPhoto.parse_mode, input_message_content=TestInlineQueryResultPhoto.input_message_content, reply_markup=TestInlineQueryResultPhoto.reply_markup) @@ -47,6 +48,7 @@ class TestInlineQueryResultPhoto(object): title = 'title' description = 'description' caption = 'caption' + parse_mode = 'HTML' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -60,6 +62,7 @@ class TestInlineQueryResultPhoto(object): assert inline_query_result_photo.title == self.title assert inline_query_result_photo.description == self.description assert inline_query_result_photo.caption == self.caption + assert inline_query_result_photo.parse_mode == self.parse_mode assert inline_query_result_photo.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_photo.reply_markup.to_dict() == self.reply_markup.to_dict() @@ -80,6 +83,7 @@ class TestInlineQueryResultPhoto(object): assert inline_query_result_photo_dict['description'] == \ inline_query_result_photo.description assert inline_query_result_photo_dict['caption'] == inline_query_result_photo.caption + assert inline_query_result_photo_dict['parse_mode'] == inline_query_result_photo.parse_mode assert inline_query_result_photo_dict['input_message_content'] == \ inline_query_result_photo.input_message_content.to_dict() assert inline_query_result_photo_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultvideo.py b/tests/test_inlinequeryresultvideo.py index 431cd4a65..06f86b18a 100644 --- a/tests/test_inlinequeryresultvideo.py +++ b/tests/test_inlinequeryresultvideo.py @@ -34,6 +34,7 @@ def inline_query_result_video(): video_height=TestInlineQueryResultVideo.video_height, video_duration=TestInlineQueryResultVideo.video_duration, caption=TestInlineQueryResultVideo.caption, + parse_mode=TestInlineQueryResultVideo.parse_mode, description=TestInlineQueryResultVideo.description, input_message_content=TestInlineQueryResultVideo.input_message_content, reply_markup=TestInlineQueryResultVideo.reply_markup) @@ -50,6 +51,7 @@ class TestInlineQueryResultVideo(object): thumb_url = 'thumb url' title = 'title' caption = 'caption' + parse_mode = 'Markdown' description = 'description' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -66,6 +68,7 @@ class TestInlineQueryResultVideo(object): assert inline_query_result_video.title == self.title assert inline_query_result_video.description == self.description assert inline_query_result_video.caption == self.caption + assert inline_query_result_video.parse_mode == self.parse_mode assert inline_query_result_video.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_video.reply_markup.to_dict() == self.reply_markup.to_dict() @@ -89,6 +92,7 @@ class TestInlineQueryResultVideo(object): assert inline_query_result_video_dict['description'] == \ inline_query_result_video.description assert inline_query_result_video_dict['caption'] == inline_query_result_video.caption + assert inline_query_result_video_dict['parse_mode'] == inline_query_result_video.parse_mode assert inline_query_result_video_dict['input_message_content'] == \ inline_query_result_video.input_message_content.to_dict() assert inline_query_result_video_dict['reply_markup'] == \ diff --git a/tests/test_inlinequeryresultvoice.py b/tests/test_inlinequeryresultvoice.py index 59cdab414..c8b2ce086 100644 --- a/tests/test_inlinequeryresultvoice.py +++ b/tests/test_inlinequeryresultvoice.py @@ -31,6 +31,7 @@ def inline_query_result_voice(): title=TestInlineQueryResultVoice.title, voice_duration=TestInlineQueryResultVoice.voice_duration, caption=TestInlineQueryResultVoice.caption, + parse_mode=TestInlineQueryResultVoice.parse_mode, input_message_content=TestInlineQueryResultVoice.input_message_content, reply_markup=TestInlineQueryResultVoice.reply_markup) @@ -42,6 +43,7 @@ class TestInlineQueryResultVoice(object): title = 'title' voice_duration = 'voice_duration' caption = 'caption' + parse_mode = 'HTML' input_message_content = InputTextMessageContent('input_message_content') reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('reply_markup')]]) @@ -52,6 +54,7 @@ class TestInlineQueryResultVoice(object): assert inline_query_result_voice.title == self.title assert inline_query_result_voice.voice_duration == self.voice_duration assert inline_query_result_voice.caption == self.caption + assert inline_query_result_voice.parse_mode == self.parse_mode assert inline_query_result_voice.input_message_content.to_dict() == \ self.input_message_content.to_dict() assert inline_query_result_voice.reply_markup.to_dict() == self.reply_markup.to_dict() @@ -67,6 +70,7 @@ class TestInlineQueryResultVoice(object): assert inline_query_result_voice_dict['voice_duration'] == \ inline_query_result_voice.voice_duration assert inline_query_result_voice_dict['caption'] == inline_query_result_voice.caption + assert inline_query_result_voice_dict['parse_mode'] == inline_query_result_voice.parse_mode assert inline_query_result_voice_dict['input_message_content'] == \ inline_query_result_voice.input_message_content.to_dict() assert inline_query_result_voice_dict['reply_markup'] == \ diff --git a/tests/test_inputmedia.py b/tests/test_inputmedia.py index 56e3c724a..b9e47feea 100644 --- a/tests/test_inputmedia.py +++ b/tests/test_inputmedia.py @@ -30,13 +30,16 @@ def input_media_video(): caption=TestInputMediaVideo.caption, width=TestInputMediaVideo.width, height=TestInputMediaVideo.height, - duration=TestInputMediaVideo.duration) + duration=TestInputMediaVideo.duration, + parse_mode=TestInputMediaVideo.parse_mode, + supports_streaming=TestInputMediaVideo.supports_streaming) @pytest.fixture(scope='class') def input_media_photo(): return InputMediaPhoto(media=TestInputMediaPhoto.media, - caption=TestInputMediaPhoto.caption) + caption=TestInputMediaPhoto.caption, + parse_mode=TestInputMediaPhoto.parse_mode) class TestInputMediaVideo(object): @@ -46,6 +49,8 @@ class TestInputMediaVideo(object): width = 3 height = 4 duration = 5 + parse_mode = 'HTML' + supports_streaming = True def test_expected_values(self, input_media_video): assert input_media_video.type == self.type @@ -54,6 +59,8 @@ class TestInputMediaVideo(object): assert input_media_video.width == self.width assert input_media_video.height == self.height assert input_media_video.duration == self.duration + assert input_media_video.parse_mode == self.parse_mode + assert input_media_video.supports_streaming == self.supports_streaming def test_to_dict(self, input_media_video): input_media_video_dict = input_media_video.to_dict() @@ -63,6 +70,8 @@ class TestInputMediaVideo(object): assert input_media_video_dict['width'] == input_media_video.width assert input_media_video_dict['height'] == input_media_video.height assert input_media_video_dict['duration'] == input_media_video.duration + assert input_media_video_dict['parse_mode'] == input_media_video.parse_mode + assert input_media_video_dict['supports_streaming'] == input_media_video.supports_streaming def test_with_video(self, video): # fixture found in test_video @@ -84,17 +93,20 @@ class TestInputMediaPhoto(object): type = "photo" media = "NOTAREALFILEID" caption = "My Caption" + parse_mode = 'Markdown' def test_expected_values(self, input_media_photo): assert input_media_photo.type == self.type assert input_media_photo.media == self.media assert input_media_photo.caption == self.caption + assert input_media_photo.parse_mode == self.parse_mode def test_to_dict(self, input_media_photo): input_media_photo_dict = input_media_photo.to_dict() assert input_media_photo_dict['type'] == input_media_photo.type assert input_media_photo_dict['media'] == input_media_photo.media assert input_media_photo_dict['caption'] == input_media_photo.caption + assert input_media_photo_dict['parse_mode'] == input_media_photo.parse_mode def test_with_photo(self, photo): # fixture found in test_photo @@ -111,7 +123,8 @@ class TestInputMediaPhoto(object): @pytest.fixture(scope='function') def media_group(photo, thumb): - return [InputMediaPhoto(photo), InputMediaPhoto(thumb)] + return [InputMediaPhoto(photo, caption='photo `1`', parse_mode='Markdown'), + InputMediaPhoto(thumb, caption='photo 2', parse_mode='HTML')] class TestSendMediaGroup(object): diff --git a/tests/test_message.py b/tests/test_message.py index 39777fe2c..c61d44138 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -79,6 +79,7 @@ def message(bot): {'successful_payment': SuccessfulPayment('EUR', 243, 'payload', 'charge_id', 'provider_id', order_info={})}, + {'connected_website': 'http://example.com/'}, {'forward_signature': 'some_forward_sign'}, {'author_signature': 'some_author_sign'}, {'photo': [PhotoSize('photo_id', 50, 50)], @@ -90,8 +91,8 @@ def message(bot): 'voice', 'video_note', 'new_members', 'contact', 'location', 'venue', 'left_member', 'new_title', 'new_photo', 'delete_photo', 'group_created', 'supergroup_created', 'channel_created', 'migrated_to', 'migrated_from', - 'pinned', 'invoice', 'successful_payment', 'forward_signature', - 'author_signature', 'photo_from_media_group']) + 'pinned', 'invoice', 'successful_payment', 'connected_website', + 'forward_signature', 'author_signature', 'photo_from_media_group']) def message_params(bot, request): return Message(message_id=TestMessage.id, from_user=TestMessage.from_user, diff --git a/tests/test_photo.py b/tests/test_photo.py index 9cd45189f..d8de488a8 100644 --- a/tests/test_photo.py +++ b/tests/test_photo.py @@ -51,7 +51,7 @@ def photo(_photo): class TestPhoto(object): width = 300 height = 300 - caption = u'PhotoTest - Caption' + caption = u'PhotoTest - *Caption*' photo_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.jpg' file_size = 10209 @@ -77,7 +77,7 @@ class TestPhoto(object): @pytest.mark.timeout(10) def test_send_photo_all_args(self, bot, chat_id, photo_file, thumb, photo): message = bot.send_photo(chat_id, photo_file, caption=self.caption, - disable_notification=False) + disable_notification=False, parse_mode='Markdown') assert isinstance(message.photo[0], PhotoSize) assert isinstance(message.photo[0].file_id, str) @@ -93,7 +93,51 @@ class TestPhoto(object): assert message.photo[1].height == photo.height assert message.photo[1].file_size == photo.file_size - assert message.caption == TestPhoto.caption + assert message.caption == TestPhoto.caption.replace('*', '') + + @flaky(3, 1) + @pytest.mark.timeout(10) + def test_send_photo_parse_mode_markdown(self, bot, chat_id, photo_file, thumb, photo): + message = bot.send_photo(chat_id, photo_file, caption=self.caption, + parse_mode='Markdown') + assert isinstance(message.photo[0], PhotoSize) + assert isinstance(message.photo[0].file_id, str) + assert message.photo[0].file_id != '' + assert message.photo[0].width == thumb.width + assert message.photo[0].height == thumb.height + assert message.photo[0].file_size == thumb.file_size + + assert isinstance(message.photo[1], PhotoSize) + assert isinstance(message.photo[1].file_id, str) + assert message.photo[1].file_id != '' + assert message.photo[1].width == photo.width + assert message.photo[1].height == photo.height + assert message.photo[1].file_size == photo.file_size + + assert message.caption == TestPhoto.caption.replace('*', '') + assert len(message.caption_entities) == 1 + + @flaky(3, 1) + @pytest.mark.timeout(10) + def test_send_photo_parse_mode_html(self, bot, chat_id, photo_file, thumb, photo): + message = bot.send_photo(chat_id, photo_file, caption=self.caption, + parse_mode='HTML') + assert isinstance(message.photo[0], PhotoSize) + assert isinstance(message.photo[0].file_id, str) + assert message.photo[0].file_id != '' + assert message.photo[0].width == thumb.width + assert message.photo[0].height == thumb.height + assert message.photo[0].file_size == thumb.file_size + + assert isinstance(message.photo[1], PhotoSize) + assert isinstance(message.photo[1].file_id, str) + assert message.photo[1].file_id != '' + assert message.photo[1].width == photo.width + assert message.photo[1].height == photo.height + assert message.photo[1].file_size == photo.file_size + + assert message.caption == TestPhoto.caption.replace('', '').replace('', '') + assert len(message.caption_entities) == 1 @flaky(3, 1) @pytest.mark.timeout(10) diff --git a/tests/test_video.py b/tests/test_video.py index a933f9a0f..48b3f148e 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -43,8 +43,9 @@ class TestVideo(object): duration = 5 file_size = 326534 mime_type = 'video/mp4' + supports_streaming = True - caption = u'VideoTest - Caption' + caption = u'VideoTest - *Caption*' video_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.mp4' def test_creation(self, video): @@ -68,8 +69,9 @@ class TestVideo(object): @pytest.mark.timeout(10) def test_send_all_args(self, bot, chat_id, video_file, video): message = bot.send_video(chat_id, video_file, duration=self.duration, - caption=self.caption, disable_notification=False, - width=video.width, height=video.height) + caption=self.caption, supports_streaming=self.supports_streaming, + disable_notification=False, width=video.width, + height=video.height, parse_mode='Markdown') assert isinstance(message.video, Video) assert isinstance(message.video.file_id, str) @@ -86,7 +88,7 @@ class TestVideo(object): assert message.video.thumb.height == video.thumb.height assert message.video.thumb.file_size == video.thumb.file_size - assert message.caption == self.caption + assert message.caption == self.caption.replace('*', '') @flaky(3, 1) @pytest.mark.timeout(10) diff --git a/tests/test_voice.py b/tests/test_voice.py index 30885e164..8817288de 100644 --- a/tests/test_voice.py +++ b/tests/test_voice.py @@ -42,7 +42,7 @@ class TestVoice(object): mime_type = 'audio/ogg' file_size = 9199 - caption = u'Test voice' + caption = u'Test *voice*' voice_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.ogg' def test_creation(self, voice): @@ -60,7 +60,8 @@ class TestVoice(object): @pytest.mark.timeout(10) def test_send_all_args(self, bot, chat_id, voice_file, voice): message = bot.send_voice(chat_id, voice_file, duration=self.duration, - caption=self.caption, disable_notification=False) + caption=self.caption, disable_notification=False, + parse_mode='Markdown') assert isinstance(message.voice, Voice) assert isinstance(message.voice.file_id, str) @@ -68,7 +69,7 @@ class TestVoice(object): assert message.voice.duration == voice.duration assert message.voice.mime_type == voice.mime_type assert message.voice.file_size == voice.file_size - assert message.caption == self.caption + assert message.caption == self.caption.replace('*', '') @flaky(3, 1) @pytest.mark.timeout(10)