Skip to content
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -35,4 +35,4 @@ script:

after_success:
- coverage combine
- codecov -F Travis
- codecov -F Travis
43 changes: 43 additions & 0 deletions telegram/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ def send_photo(self,
reply_to_message_id=None,
reply_markup=None,
timeout=20,
parse_mode=None,
**kwargs):
"""Use this method to send photos.

Expand All @@ -356,6 +357,9 @@ def send_photo(self,
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
Expand All @@ -382,6 +386,8 @@ def send_photo(self,

if caption:
data['caption'] = caption
if parse_mode:
data['parse_mode'] = parse_mode

return url, data

Expand All @@ -398,6 +404,7 @@ def send_audio(self,
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
Expand All @@ -420,6 +427,9 @@ def send_audio(self,
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.
Expand Down Expand Up @@ -455,6 +465,8 @@ def send_audio(self,
data['title'] = title
if caption:
data['caption'] = caption
if parse_mode:
data['parse_mode'] = parse_mode

return url, data

Expand All @@ -469,6 +481,7 @@ def send_document(self,
reply_to_message_id=None,
reply_markup=None,
timeout=20,
parse_mode=None,
**kwargs):
"""Use this method to send general files.

Expand All @@ -488,6 +501,9 @@ def send_document(self,
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
Expand Down Expand Up @@ -516,6 +532,8 @@ def send_document(self,
data['filename'] = filename
if caption:
data['caption'] = caption
if parse_mode:
data['parse_mode'] = parse_mode

return url, data

Expand Down Expand Up @@ -582,6 +600,8 @@ def send_video(self,
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
Expand All @@ -604,6 +624,11 @@ def send_video(self,
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
Expand Down Expand Up @@ -632,6 +657,10 @@ def send_video(self,
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:
Expand All @@ -650,6 +679,7 @@ def send_voice(self,
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
Expand All @@ -669,6 +699,9 @@ def send_voice(self,
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.
Expand Down Expand Up @@ -698,6 +731,8 @@ def send_voice(self,
data['duration'] = duration
if caption:
data['caption'] = caption
if parse_mode:
data['parse_mode'] = parse_mode

return url, data

Expand Down Expand Up @@ -1504,6 +1539,8 @@ def edit_message_text(self,
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.
Expand Down Expand Up @@ -1546,6 +1583,7 @@ def edit_message_caption(self,
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
Expand All @@ -1559,6 +1597,9 @@ def edit_message_caption(self,
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.
Expand Down Expand Up @@ -1586,6 +1627,8 @@ def edit_message_caption(self,

if caption:
data['caption'] = caption
if parse_mode:
data['parse_mode'] = parse_mode
if chat_id:
data['chat_id'] = chat_id
if message_id:
Expand Down
12 changes: 11 additions & 1 deletion telegram/ext/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,23 @@ def filter(self, message):
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.
Expand Down
10 changes: 9 additions & 1 deletion telegram/files/inputmediaphoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,26 @@ 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.
"""

# 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):
Expand All @@ -55,3 +61,5 @@ def __init__(self, media, caption=None):

if caption:
self.caption = caption
if parse_mode:
self.parse_mode = parse_mode
17 changes: 16 additions & 1 deletion telegram/files/inputmediavideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -66,9 +77,13 @@ def __init__(self, media, caption=None, width=None, height=None, duration=None):

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
9 changes: 9 additions & 0 deletions telegram/inline/inlinequeryresultaudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -64,6 +70,7 @@ def __init__(self,
caption=None,
reply_markup=None,
input_message_content=None,
parse_mode=None,
**kwargs):

# Required
Expand All @@ -78,6 +85,8 @@ def __init__(self,
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:
Expand Down
9 changes: 9 additions & 0 deletions telegram/inline/inlinequeryresultcachedaudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -55,6 +61,7 @@ def __init__(self,
caption=None,
reply_markup=None,
input_message_content=None,
parse_mode=None,
**kwargs):
# Required
super(InlineQueryResultCachedAudio, self).__init__('audio', id)
Expand All @@ -63,6 +70,8 @@ def __init__(self,
# 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:
Expand Down
Loading