New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for 3.5 api #920
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
aae2195
add support for 3.5 api
Eldinnie 6f0b3d2
removed "unused" import by accident
Eldinnie faa33fd
Hardcoded values
Eldinnie 96a046d
test_official
Eldinnie 9826cda
Improve coverage
Eldinnie f739102
Finishing up
Eldinnie d9f70f7
spelling error
Eldinnie 033e82c
pytest fixed tot < than 3.3 for python 3.3 support
Eldinnie 8c8d2c4
flake8
Eldinnie e2b55ed
rollback requirements
Eldinnie 9e9bc4b
as per CR
Eldinnie f9dccdd
object for provider_data
Eldinnie b1c504f
shorten error message
Eldinnie a9f337f
using string_types
Eldinnie File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
telegram.InputMedia | ||
=================== | ||
|
||
.. autoclass:: telegram.InputMedia | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
telegram.InputMediaPhoto | ||
======================== | ||
|
||
.. autoclass:: telegram.InputMediaPhoto | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
telegram.InputMediaVideo | ||
======================== | ||
|
||
.. autoclass:: telegram.InputMediaVideo | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
# | ||
# A library that provides a Python interface to the Telegram Bot API | ||
# Copyright (C) 2015-2017 | ||
# Leandro Toledo de Souza <devs@python-telegram-bot.org> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser Public License | ||
# along with this program. If not, see [http://www.gnu.org/licenses/]. | ||
"""Base class for Telegram InputMedia Objects.""" | ||
|
||
from telegram import TelegramObject | ||
|
||
|
||
class InputMedia(TelegramObject): | ||
"""Base class for Telegram InputMedia Objects. | ||
|
||
See :class:`telegram.InputMediaPhoto` and :class:`telegram.InputMediaVideo` for | ||
detailed use. | ||
|
||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python | ||
# | ||
# A library that provides a Python interface to the Telegram Bot API | ||
# Copyright (C) 2015-2017 | ||
# Leandro Toledo de Souza <devs@python-telegram-bot.org> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser Public License | ||
# along with this program. If not, see [http://www.gnu.org/licenses/]. | ||
"""This module contains an object that represents a Telegram InputMediaPhoto.""" | ||
from telegram import InputMedia, PhotoSize | ||
|
||
|
||
class InputMediaPhoto(InputMedia): | ||
"""Represents a photo to be sent. | ||
|
||
Attributes: | ||
type (:obj:`str`): ``photo``. | ||
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. | ||
|
||
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. | ||
|
||
Note: | ||
At the moment using a new file is not yet supported. | ||
""" | ||
|
||
def __init__(self, media, caption=None): | ||
self.type = 'photo' | ||
|
||
if isinstance(media, PhotoSize): | ||
self.media = media.file_id | ||
elif hasattr(media, 'read'): | ||
raise ValueError('We only support file_id or url as a valid media. Sending files is ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a TODO: about this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, will do |
||
'not supported (yet).') | ||
else: | ||
self.media = media | ||
|
||
if caption: | ||
self.caption = caption |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env python | ||
# | ||
# A library that provides a Python interface to the Telegram Bot API | ||
# Copyright (C) 2015-2017 | ||
# Leandro Toledo de Souza <devs@python-telegram-bot.org> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser Public License | ||
# along with this program. If not, see [http://www.gnu.org/licenses/]. | ||
"""This module contains an object that represents a Telegram InputMediaPhoto.""" | ||
from telegram import InputMedia, Video | ||
|
||
|
||
class InputMediaVideo(InputMedia): | ||
"""Represents a video to be sent. | ||
|
||
Attributes: | ||
type (:obj:`str`): ``video``. | ||
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. | ||
width (:obj:`int`): Optional. Video width. | ||
height (:obj:`int`): Optional. Video height. | ||
duration (:obj:`int`): Optional. Video duration. | ||
|
||
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. | ||
width (:obj:`int`, optional): Video width. | ||
height (:obj:`int`, optional): Video height. | ||
duration (:obj:`int`, optional): Video duration. | ||
|
||
Note: | ||
When using a :class:`telegram.Video` for the :attr:`media` attribute. It will take the | ||
width, height and duration from that video, unless otherwise specified with the optional | ||
arguments. | ||
At the moment using a new file is not yet supported. | ||
""" | ||
|
||
def __init__(self, media, caption=None, width=None, height=None, duration=None): | ||
self.type = 'video' | ||
|
||
if isinstance(media, Video): | ||
self.media = media.file_id | ||
self.width = media.width | ||
self.height = media.height | ||
self.duration = media.duration | ||
elif hasattr(media, 'read'): | ||
raise ValueError('We only support file_id or url as a valid media. Sending files is ' | ||
'not supported (yet).') | ||
else: | ||
self.media = media | ||
|
||
if caption: | ||
self.caption = caption | ||
if width: | ||
self.width = width | ||
if height: | ||
self.height = height | ||
if duration: | ||
self.duration = duration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these files maybe be in files/?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe.