mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 22:45:09 +01:00
Merge branch 'bot-api-2.0' into dispatcher-rework
This commit is contained in:
commit
b2045717d6
26 changed files with 732 additions and 349 deletions
101
telegram/bot.py
101
telegram/bot.py
|
@ -611,6 +611,107 @@ class Bot(TelegramObject):
|
|||
|
||||
return url, data
|
||||
|
||||
@log
|
||||
@message
|
||||
def sendVenue(self,
|
||||
chat_id,
|
||||
latitude,
|
||||
longitude,
|
||||
title,
|
||||
address,
|
||||
foursquare_id=None,
|
||||
**kwargs):
|
||||
"""
|
||||
Use this method to send information about a venue.
|
||||
|
||||
Args:
|
||||
chat_id:
|
||||
Unique identifier for the target chat or username of the target
|
||||
channel (in the format @channelusername).
|
||||
latitude:
|
||||
Latitude of the venue.
|
||||
longitude:
|
||||
Longitude of the venue.
|
||||
title:
|
||||
Name of the venue.
|
||||
address:
|
||||
Address of the venue.
|
||||
foursquare_id:
|
||||
Foursquare identifier of the venue.
|
||||
disable_notification:
|
||||
Sends the message silently. iOS users will not receive a
|
||||
notification, Android users will receive a notification with no
|
||||
sound.
|
||||
reply_to_message_id:
|
||||
If the message is a reply, ID of the original message.
|
||||
reply_markup:
|
||||
Additional interface options. A JSON-serialized object for an
|
||||
inline keyboard, custom reply keyboard, instructions to hide
|
||||
reply keyboard or to force a reply from the user.
|
||||
|
||||
Returns:
|
||||
A telegram.Message instance representing the message posted.
|
||||
"""
|
||||
|
||||
url = '%s/sendVenue' % self.base_url
|
||||
|
||||
data = {'chat_id': chat_id,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'address': address,
|
||||
'title': title}
|
||||
|
||||
if foursquare_id:
|
||||
data['foursquare_id'] = foursquare_id
|
||||
|
||||
return url, data
|
||||
|
||||
@log
|
||||
@message
|
||||
def sendContact(self,
|
||||
chat_id,
|
||||
phone_number,
|
||||
first_name,
|
||||
last_name=None,
|
||||
**kwargs):
|
||||
"""
|
||||
Use this method to send phone contacts.
|
||||
|
||||
Args:
|
||||
chat_id:
|
||||
Unique identifier for the target chat or username of the target
|
||||
channel (in the format @channelusername).
|
||||
phone_number:
|
||||
Contact's phone number.
|
||||
first_name:
|
||||
Contact's first name.
|
||||
last_name:
|
||||
Contact's last name.
|
||||
disable_notification:
|
||||
Sends the message silently. iOS users will not receive a
|
||||
notification, Android users will receive a notification with no
|
||||
sound.
|
||||
reply_to_message_id:
|
||||
If the message is a reply, ID of the original message.
|
||||
reply_markup:
|
||||
Additional interface options. A JSON-serialized object for an
|
||||
inline keyboard, custom reply keyboard, instructions to hide
|
||||
reply keyboard or to force a reply from the user.
|
||||
|
||||
Returns:
|
||||
A telegram.Message instance representing the message posted.
|
||||
"""
|
||||
url = '%s/sendContact' % self.base_url
|
||||
|
||||
data = {'chat_id': chat_id,
|
||||
'phone_number': phone_number,
|
||||
'first_name': first_name}
|
||||
|
||||
if last_name:
|
||||
data['last_name'] = last_name
|
||||
|
||||
return url, data
|
||||
|
||||
@log
|
||||
@message
|
||||
def sendChatAction(self,
|
||||
|
|
|
@ -77,7 +77,7 @@ def run_async(func):
|
|||
return async_func
|
||||
|
||||
|
||||
class Dispatcher:
|
||||
class Dispatcher(object):
|
||||
"""
|
||||
This class dispatches all kinds of updates to its registered handlers.
|
||||
|
||||
|
@ -131,7 +131,7 @@ class Dispatcher:
|
|||
if self.__stop_event.is_set():
|
||||
self.logger.debug('orderly stopping')
|
||||
break
|
||||
elif self.__stop_event.is_set():
|
||||
elif self.__exception_event.is_set():
|
||||
self.logger.critical(
|
||||
'stopping due to exception in another thread')
|
||||
break
|
||||
|
|
|
@ -43,7 +43,7 @@ from telegram.utils.webhookhandler import (WebhookServer, WebhookHandler)
|
|||
logging.getLogger(__name__).addHandler(NullHandler())
|
||||
|
||||
|
||||
class Updater:
|
||||
class Updater(object):
|
||||
"""
|
||||
This class, which employs the Dispatcher class, provides a frontend to
|
||||
telegram.Bot to the programmer, so they can focus on coding the bot. Its
|
||||
|
|
|
@ -45,14 +45,4 @@ class InlineQueryResult(TelegramObject):
|
|||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
"""
|
||||
Args:
|
||||
data (dict):
|
||||
|
||||
Returns:
|
||||
telegram.InlineQueryResult:
|
||||
"""
|
||||
if not data:
|
||||
return None
|
||||
|
||||
return InlineQueryResult(**data)
|
||||
return super(InlineQueryResult, InlineQueryResult).de_json(data)
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultArticle"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram.utils.validate import validate_string
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultArticle(InlineQueryResult):
|
||||
|
@ -30,9 +30,8 @@ class InlineQueryResultArticle(InlineQueryResult):
|
|||
Attributes:
|
||||
id (str):
|
||||
title (str):
|
||||
message_text (str):
|
||||
parse_mode (str):
|
||||
disable_web_page_preview (bool):
|
||||
input_message_content (telegram.InputMessageContent):
|
||||
reply_markup (telegram.ReplyMarkup):
|
||||
url (str):
|
||||
hide_url (bool):
|
||||
description (str):
|
||||
|
@ -43,11 +42,9 @@ class InlineQueryResultArticle(InlineQueryResult):
|
|||
Args:
|
||||
id (str): Unique identifier for this result, 1-64 Bytes
|
||||
title (str):
|
||||
message_text (str):
|
||||
reply_markup (telegram.ReplyMarkup):
|
||||
|
||||
Keyword Args:
|
||||
parse_mode (Optional[str]):
|
||||
disable_web_page_preview (Optional[bool]):
|
||||
url (Optional[str]):
|
||||
hide_url (Optional[bool]):
|
||||
description (Optional[str]):
|
||||
|
@ -59,51 +56,44 @@ class InlineQueryResultArticle(InlineQueryResult):
|
|||
def __init__(self,
|
||||
id,
|
||||
title,
|
||||
message_text,
|
||||
parse_mode=None,
|
||||
disable_web_page_preview=None,
|
||||
input_message_content,
|
||||
reply_markup=None,
|
||||
url=None,
|
||||
hide_url=None,
|
||||
description=None,
|
||||
thumb_url=None,
|
||||
thumb_width=None,
|
||||
thumb_height=None,
|
||||
**kwargs):
|
||||
|
||||
validate_string(title, 'title')
|
||||
validate_string(message_text, 'message_text')
|
||||
validate_string(url, 'url')
|
||||
validate_string(description, 'description')
|
||||
validate_string(thumb_url, 'thumb_url')
|
||||
validate_string(parse_mode, 'parse_mode')
|
||||
thumb_height=None):
|
||||
|
||||
# Required
|
||||
super(InlineQueryResultArticle, self).__init__('article', id)
|
||||
self.title = title
|
||||
self.message_text = message_text
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
# Optional
|
||||
self.parse_mode = parse_mode
|
||||
self.disable_web_page_preview = bool(disable_web_page_preview)
|
||||
self.url = url
|
||||
self.hide_url = bool(hide_url)
|
||||
self.description = description
|
||||
self.thumb_url = thumb_url
|
||||
if thumb_width is not None:
|
||||
self.thumb_width = int(thumb_width)
|
||||
if thumb_height is not None:
|
||||
self.thumb_height = int(thumb_height)
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if url:
|
||||
self.url = url
|
||||
if hide_url:
|
||||
self.hide_url = hide_url
|
||||
if description:
|
||||
self.description = description
|
||||
if thumb_url:
|
||||
self.thumb_url = thumb_url
|
||||
if thumb_width:
|
||||
self.thumb_width = thumb_width
|
||||
if thumb_height:
|
||||
self.thumb_height = thumb_height
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
"""
|
||||
Args:
|
||||
data (dict):
|
||||
data = super(InlineQueryResultArticle,
|
||||
InlineQueryResultArticle).de_json(data)
|
||||
|
||||
Returns:
|
||||
telegram.InlineQueryResultArticle:
|
||||
"""
|
||||
if not data:
|
||||
return None
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultArticle(**data)
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultAudio"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultAudio(InlineQueryResult):
|
||||
|
@ -38,10 +39,24 @@ class InlineQueryResultAudio(InlineQueryResult):
|
|||
self.audio_url = audio_url
|
||||
self.title = title
|
||||
|
||||
# Optional
|
||||
self.performer = performer
|
||||
self.audio_duration = audio_duration
|
||||
if reply_markup is not None:
|
||||
self.reply_markup = 'ReplyMarkup' # TODO
|
||||
if input_message_content is not None:
|
||||
self.input_message_content = 'InputMessageContent'
|
||||
# Optionals
|
||||
if performer:
|
||||
self.performer = performer
|
||||
if audio_duration:
|
||||
self.audio_duration = audio_duration
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultAudio,
|
||||
InlineQueryResultAudio).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultAudio(**data)
|
||||
|
|
|
@ -20,8 +20,34 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultCachedAudio"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultCachedAudio(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
audio_file_id,
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
# Required
|
||||
super(InlineQueryResultCachedAudio, self).__init__('audio', id)
|
||||
self.audio_file_id = audio_file_id
|
||||
|
||||
# Optionals
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultCachedAudio,
|
||||
InlineQueryResultCachedAudio).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultCachedAudio(**data)
|
||||
|
|
|
@ -20,8 +20,42 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultCachedDocument"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultCachedDocument(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
title,
|
||||
document_file_id,
|
||||
description=None,
|
||||
caption=None,
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
# Required
|
||||
super(InlineQueryResultCachedDocument, self).__init__('document', id)
|
||||
self.title = title
|
||||
self.document_file_id = document_file_id
|
||||
|
||||
# Optionals
|
||||
if description:
|
||||
self.description = description
|
||||
if caption:
|
||||
self.caption = caption
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultCachedDocument,
|
||||
InlineQueryResultCachedDocument).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultCachedDocument(**data)
|
||||
|
|
|
@ -20,8 +20,40 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultCachedGif"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultCachedGif(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
gif_file_id,
|
||||
title=None,
|
||||
caption=None,
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
# Required
|
||||
super(InlineQueryResultCachedGif, self).__init__('gif', id)
|
||||
self.gif_file_id = gif_file_id
|
||||
|
||||
# Optionals
|
||||
if title:
|
||||
self.title = title
|
||||
if caption:
|
||||
self.caption = caption
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultCachedGif,
|
||||
InlineQueryResultCachedGif).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultCachedGif(**data)
|
||||
|
|
|
@ -20,8 +20,40 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultMpeg4Gif"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
mpeg4_file_id,
|
||||
title=None,
|
||||
caption=None,
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
# Required
|
||||
super(InlineQueryResultCachedMpeg4Gif, self).__init__('mpeg4_gif', id)
|
||||
self.mpeg4_file_id = mpeg4_file_id
|
||||
|
||||
# Optionals
|
||||
if title:
|
||||
self.title = title
|
||||
if caption:
|
||||
self.caption = caption
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultCachedMpeg4Gif,
|
||||
InlineQueryResultCachedMpeg4Gif).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultCachedMpeg4Gif(**data)
|
||||
|
|
|
@ -20,8 +20,43 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultPhoto"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultCachedPhoto(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
photo_file_id,
|
||||
title=None,
|
||||
description=None,
|
||||
caption=None,
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
# Required
|
||||
super(InlineQueryResultCachedPhoto, self).__init__('photo', id)
|
||||
self.photo_file_id = photo_file_id
|
||||
|
||||
# Optionals
|
||||
if title:
|
||||
self.title = title
|
||||
if description:
|
||||
self.description = description
|
||||
if caption:
|
||||
self.caption = caption
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultCachedPhoto,
|
||||
InlineQueryResultCachedPhoto).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultCachedPhoto(**data)
|
||||
|
|
|
@ -20,8 +20,34 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultCachedSticker"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultCachedSticker(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
sticker_file_id,
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
# Required
|
||||
super(InlineQueryResultCachedSticker, self).__init__('sticker', id)
|
||||
self.sticker_file_id = sticker_file_id
|
||||
|
||||
# Optionals
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultCachedSticker,
|
||||
InlineQueryResultCachedSticker).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultCachedSticker(**data)
|
||||
|
|
|
@ -20,8 +20,42 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultCachedVideo"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultCachedVideo(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
video_file_id,
|
||||
title,
|
||||
description=None,
|
||||
caption=None,
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
# Required
|
||||
super(InlineQueryResultCachedVideo, self).__init__('video', id)
|
||||
self.video_file_id = video_file_id
|
||||
self.title = title
|
||||
|
||||
# Optionals
|
||||
if description:
|
||||
self.description = description
|
||||
if caption:
|
||||
self.caption = caption
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultCachedVideo,
|
||||
InlineQueryResultCachedVideo).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultCachedVideo(**data)
|
||||
|
|
|
@ -20,8 +20,39 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultCachedVoice"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultCachedVoice(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
voice_file_id,
|
||||
title,
|
||||
description=None,
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
# Required
|
||||
super(InlineQueryResultCachedVoice, self).__init__('voice', id)
|
||||
self.voice_file_id = voice_file_id
|
||||
self.title = title
|
||||
|
||||
# Optionals
|
||||
if description:
|
||||
self.description = description
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultCachedVoice,
|
||||
InlineQueryResultCachedVoice).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultCachedVoice(**data)
|
||||
|
|
|
@ -20,8 +20,48 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultContact"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultContact(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
phone_number,
|
||||
first_name,
|
||||
last_name=None,
|
||||
reply_markup=None,
|
||||
input_message_content=None,
|
||||
thumb_url=None,
|
||||
thumb_width=None,
|
||||
thumb_height=None):
|
||||
# Required
|
||||
super(InlineQueryResultContact, self).__init__('contact', id)
|
||||
self.phone_number = phone_number
|
||||
self.first_name = first_name
|
||||
|
||||
# Optionals
|
||||
if last_name:
|
||||
self.last_name = last_name
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
if thumb_url:
|
||||
self.thumb_url = thumb_url
|
||||
if thumb_width:
|
||||
self.thumb_width = thumb_width
|
||||
if thumb_height:
|
||||
self.thumb_height = thumb_height
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultContact,
|
||||
InlineQueryResultContact).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultContact(**data)
|
||||
|
|
|
@ -20,8 +20,53 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultDocument"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultDocument(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
document_url,
|
||||
title,
|
||||
mime_type,
|
||||
caption=None,
|
||||
description=None,
|
||||
reply_markup=None,
|
||||
input_message_content=None,
|
||||
thumb_url=None,
|
||||
thumb_width=None,
|
||||
thumb_height=None):
|
||||
# Required
|
||||
super(InlineQueryResultDocument, self).__init__('document', id)
|
||||
self.document_url = document_url
|
||||
self.title = title
|
||||
self.mime_type = mime_type
|
||||
|
||||
# Optionals
|
||||
if caption:
|
||||
self.caption = caption
|
||||
if description:
|
||||
self.description = description
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
if thumb_url:
|
||||
self.thumb_url = thumb_url
|
||||
if thumb_width:
|
||||
self.thumb_width = thumb_width
|
||||
if thumb_height:
|
||||
self.thumb_height = thumb_height
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultDocument,
|
||||
InlineQueryResultDocument).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultDocument(**data)
|
||||
|
|
|
@ -20,40 +20,11 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultGif"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram.utils.validate import validate_string
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultGif(InlineQueryResult):
|
||||
"""This object represents a Telegram InlineQueryResultGif.
|
||||
|
||||
Attributes:
|
||||
id (str):
|
||||
gif_url (str):
|
||||
gif_width (int):
|
||||
gif_height (int):
|
||||
thumb_url (str):
|
||||
title (str):
|
||||
caption (str):
|
||||
message_text (str):
|
||||
parse_mode (str):
|
||||
disable_web_page_preview (bool):
|
||||
|
||||
Args:
|
||||
id (str): Unique identifier for this result, 1-64 Bytes
|
||||
gif_url (str):
|
||||
thumb_url (str):
|
||||
|
||||
Keyword Args:
|
||||
gif_width (Optional[int]):
|
||||
gif_height (Optional[int]):
|
||||
title (Optional[str]):
|
||||
caption (Optional[str]):
|
||||
message_text (Optional[str]):
|
||||
parse_mode (Optional[str]):
|
||||
disable_web_page_preview (Optional[bool]):
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
id,
|
||||
gif_url,
|
||||
|
@ -62,44 +33,36 @@ class InlineQueryResultGif(InlineQueryResult):
|
|||
gif_height=None,
|
||||
title=None,
|
||||
caption=None,
|
||||
message_text=None,
|
||||
parse_mode=None,
|
||||
disable_web_page_preview=None,
|
||||
**kwargs):
|
||||
|
||||
validate_string(gif_url, 'gif_url')
|
||||
validate_string(thumb_url, 'thumb_url')
|
||||
validate_string(title, 'title')
|
||||
validate_string(caption, 'caption')
|
||||
validate_string(message_text, 'message_text')
|
||||
validate_string(parse_mode, 'parse_mode')
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
|
||||
# Required
|
||||
super(InlineQueryResultGif, self).__init__('gif', id)
|
||||
self.gif_url = gif_url
|
||||
self.thumb_url = thumb_url
|
||||
|
||||
# Optional
|
||||
if gif_width is not None:
|
||||
self.gif_width = int(gif_width)
|
||||
if gif_height is not None:
|
||||
self.gif_height = int(gif_height)
|
||||
self.title = title
|
||||
self.caption = caption
|
||||
self.message_text = message_text
|
||||
self.parse_mode = parse_mode
|
||||
self.disable_web_page_preview = bool(disable_web_page_preview)
|
||||
# Optionals
|
||||
if gif_width:
|
||||
self.gif_width = gif_width
|
||||
if gif_height:
|
||||
self.gif_height = gif_height
|
||||
if title:
|
||||
self.title = title
|
||||
if caption:
|
||||
self.caption = caption
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
"""
|
||||
Args:
|
||||
data (dict):
|
||||
data = super(InlineQueryResultGif,
|
||||
InlineQueryResultGif).de_json(data)
|
||||
|
||||
Returns:
|
||||
telegram.InlineQueryResultGif:
|
||||
"""
|
||||
if not data:
|
||||
return None
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultGif(**data)
|
||||
|
|
|
@ -20,8 +20,47 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultLocation"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultLocation(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
latitude,
|
||||
longitude,
|
||||
title,
|
||||
reply_markup=None,
|
||||
input_message_content=None,
|
||||
thumb_url=None,
|
||||
thumb_width=None,
|
||||
thumb_height=None):
|
||||
# Required
|
||||
super(InlineQueryResultLocation, self).__init__('location', id)
|
||||
self.latitude = latitude
|
||||
self.longitude = longitude
|
||||
self.title = title
|
||||
|
||||
# Optionals
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
if thumb_url:
|
||||
self.thumb_url = thumb_url
|
||||
if thumb_width:
|
||||
self.thumb_width = thumb_width
|
||||
if thumb_height:
|
||||
self.thumb_height = thumb_height
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultLocation,
|
||||
InlineQueryResultLocation).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultLocation(**data)
|
||||
|
|
|
@ -20,40 +20,11 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultMpeg4Gif"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram.utils.validate import validate_string
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
||||
"""This object represents a Telegram InlineQueryResultMpeg4Gif.
|
||||
|
||||
Attributes:
|
||||
id (str):
|
||||
mpeg4_url (str):
|
||||
mpeg4_width (int):
|
||||
mpeg4_height (int):
|
||||
thumb_url (str):
|
||||
title (str):
|
||||
caption (str):
|
||||
message_text (str):
|
||||
parse_mode (str):
|
||||
disable_web_page_preview (bool):
|
||||
|
||||
Args:
|
||||
id (str): Unique identifier for this result, 1-64 Bytes
|
||||
mpeg4_url (str):
|
||||
thumb_url (str):
|
||||
|
||||
Keyword Args:
|
||||
mpeg4_width (Optional[int]):
|
||||
mpeg4_height (Optional[int]):
|
||||
title (Optional[str]):
|
||||
caption (Optional[str]):
|
||||
message_text (Optional[str]):
|
||||
parse_mode (Optional[str]):
|
||||
disable_web_page_preview (Optional[bool]):
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
id,
|
||||
mpeg4_url,
|
||||
|
@ -62,17 +33,8 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
|||
mpeg4_height=None,
|
||||
title=None,
|
||||
caption=None,
|
||||
message_text=None,
|
||||
parse_mode=None,
|
||||
disable_web_page_preview=None,
|
||||
**kwargs):
|
||||
|
||||
validate_string(mpeg4_url, 'mpeg4_url')
|
||||
validate_string(thumb_url, 'thumb_url')
|
||||
validate_string(title, 'title')
|
||||
validate_string(caption, 'caption')
|
||||
validate_string(message_text, 'message_text')
|
||||
validate_string(parse_mode, 'parse_mode')
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
|
||||
# Required
|
||||
super(InlineQueryResultMpeg4Gif, self).__init__('mpeg4_gif', id)
|
||||
|
@ -80,26 +42,27 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
|||
self.thumb_url = thumb_url
|
||||
|
||||
# Optional
|
||||
if mpeg4_width is not None:
|
||||
self.mpeg4_width = int(mpeg4_width)
|
||||
if mpeg4_height is not None:
|
||||
self.mpeg4_height = int(mpeg4_height)
|
||||
self.title = title
|
||||
self.caption = caption
|
||||
self.message_text = message_text
|
||||
self.parse_mode = parse_mode
|
||||
self.disable_web_page_preview = bool(disable_web_page_preview)
|
||||
if mpeg4_width:
|
||||
self.mpeg4_width = mpeg4_width
|
||||
if mpeg4_height:
|
||||
self.mpeg4_height = mpeg4_height
|
||||
if title:
|
||||
self.title = title
|
||||
if caption:
|
||||
self.caption = caption
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
"""
|
||||
Args:
|
||||
data (dict):
|
||||
data = super(InlineQueryResultMpeg4Gif,
|
||||
InlineQueryResultMpeg4Gif).de_json(data)
|
||||
|
||||
Returns:
|
||||
telegram.InlineQueryResultMpeg4Gif:
|
||||
"""
|
||||
if not data:
|
||||
return None
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultMpeg4Gif(**data)
|
||||
|
|
|
@ -20,96 +20,51 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultPhoto"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram.utils.validate import validate_string
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultPhoto(InlineQueryResult):
|
||||
"""This object represents a Telegram InlineQueryResultPhoto.
|
||||
|
||||
Attributes:
|
||||
id (str):
|
||||
photo_url (str):
|
||||
mime_type (str):
|
||||
photo_width (int):
|
||||
photo_height (int):
|
||||
thumb_url (str):
|
||||
title (str):
|
||||
description (str):
|
||||
caption (str):
|
||||
message_text (str):
|
||||
parse_mode (str):
|
||||
disable_web_page_preview (bool):
|
||||
|
||||
Args:
|
||||
id (str): Unique identifier for this result, 1-64 Bytes
|
||||
photo_url (str):
|
||||
thumb_url (str):
|
||||
|
||||
Keyword Args:
|
||||
mime_type (Optional[str]):
|
||||
photo_width (Optional[int]):
|
||||
photo_height (Optional[int]):
|
||||
title (Optional[str]):
|
||||
description (Optional[str]):
|
||||
caption (Optional[str]):
|
||||
message_text (Optional[str]):
|
||||
parse_mode (Optional[str]):
|
||||
disable_web_page_preview (Optional[bool]):
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
id,
|
||||
photo_url,
|
||||
thumb_url,
|
||||
mime_type=None,
|
||||
photo_width=None,
|
||||
photo_height=None,
|
||||
title=None,
|
||||
description=None,
|
||||
caption=None,
|
||||
message_text=None,
|
||||
parse_mode=None,
|
||||
disable_web_page_preview=None,
|
||||
**kwargs):
|
||||
|
||||
validate_string(photo_url, 'photo_url')
|
||||
validate_string(thumb_url, 'thumb_url')
|
||||
validate_string(mime_type, 'mime_type')
|
||||
validate_string(title, 'title')
|
||||
validate_string(description, 'description')
|
||||
validate_string(caption, 'caption')
|
||||
validate_string(message_text, 'message_text')
|
||||
validate_string(parse_mode, 'parse_mode')
|
||||
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
# Required
|
||||
super(InlineQueryResultPhoto, self).__init__('photo', id)
|
||||
self.photo_url = photo_url
|
||||
self.thumb_url = thumb_url
|
||||
|
||||
# Optional
|
||||
self.mime_type = mime_type
|
||||
if photo_width is not None:
|
||||
# Optionals
|
||||
if photo_width:
|
||||
self.photo_width = int(photo_width)
|
||||
if photo_height is not None:
|
||||
if photo_height:
|
||||
self.photo_height = int(photo_height)
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.caption = caption
|
||||
self.message_text = message_text
|
||||
self.parse_mode = parse_mode
|
||||
self.disable_web_page_preview = bool(disable_web_page_preview)
|
||||
if title:
|
||||
self.title = title
|
||||
if description:
|
||||
self.description = description
|
||||
if caption:
|
||||
self.caption = caption
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
"""
|
||||
Args:
|
||||
data (dict):
|
||||
data = super(InlineQueryResultPhoto,
|
||||
InlineQueryResultPhoto).de_json(data)
|
||||
|
||||
Returns:
|
||||
telegram.InlineQueryResultPhoto:
|
||||
"""
|
||||
if not data:
|
||||
return None
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultPhoto(**data)
|
||||
|
|
|
@ -20,8 +20,53 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultVenue"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultVenue(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
latitude,
|
||||
longitude,
|
||||
title,
|
||||
address,
|
||||
foursquare_id=None,
|
||||
reply_markup=None,
|
||||
input_message_content=None,
|
||||
thumb_url=None,
|
||||
thumb_width=None,
|
||||
thumb_height=None):
|
||||
|
||||
# Required
|
||||
super(InlineQueryResultVenue, self).__init__('venue', id)
|
||||
self.latitude = latitude
|
||||
self.longitude = longitude
|
||||
self.title = title
|
||||
self.address = address
|
||||
|
||||
# Optional
|
||||
if foursquare_id:
|
||||
self.foursquare_id = foursquare_id
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
if thumb_url:
|
||||
self.thumb_url = thumb_url
|
||||
if thumb_width:
|
||||
self.thumb_width = thumb_width
|
||||
if thumb_height:
|
||||
self.thumb_height = thumb_height
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultVenue,
|
||||
InlineQueryResultVenue).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultVenue(**data)
|
||||
|
|
|
@ -20,70 +20,24 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultVideo"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram.utils.validate import validate_string
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultVideo(InlineQueryResult):
|
||||
"""This object represents a Telegram InlineQueryResultVideo.
|
||||
|
||||
Attributes:
|
||||
id (str):
|
||||
video_url (str):
|
||||
mime_type (str):
|
||||
video_width (int):
|
||||
video_height (int):
|
||||
video_duration (int):
|
||||
thumb_url (str):
|
||||
title (str):
|
||||
description (str):
|
||||
caption (str):
|
||||
message_text (str):
|
||||
parse_mode (str):
|
||||
disable_web_page_preview (bool):
|
||||
|
||||
Args:
|
||||
id (str): Unique identifier for this result, 1-64 Bytes
|
||||
video_url (str):
|
||||
mime_type (str):
|
||||
thumb_url (str):
|
||||
title (str):
|
||||
message_text (str):
|
||||
|
||||
Keyword Args:
|
||||
video_width (Optional[int]):
|
||||
video_height (Optional[int]):
|
||||
video_duration (Optional[int]):
|
||||
description (Optional[str]):
|
||||
caption (Optional[str]):
|
||||
parse_mode (Optional[str]):
|
||||
disable_web_page_preview (Optional[bool]):
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
id,
|
||||
video_url,
|
||||
mime_type,
|
||||
thumb_url,
|
||||
title,
|
||||
message_text,
|
||||
caption=None,
|
||||
video_width=None,
|
||||
video_height=None,
|
||||
video_duration=None,
|
||||
description=None,
|
||||
caption=None,
|
||||
parse_mode=None,
|
||||
disable_web_page_preview=None,
|
||||
**kwargs):
|
||||
|
||||
validate_string(video_url, 'video_url')
|
||||
validate_string(mime_type, 'mime_type')
|
||||
validate_string(thumb_url, 'thumb_url')
|
||||
validate_string(title, 'title')
|
||||
validate_string(message_text, 'message_text')
|
||||
validate_string(description, 'description')
|
||||
validate_string(caption, 'caption')
|
||||
validate_string(parse_mode, 'parse_mode')
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
|
||||
# Required
|
||||
super(InlineQueryResultVideo, self).__init__('video', id)
|
||||
|
@ -91,30 +45,31 @@ class InlineQueryResultVideo(InlineQueryResult):
|
|||
self.mime_type = mime_type
|
||||
self.thumb_url = thumb_url
|
||||
self.title = title
|
||||
self.message_text = message_text
|
||||
|
||||
# Optional
|
||||
if video_width is not None:
|
||||
self.video_width = int(video_width)
|
||||
if video_height is not None:
|
||||
self.video_height = int(video_height)
|
||||
if video_duration is not None:
|
||||
self.video_duration = int(video_duration)
|
||||
self.description = description
|
||||
self.caption = caption
|
||||
self.parse_mode = parse_mode
|
||||
self.disable_web_page_preview = bool(disable_web_page_preview)
|
||||
if caption:
|
||||
self.caption = caption
|
||||
if video_width:
|
||||
self.video_width = video_width
|
||||
if video_height:
|
||||
self.video_height = video_height
|
||||
if video_duration:
|
||||
self.video_duration = video_duration
|
||||
if description:
|
||||
self.description = description
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
"""
|
||||
Args:
|
||||
data (dict):
|
||||
data = super(InlineQueryResultVideo,
|
||||
InlineQueryResultVideo).de_json(data)
|
||||
|
||||
Returns:
|
||||
telegram.InlineQueryResultVideo:
|
||||
"""
|
||||
if not data:
|
||||
return None
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultVideo(**data)
|
||||
|
|
|
@ -20,8 +20,40 @@
|
|||
"""This module contains the classes that represent Telegram
|
||||
InlineQueryResultVoice"""
|
||||
|
||||
from telegram import InlineQueryResult
|
||||
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||
InputMessageContent
|
||||
|
||||
|
||||
class InlineQueryResultVoice(InlineQueryResult):
|
||||
pass
|
||||
def __init__(self,
|
||||
id,
|
||||
voice_url,
|
||||
title,
|
||||
voice_duration=None,
|
||||
reply_markup=None,
|
||||
input_message_content=None):
|
||||
|
||||
# Required
|
||||
super(InlineQueryResultVoice, self).__init__('voice', id)
|
||||
self.voice_url = voice_url
|
||||
self.title = title
|
||||
|
||||
# Optional
|
||||
if voice_duration:
|
||||
self.voice_duration = voice_duration
|
||||
if reply_markup:
|
||||
self.reply_markup = reply_markup
|
||||
if input_message_content:
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineQueryResultVoice,
|
||||
InlineQueryResultVoice).de_json(data)
|
||||
|
||||
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||
data.get('reply_markup'))
|
||||
data['input_message_content'] = InputMessageContent.de_json(
|
||||
data.get('input_message_content'))
|
||||
|
||||
return InlineQueryResultVoice(**data)
|
||||
|
|
|
@ -47,7 +47,7 @@ class MessageEntity(TelegramObject):
|
|||
self.url = url
|
||||
|
||||
@staticmethod
|
||||
def de_json(self):
|
||||
def de_json(data):
|
||||
data = super(MessageEntity, MessageEntity).de_json(data)
|
||||
|
||||
return MessageEntity(**data)
|
||||
return MessageEntity(**data)
|
||||
|
|
|
@ -46,9 +46,9 @@ class Venue(TelegramObject):
|
|||
self.foursquare_id = foursquare_id
|
||||
|
||||
@staticmethod
|
||||
def de_json(self):
|
||||
def de_json(data):
|
||||
data = super(Venue, Venue).de_json(data)
|
||||
|
||||
data['location'] = Location.de_json(data.get('location'))
|
||||
|
||||
return Venue(**data)
|
||||
return Venue(**data)
|
||||
|
|
|
@ -632,7 +632,7 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
self.assertRaises(ValueError, Updater)
|
||||
|
||||
|
||||
class MockBot:
|
||||
class MockBot(object):
|
||||
|
||||
def __init__(self, text, messages=1, raise_error=False,
|
||||
bootstrap_retries=None, bootstrap_err=TelegramError('test')):
|
||||
|
|
Loading…
Reference in a new issue