Merge branch 'bot-api-2.0' into dispatcher-rework

This commit is contained in:
Jannes Höke 2016-04-16 16:41:39 +02:00
commit b5cbf17ef5
7 changed files with 136 additions and 4 deletions

View file

@ -44,6 +44,7 @@ from .nullhandler import NullHandler
from .emoji import Emoji
from .parsemode import ParseMode
from .message import Message
from .messageentity import MessageEntity
from .callbackquery import CallbackQuery
from .choseninlineresult import ChosenInlineResult
from .inlinekeyboardbutton import InlineKeyboardButton
@ -74,6 +75,7 @@ from .inputtextmessagecontent import InputTextMessageContent
from .inputlocationmessagecontent import InputLocationMessageContent
from .inputvenuemessagecontent import InputVenueMessageContent
from .inputcontactmessagecontent import InputContactMessageContent
from .venue import Venue
from .update import Update
from .bot import Bot
@ -157,6 +159,7 @@ __all__ = ['Audio',
'KeyboardButton',
'Location',
'Message',
'MessageEntity',
'NullHandler',
'ParseMode',
'PhotoSize',
@ -169,5 +172,6 @@ __all__ = ['Audio',
'Update',
'User',
'UserProfilePhotos',
'Venue',
'Video',
'Voice']

View file

@ -43,7 +43,12 @@ class TelegramObject(object):
Returns:
telegram.TelegramObject:
"""
raise NotImplementedError
if not data:
return None
data = data.copy()
return data
def to_json(self):
"""

View file

@ -24,4 +24,18 @@ from telegram import InputMessageContent
class InputLocationMessageContent(InputMessageContent):
pass
"""Base class for Telegram InputLocationMessageContent Objects"""
def __init__(self,
latitude,
longitude):
# Required
self.latitude = latitude
self.longitude = longitude
@staticmethod
def de_json(data):
data = super(InputLocationMessageContent,
InputLocationMessageContent).de_json(data)
return InputLocationMessageContent(**data)

View file

@ -24,4 +24,21 @@ from telegram import InputMessageContent
class InputTextMessageContent(InputMessageContent):
pass
"""Base class for Telegram InputTextMessageContent Objects"""
def __init__(self,
message_text,
parse_mode=None,
disable_web_page_preview=None):
# Required
self.message_text = message_text
# Optionals
self.parse_mode = parse_mode
self.disable_web_page_preview = disable_web_page_preview
@staticmethod
def de_json(data):
data = super(InputTextMessageContent,
InputTextMessageContent).de_json(data)
return InputTextMessageContent(**data)

View file

@ -24,4 +24,25 @@ from telegram import InputMessageContent
class InputVenueMessageContent(InputMessageContent):
pass
"""Base class for Telegram InputVenueMessageContent Objects"""
def __init__(self,
latitude,
longitude,
title,
address,
foursquare_id=None):
# Required
self.latitude = latitude
self.longitude = longitude
self.title = title
self.address = address
# Optionals
self.foursquare_id = foursquare_id
@staticmethod
def de_json(data):
data = super(InputVenueMessageContent,
InputVenueMessageContent).de_json(data)
return InputVenueMessageContent(**data)

View file

@ -16,3 +16,38 @@
#
# 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 a object that represents a Telegram MessageEntity."""
from telegram import TelegramObject
class MessageEntity(TelegramObject):
"""
This object represents one special entity in a text message. For example,
hashtags, usernames, URLs, etc.
Args:
type (str):
offset (int):
length (int):
url (Optional[str]):
"""
def __init__(self,
type,
offset,
length,
url=None):
# Required
self.type = type
self.offset = offset
self.length = length
# Optionals
self.url = url
@staticmethod
def de_json(self):
data = super(MessageEntity, MessageEntity).de_json(data)
return MessageEntity(**data)

View file

@ -16,3 +16,39 @@
#
# 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 a object that represents a Telegram Venue."""
from telegram import TelegramObject, Location
class Venue(TelegramObject):
"""
This object represents a venue.
Args:
location (:class:`telegram.Location`):
title (str):
address (str):
foursquare_id (Optional[str]):
"""
def __init__(self,
location,
title,
address,
foursquare_id=None):
# Required
self.location = location
self.title = title
self.address = address
# Optionals
self.foursquare_id = foursquare_id
@staticmethod
def de_json(self):
data = super(Venue, Venue).de_json(data)
data['location'] = Location.de_json(data.get('location'))
return Venue(**data)