mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-23 06:50:29 +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
|
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
|
@log
|
||||||
@message
|
@message
|
||||||
def sendChatAction(self,
|
def sendChatAction(self,
|
||||||
|
|
|
@ -77,7 +77,7 @@ def run_async(func):
|
||||||
return async_func
|
return async_func
|
||||||
|
|
||||||
|
|
||||||
class Dispatcher:
|
class Dispatcher(object):
|
||||||
"""
|
"""
|
||||||
This class dispatches all kinds of updates to its registered handlers.
|
This class dispatches all kinds of updates to its registered handlers.
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ class Dispatcher:
|
||||||
if self.__stop_event.is_set():
|
if self.__stop_event.is_set():
|
||||||
self.logger.debug('orderly stopping')
|
self.logger.debug('orderly stopping')
|
||||||
break
|
break
|
||||||
elif self.__stop_event.is_set():
|
elif self.__exception_event.is_set():
|
||||||
self.logger.critical(
|
self.logger.critical(
|
||||||
'stopping due to exception in another thread')
|
'stopping due to exception in another thread')
|
||||||
break
|
break
|
||||||
|
|
|
@ -43,7 +43,7 @@ from telegram.utils.webhookhandler import (WebhookServer, WebhookHandler)
|
||||||
logging.getLogger(__name__).addHandler(NullHandler())
|
logging.getLogger(__name__).addHandler(NullHandler())
|
||||||
|
|
||||||
|
|
||||||
class Updater:
|
class Updater(object):
|
||||||
"""
|
"""
|
||||||
This class, which employs the Dispatcher class, provides a frontend to
|
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
|
telegram.Bot to the programmer, so they can focus on coding the bot. Its
|
||||||
|
|
|
@ -45,14 +45,4 @@ class InlineQueryResult(TelegramObject):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
"""
|
return super(InlineQueryResult, InlineQueryResult).de_json(data)
|
||||||
Args:
|
|
||||||
data (dict):
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
telegram.InlineQueryResult:
|
|
||||||
"""
|
|
||||||
if not data:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return InlineQueryResult(**data)
|
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
"""This module contains the classes that represent Telegram
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultArticle"""
|
InlineQueryResultArticle"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
from telegram.utils.validate import validate_string
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultArticle(InlineQueryResult):
|
class InlineQueryResultArticle(InlineQueryResult):
|
||||||
|
@ -30,9 +30,8 @@ class InlineQueryResultArticle(InlineQueryResult):
|
||||||
Attributes:
|
Attributes:
|
||||||
id (str):
|
id (str):
|
||||||
title (str):
|
title (str):
|
||||||
message_text (str):
|
input_message_content (telegram.InputMessageContent):
|
||||||
parse_mode (str):
|
reply_markup (telegram.ReplyMarkup):
|
||||||
disable_web_page_preview (bool):
|
|
||||||
url (str):
|
url (str):
|
||||||
hide_url (bool):
|
hide_url (bool):
|
||||||
description (str):
|
description (str):
|
||||||
|
@ -43,11 +42,9 @@ class InlineQueryResultArticle(InlineQueryResult):
|
||||||
Args:
|
Args:
|
||||||
id (str): Unique identifier for this result, 1-64 Bytes
|
id (str): Unique identifier for this result, 1-64 Bytes
|
||||||
title (str):
|
title (str):
|
||||||
message_text (str):
|
reply_markup (telegram.ReplyMarkup):
|
||||||
|
|
||||||
Keyword Args:
|
Keyword Args:
|
||||||
parse_mode (Optional[str]):
|
|
||||||
disable_web_page_preview (Optional[bool]):
|
|
||||||
url (Optional[str]):
|
url (Optional[str]):
|
||||||
hide_url (Optional[bool]):
|
hide_url (Optional[bool]):
|
||||||
description (Optional[str]):
|
description (Optional[str]):
|
||||||
|
@ -59,51 +56,44 @@ class InlineQueryResultArticle(InlineQueryResult):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
id,
|
id,
|
||||||
title,
|
title,
|
||||||
message_text,
|
input_message_content,
|
||||||
parse_mode=None,
|
reply_markup=None,
|
||||||
disable_web_page_preview=None,
|
|
||||||
url=None,
|
url=None,
|
||||||
hide_url=None,
|
hide_url=None,
|
||||||
description=None,
|
description=None,
|
||||||
thumb_url=None,
|
thumb_url=None,
|
||||||
thumb_width=None,
|
thumb_width=None,
|
||||||
thumb_height=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')
|
|
||||||
|
|
||||||
# Required
|
# Required
|
||||||
super(InlineQueryResultArticle, self).__init__('article', id)
|
super(InlineQueryResultArticle, self).__init__('article', id)
|
||||||
self.title = title
|
self.title = title
|
||||||
self.message_text = message_text
|
self.input_message_content = input_message_content
|
||||||
|
|
||||||
# Optional
|
# Optional
|
||||||
self.parse_mode = parse_mode
|
if reply_markup:
|
||||||
self.disable_web_page_preview = bool(disable_web_page_preview)
|
self.reply_markup = reply_markup
|
||||||
self.url = url
|
if url:
|
||||||
self.hide_url = bool(hide_url)
|
self.url = url
|
||||||
self.description = description
|
if hide_url:
|
||||||
self.thumb_url = thumb_url
|
self.hide_url = hide_url
|
||||||
if thumb_width is not None:
|
if description:
|
||||||
self.thumb_width = int(thumb_width)
|
self.description = description
|
||||||
if thumb_height is not None:
|
if thumb_url:
|
||||||
self.thumb_height = int(thumb_height)
|
self.thumb_url = thumb_url
|
||||||
|
if thumb_width:
|
||||||
|
self.thumb_width = thumb_width
|
||||||
|
if thumb_height:
|
||||||
|
self.thumb_height = thumb_height
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
"""
|
data = super(InlineQueryResultArticle,
|
||||||
Args:
|
InlineQueryResultArticle).de_json(data)
|
||||||
data (dict):
|
|
||||||
|
|
||||||
Returns:
|
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||||
telegram.InlineQueryResultArticle:
|
data.get('reply_markup'))
|
||||||
"""
|
data['input_message_content'] = InputMessageContent.de_json(
|
||||||
if not data:
|
data.get('input_message_content'))
|
||||||
return None
|
|
||||||
|
|
||||||
return InlineQueryResultArticle(**data)
|
return InlineQueryResultArticle(**data)
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
"""This module contains the classes that represent Telegram
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultAudio"""
|
InlineQueryResultAudio"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultAudio(InlineQueryResult):
|
class InlineQueryResultAudio(InlineQueryResult):
|
||||||
|
@ -38,10 +39,24 @@ class InlineQueryResultAudio(InlineQueryResult):
|
||||||
self.audio_url = audio_url
|
self.audio_url = audio_url
|
||||||
self.title = title
|
self.title = title
|
||||||
|
|
||||||
# Optional
|
# Optionals
|
||||||
self.performer = performer
|
if performer:
|
||||||
self.audio_duration = audio_duration
|
self.performer = performer
|
||||||
if reply_markup is not None:
|
if audio_duration:
|
||||||
self.reply_markup = 'ReplyMarkup' # TODO
|
self.audio_duration = audio_duration
|
||||||
if input_message_content is not None:
|
if reply_markup:
|
||||||
self.input_message_content = 'InputMessageContent'
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultCachedAudio"""
|
InlineQueryResultCachedAudio"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultCachedAudio(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultCachedDocument"""
|
InlineQueryResultCachedDocument"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultCachedDocument(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultCachedGif"""
|
InlineQueryResultCachedGif"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultCachedGif(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultMpeg4Gif"""
|
InlineQueryResultMpeg4Gif"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultPhoto"""
|
InlineQueryResultPhoto"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultCachedPhoto(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultCachedSticker"""
|
InlineQueryResultCachedSticker"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultCachedSticker(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultCachedVideo"""
|
InlineQueryResultCachedVideo"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultCachedVideo(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultCachedVoice"""
|
InlineQueryResultCachedVoice"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultCachedVoice(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultContact"""
|
InlineQueryResultContact"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultContact(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultDocument"""
|
InlineQueryResultDocument"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultDocument(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultGif"""
|
InlineQueryResultGif"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
from telegram.utils.validate import validate_string
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultGif(InlineQueryResult):
|
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,
|
def __init__(self,
|
||||||
id,
|
id,
|
||||||
gif_url,
|
gif_url,
|
||||||
|
@ -62,44 +33,36 @@ class InlineQueryResultGif(InlineQueryResult):
|
||||||
gif_height=None,
|
gif_height=None,
|
||||||
title=None,
|
title=None,
|
||||||
caption=None,
|
caption=None,
|
||||||
message_text=None,
|
reply_markup=None,
|
||||||
parse_mode=None,
|
input_message_content=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')
|
|
||||||
|
|
||||||
# Required
|
# Required
|
||||||
super(InlineQueryResultGif, self).__init__('gif', id)
|
super(InlineQueryResultGif, self).__init__('gif', id)
|
||||||
self.gif_url = gif_url
|
self.gif_url = gif_url
|
||||||
self.thumb_url = thumb_url
|
self.thumb_url = thumb_url
|
||||||
|
|
||||||
# Optional
|
# Optionals
|
||||||
if gif_width is not None:
|
if gif_width:
|
||||||
self.gif_width = int(gif_width)
|
self.gif_width = gif_width
|
||||||
if gif_height is not None:
|
if gif_height:
|
||||||
self.gif_height = int(gif_height)
|
self.gif_height = gif_height
|
||||||
self.title = title
|
if title:
|
||||||
self.caption = caption
|
self.title = title
|
||||||
self.message_text = message_text
|
if caption:
|
||||||
self.parse_mode = parse_mode
|
self.caption = caption
|
||||||
self.disable_web_page_preview = bool(disable_web_page_preview)
|
if reply_markup:
|
||||||
|
self.reply_markup = reply_markup
|
||||||
|
if input_message_content:
|
||||||
|
self.input_message_content = input_message_content
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
"""
|
data = super(InlineQueryResultGif,
|
||||||
Args:
|
InlineQueryResultGif).de_json(data)
|
||||||
data (dict):
|
|
||||||
|
|
||||||
Returns:
|
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||||
telegram.InlineQueryResultGif:
|
data.get('reply_markup'))
|
||||||
"""
|
data['input_message_content'] = InputMessageContent.de_json(
|
||||||
if not data:
|
data.get('input_message_content'))
|
||||||
return None
|
|
||||||
|
|
||||||
return InlineQueryResultGif(**data)
|
return InlineQueryResultGif(**data)
|
||||||
|
|
|
@ -20,8 +20,47 @@
|
||||||
"""This module contains the classes that represent Telegram
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultLocation"""
|
InlineQueryResultLocation"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultLocation(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultMpeg4Gif"""
|
InlineQueryResultMpeg4Gif"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
from telegram.utils.validate import validate_string
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
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,
|
def __init__(self,
|
||||||
id,
|
id,
|
||||||
mpeg4_url,
|
mpeg4_url,
|
||||||
|
@ -62,17 +33,8 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
||||||
mpeg4_height=None,
|
mpeg4_height=None,
|
||||||
title=None,
|
title=None,
|
||||||
caption=None,
|
caption=None,
|
||||||
message_text=None,
|
reply_markup=None,
|
||||||
parse_mode=None,
|
input_message_content=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')
|
|
||||||
|
|
||||||
# Required
|
# Required
|
||||||
super(InlineQueryResultMpeg4Gif, self).__init__('mpeg4_gif', id)
|
super(InlineQueryResultMpeg4Gif, self).__init__('mpeg4_gif', id)
|
||||||
|
@ -80,26 +42,27 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
||||||
self.thumb_url = thumb_url
|
self.thumb_url = thumb_url
|
||||||
|
|
||||||
# Optional
|
# Optional
|
||||||
if mpeg4_width is not None:
|
if mpeg4_width:
|
||||||
self.mpeg4_width = int(mpeg4_width)
|
self.mpeg4_width = mpeg4_width
|
||||||
if mpeg4_height is not None:
|
if mpeg4_height:
|
||||||
self.mpeg4_height = int(mpeg4_height)
|
self.mpeg4_height = mpeg4_height
|
||||||
self.title = title
|
if title:
|
||||||
self.caption = caption
|
self.title = title
|
||||||
self.message_text = message_text
|
if caption:
|
||||||
self.parse_mode = parse_mode
|
self.caption = caption
|
||||||
self.disable_web_page_preview = bool(disable_web_page_preview)
|
if reply_markup:
|
||||||
|
self.reply_markup = reply_markup
|
||||||
|
if input_message_content:
|
||||||
|
self.input_message_content = input_message_content
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
"""
|
data = super(InlineQueryResultMpeg4Gif,
|
||||||
Args:
|
InlineQueryResultMpeg4Gif).de_json(data)
|
||||||
data (dict):
|
|
||||||
|
|
||||||
Returns:
|
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||||
telegram.InlineQueryResultMpeg4Gif:
|
data.get('reply_markup'))
|
||||||
"""
|
data['input_message_content'] = InputMessageContent.de_json(
|
||||||
if not data:
|
data.get('input_message_content'))
|
||||||
return None
|
|
||||||
|
|
||||||
return InlineQueryResultMpeg4Gif(**data)
|
return InlineQueryResultMpeg4Gif(**data)
|
||||||
|
|
|
@ -20,96 +20,51 @@
|
||||||
"""This module contains the classes that represent Telegram
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultPhoto"""
|
InlineQueryResultPhoto"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
from telegram.utils.validate import validate_string
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultPhoto(InlineQueryResult):
|
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,
|
def __init__(self,
|
||||||
id,
|
id,
|
||||||
photo_url,
|
photo_url,
|
||||||
thumb_url,
|
thumb_url,
|
||||||
mime_type=None,
|
|
||||||
photo_width=None,
|
photo_width=None,
|
||||||
photo_height=None,
|
photo_height=None,
|
||||||
title=None,
|
title=None,
|
||||||
description=None,
|
description=None,
|
||||||
caption=None,
|
caption=None,
|
||||||
message_text=None,
|
reply_markup=None,
|
||||||
parse_mode=None,
|
input_message_content=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')
|
|
||||||
|
|
||||||
# Required
|
# Required
|
||||||
super(InlineQueryResultPhoto, self).__init__('photo', id)
|
super(InlineQueryResultPhoto, self).__init__('photo', id)
|
||||||
self.photo_url = photo_url
|
self.photo_url = photo_url
|
||||||
self.thumb_url = thumb_url
|
self.thumb_url = thumb_url
|
||||||
|
|
||||||
# Optional
|
# Optionals
|
||||||
self.mime_type = mime_type
|
if photo_width:
|
||||||
if photo_width is not None:
|
|
||||||
self.photo_width = int(photo_width)
|
self.photo_width = int(photo_width)
|
||||||
if photo_height is not None:
|
if photo_height:
|
||||||
self.photo_height = int(photo_height)
|
self.photo_height = int(photo_height)
|
||||||
self.title = title
|
if title:
|
||||||
self.description = description
|
self.title = title
|
||||||
self.caption = caption
|
if description:
|
||||||
self.message_text = message_text
|
self.description = description
|
||||||
self.parse_mode = parse_mode
|
if caption:
|
||||||
self.disable_web_page_preview = bool(disable_web_page_preview)
|
self.caption = caption
|
||||||
|
if reply_markup:
|
||||||
|
self.reply_markup = reply_markup
|
||||||
|
if input_message_content:
|
||||||
|
self.input_message_content = input_message_content
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
"""
|
data = super(InlineQueryResultPhoto,
|
||||||
Args:
|
InlineQueryResultPhoto).de_json(data)
|
||||||
data (dict):
|
|
||||||
|
|
||||||
Returns:
|
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||||
telegram.InlineQueryResultPhoto:
|
data.get('reply_markup'))
|
||||||
"""
|
data['input_message_content'] = InputMessageContent.de_json(
|
||||||
if not data:
|
data.get('input_message_content'))
|
||||||
return None
|
|
||||||
|
|
||||||
return InlineQueryResultPhoto(**data)
|
return InlineQueryResultPhoto(**data)
|
||||||
|
|
|
@ -20,8 +20,53 @@
|
||||||
"""This module contains the classes that represent Telegram
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultVenue"""
|
InlineQueryResultVenue"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultVenue(InlineQueryResult):
|
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
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultVideo"""
|
InlineQueryResultVideo"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
from telegram.utils.validate import validate_string
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultVideo(InlineQueryResult):
|
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,
|
def __init__(self,
|
||||||
id,
|
id,
|
||||||
video_url,
|
video_url,
|
||||||
mime_type,
|
mime_type,
|
||||||
thumb_url,
|
thumb_url,
|
||||||
title,
|
title,
|
||||||
message_text,
|
caption=None,
|
||||||
video_width=None,
|
video_width=None,
|
||||||
video_height=None,
|
video_height=None,
|
||||||
video_duration=None,
|
video_duration=None,
|
||||||
description=None,
|
description=None,
|
||||||
caption=None,
|
reply_markup=None,
|
||||||
parse_mode=None,
|
input_message_content=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')
|
|
||||||
|
|
||||||
# Required
|
# Required
|
||||||
super(InlineQueryResultVideo, self).__init__('video', id)
|
super(InlineQueryResultVideo, self).__init__('video', id)
|
||||||
|
@ -91,30 +45,31 @@ class InlineQueryResultVideo(InlineQueryResult):
|
||||||
self.mime_type = mime_type
|
self.mime_type = mime_type
|
||||||
self.thumb_url = thumb_url
|
self.thumb_url = thumb_url
|
||||||
self.title = title
|
self.title = title
|
||||||
self.message_text = message_text
|
|
||||||
|
|
||||||
# Optional
|
# Optional
|
||||||
if video_width is not None:
|
if caption:
|
||||||
self.video_width = int(video_width)
|
self.caption = caption
|
||||||
if video_height is not None:
|
if video_width:
|
||||||
self.video_height = int(video_height)
|
self.video_width = video_width
|
||||||
if video_duration is not None:
|
if video_height:
|
||||||
self.video_duration = int(video_duration)
|
self.video_height = video_height
|
||||||
self.description = description
|
if video_duration:
|
||||||
self.caption = caption
|
self.video_duration = video_duration
|
||||||
self.parse_mode = parse_mode
|
if description:
|
||||||
self.disable_web_page_preview = bool(disable_web_page_preview)
|
self.description = description
|
||||||
|
if reply_markup:
|
||||||
|
self.reply_markup = reply_markup
|
||||||
|
if input_message_content:
|
||||||
|
self.input_message_content = input_message_content
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(data):
|
def de_json(data):
|
||||||
"""
|
data = super(InlineQueryResultVideo,
|
||||||
Args:
|
InlineQueryResultVideo).de_json(data)
|
||||||
data (dict):
|
|
||||||
|
|
||||||
Returns:
|
data['reply_markup'] = InlineKeyboardMarkup.de_json(
|
||||||
telegram.InlineQueryResultVideo:
|
data.get('reply_markup'))
|
||||||
"""
|
data['input_message_content'] = InputMessageContent.de_json(
|
||||||
if not data:
|
data.get('input_message_content'))
|
||||||
return None
|
|
||||||
|
|
||||||
return InlineQueryResultVideo(**data)
|
return InlineQueryResultVideo(**data)
|
||||||
|
|
|
@ -20,8 +20,40 @@
|
||||||
"""This module contains the classes that represent Telegram
|
"""This module contains the classes that represent Telegram
|
||||||
InlineQueryResultVoice"""
|
InlineQueryResultVoice"""
|
||||||
|
|
||||||
from telegram import InlineQueryResult
|
from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
||||||
|
InputMessageContent
|
||||||
|
|
||||||
|
|
||||||
class InlineQueryResultVoice(InlineQueryResult):
|
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
|
self.url = url
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(self):
|
def de_json(data):
|
||||||
data = super(MessageEntity, MessageEntity).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
|
self.foursquare_id = foursquare_id
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def de_json(self):
|
def de_json(data):
|
||||||
data = super(Venue, Venue).de_json(data)
|
data = super(Venue, Venue).de_json(data)
|
||||||
|
|
||||||
data['location'] = Location.de_json(data.get('location'))
|
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)
|
self.assertRaises(ValueError, Updater)
|
||||||
|
|
||||||
|
|
||||||
class MockBot:
|
class MockBot(object):
|
||||||
|
|
||||||
def __init__(self, text, messages=1, raise_error=False,
|
def __init__(self, text, messages=1, raise_error=False,
|
||||||
bootstrap_retries=None, bootstrap_err=TelegramError('test')):
|
bootstrap_retries=None, bootstrap_err=TelegramError('test')):
|
||||||
|
|
Loading…
Reference in a new issue