From 59fa717023daf2ec028ef22c5216250f260fb2fd Mon Sep 17 00:00:00 2001 From: Noam Meltzer Date: Mon, 17 Oct 2016 01:11:20 +0300 Subject: [PATCH] Documentation improvements + small style fixes --- telegram/audio.py | 5 +- telegram/bot.py | 881 ++++++++------------ telegram/chat.py | 11 +- telegram/chatmember.py | 3 +- telegram/choseninlineresult.py | 5 + telegram/contact.py | 5 +- telegram/document.py | 5 +- telegram/file.py | 4 +- telegram/forcereply.py | 5 +- telegram/inlinekeyboardbutton.py | 4 +- telegram/inlinekeyboardmarkup.py | 2 + telegram/inlinequery.py | 5 +- telegram/inlinequeryresult.py | 7 +- telegram/inlinequeryresultarticle.py | 7 +- telegram/inlinequeryresultaudio.py | 14 +- telegram/inlinequeryresultcachedaudio.py | 21 +- telegram/inlinequeryresultcacheddocument.py | 29 +- telegram/inlinequeryresultcachedgif.py | 23 + telegram/inlinequeryresultcachedmpeg4gif.py | 24 + telegram/message.py | 4 +- 20 files changed, 476 insertions(+), 588 deletions(-) diff --git a/telegram/audio.py b/telegram/audio.py index 0b49e9396..4754ba5f4 100644 --- a/telegram/audio.py +++ b/telegram/audio.py @@ -35,13 +35,12 @@ class Audio(TelegramObject): Args: file_id (str): duration (int): - **kwargs: Arbitrary keyword arguments. - - Keyword Args: performer (Optional[str]): title (Optional[str]): mime_type (Optional[str]): file_size (Optional[int]): + **kwargs: Arbitrary keyword arguments. + """ def __init__(self, diff --git a/telegram/bot.py b/telegram/bot.py index 9d788ed48..aeffafce2 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -163,15 +163,13 @@ class Bot(TelegramObject): """A simple method for testing your bot's auth token. Returns: - :class:`telegram.User`: A :class:`telegram.User` instance - representing that bot if the credentials are valid, `None` - otherwise. + :class:`telegram.User`: A :class:`telegram.User` instance representing that bot if the + credentials are valid, `None` otherwise. Raises: :class:`telegram.TelegramError` """ - url = '{0}/getMe'.format(self.base_url) result = self._request.get(url) @@ -205,9 +203,6 @@ class Bot(TelegramObject): URLs in your bot's message. disable_web_page_preview (Optional[bool]): Disables link previews for links in this message. - **kwargs (dict): Arbitrary keyword arguments. - - Keyword Args: disable_notification (Optional[bool]): Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound. @@ -219,16 +214,15 @@ class Bot(TelegramObject): keyboard or to force a reply from the user. timeout (Optional[float]): If this value is specified, use it as the definitive timeout (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, the sent message is - returned. + :class:`telegram.Message`: On success, the sent message is returned. Raises: :class:`telegram.TelegramError` """ - url = '{0}/sendMessage'.format(self.base_url) data = {'chat_id': chat_id, 'text': text} @@ -252,30 +246,23 @@ class Bot(TelegramObject): """Use this method to forward messages of any kind. Args: - chat_id: - Unique identifier for the message recipient - Chat id. - from_chat_id: - Unique identifier for the chat where the original message was sent - - Chat id. - message_id: - Unique message identifier. - - Keyword Args: - disable_notification (Optional[bool]): Sends the message silently. - iOS users will not receive a notification, Android users will - receive a notification with no sound. + chat_id: Unique identifier for the message recipient - Chat id. + from_chat_id: Unique identifier for the chat where the original message was sent + - Chat id. + message_id: Unique message identifier. + disable_notification (Optional[bool]): Sends the message silently. iOS users will not + receive a notification, Android users will receive a notification with no sound. timeout (Optional[float]): If this value is specified, use it as the definitive timeout (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, instance representing the - message forwarded. + :class:`telegram.Message`: On success, instance representing the message forwarded. Raises: :class:`telegram.TelegramError` """ - url = '{0}/forwardMessage'.format(self.base_url) data = {} @@ -303,38 +290,29 @@ class Bot(TelegramObject): """Use this method to send photos. Args: - chat_id: - Unique identifier for the message recipient - Chat id. - photo: - Photo to send. You can either pass a file_id as String to resend a - photo that is already on the Telegram servers, or upload a new - photo using multipart/form-data. - caption: - Photo caption (may also be used when resending photos by file_id). - [Optional] - - Keyword Args: - disable_notification (Optional[bool]): Sends the message silently. - iOS users will not receive a notification, Android users will - receive a notification with no sound. - reply_to_message_id (Optional[int]): If the message is a reply, - ID of the original message. - reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the message recipient - Chat id. + photo: Photo to send. You can either pass a file_id as String to resend a photo that is + already on the Telegram servers, or upload a new photo using multipart/form-data. + caption (Optional[str]): Photo caption (may also be used when resending photos by + file_id). + disable_notification (Optional[bool]): Sends the message silently. iOS users will not + receive a notification, Android users will receive a notification with no sound. + reply_to_message_id (Optional[int]): If the message is a reply, ID of the original + message. + reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, instance representing the - message posted. + :class:`telegram.Message`: On success, instance representing the message posted. Raises: :class:`telegram.TelegramError` """ - url = '{0}/sendPhoto'.format(self.base_url) data = {'chat_id': chat_id, 'photo': photo} @@ -369,41 +347,31 @@ class Bot(TelegramObject): use sendVoice method instead. Args: - chat_id: - Unique identifier for the message recipient - Chat id. - audio: - Audio file to send. You can either pass a file_id as String to - resend an audio that is already on the Telegram servers, or upload - a new audio file using multipart/form-data. - duration: - Duration of sent audio in seconds. [Optional] - performer: - Performer of sent audio. [Optional] - title: - Title of sent audio. [Optional] - - Keyword Args: - disable_notification (Optional[bool]): Sends the message silently. - iOS users will not receive a notification, Android users will - receive a notification with no sound. - reply_to_message_id (Optional[int]): If the message is a reply, - ID of the original message. - reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the message recipient - Chat id. + audio Audio file to send. You can either pass a file_id as String to resend an audio + that is already on the Telegram servers, or upload a new audio file using + multipart/form-data. + duration (Optional[int]): Duration of sent audio in seconds. + performer: Performer of sent audio. [Optional] + title: Title of sent audio. [Optional] + disable_notification (Optional[bool]): Sends the message silently. iOS users will not + receive a notification, Android users will receive a notification with no sound. + reply_to_message_id (Optional[int]): If the message is a reply, ID of the original + message. + reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, instance representing the - message posted. + :class:`telegram.Message`: On success, instance representing the message posted. Raises: :class:`telegram.TelegramError` """ - url = '{0}/sendAudio'.format(self.base_url) data = {'chat_id': chat_id, 'audio': audio} @@ -432,41 +400,31 @@ class Bot(TelegramObject): """Use this method to send general files. Args: - chat_id: - Unique identifier for the message recipient - Chat id. - document: - File to send. You can either pass a file_id as String to resend a - file that is already on the Telegram servers, or upload a new file - using multipart/form-data. - filename: - File name that shows in telegram message (it is usefull when you - send file generated by temp module, for example). [Optional] - caption: - Document caption (may also be used when resending documents by - file_id), 0-200 characters. [Optional] - - Keyword Args: - disable_notification (Optional[bool]): Sends the message silently. - iOS users will not receive a notification, Android users will - receive a notification with no sound. - reply_to_message_id (Optional[int]): If the message is a reply, - ID of the original message. - reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the message recipient - Chat id. + document: File to send. You can either pass a file_id as String to resend a file that + is already on the Telegram servers, or upload a new file using multipart/form-data. + filename: File name that shows in telegram message (it is usefull when you send file + generated by temp module, for example). [Optional] + caption (Optional[str]): Document caption (may also be used when resending documents by + file_id), 0-200 characters. + disable_notification (Optional[bool]): Sends the message silently. iOS users will not + receive a notification, Android users will receive a notification with no sound. + reply_to_message_id (Optional[int]): If the message is a reply, ID of the original + message. + reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, instance representing the - message posted. + :class:`telegram.Message`: On success, instance representing the message posted. Raises: :class:`telegram.TelegramError` """ - url = '{0}/sendDocument'.format(self.base_url) data = {'chat_id': chat_id, 'document': document} @@ -491,35 +449,28 @@ class Bot(TelegramObject): """Use this method to send .webp stickers. Args: - chat_id: - Unique identifier for the message recipient - Chat id. - sticker: - Sticker to send. You can either pass a file_id as String to resend - a sticker that is already on the Telegram servers, or upload a new - sticker using multipart/form-data. - - Keyword Args: - disable_notification (Optional[bool]): Sends the message silently. - iOS users will not receive a notification, Android users will - receive a notification with no sound. - reply_to_message_id (Optional[int]): If the message is a reply, - ID of the original message. - reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the message recipient - Chat id. + sticker: Sticker to send. You can either pass a file_id as String to resend a sticker + that is already on the Telegram servers, or upload a new sticker using + multipart/form-data. + disable_notification (Optional[bool]): Sends the message silently. iOS users will not + receive a notification, Android users will receive a notification with no sound. + reply_to_message_id (Optional[int]): If the message is a reply, ID of the original + message. + reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, instance representing the - message posted. + :class:`telegram.Message`: On success, instance representing the message posted. Raises: :class:`telegram.TelegramError` """ - url = '{0}/sendSticker'.format(self.base_url) data = {'chat_id': chat_id, 'sticker': sticker} @@ -542,40 +493,30 @@ class Bot(TelegramObject): videos (other formats may be sent as telegram.Document). Args: - chat_id: - Unique identifier for the message recipient - Chat id. - video: - Video to send. You can either pass a file_id as String to resend a - video that is already on the Telegram servers, or upload a new - video file using multipart/form-data. - duration: - Duration of sent video in seconds. [Optional] - caption: - Video caption (may also be used when resending videos by file_id). - [Optional] - - Keyword Args: - disable_notification (Optional[bool]): Sends the message silently. - iOS users will not receive a notification, Android users will - receive a notification with no sound. - reply_to_message_id (Optional[int]): If the message is a reply, - ID of the original message. - reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the message recipient - Chat id. + video: Video to send. You can either pass a file_id as String to resend a video that is + already on the Telegram servers, or upload a new video file using + multipart/form-data. + duration (Optional[int]): Duration of sent video in seconds. + caption (Optional[str]): Video caption (may also be used when resending videos by + file_id). + disable_notification (Optional[bool]): Sends the message silently. iOS users will not + receive a notification, Android users will receive a notification with no sound. + reply_to_message_id (Optional[int]): If the message is a reply, ID of the original + message. + reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. Returns: - :class:`telegram.Message`: On success, instance representing the - message posted. + :class:`telegram.Message`: On success, instance representing the message posted. Raises: :class:`telegram.TelegramError` """ - url = '{0}/sendVideo'.format(self.base_url) data = {'chat_id': chat_id, 'video': video} @@ -598,45 +539,36 @@ class Bot(TelegramObject): reply_markup=None, timeout=None, **kwargs): - """Use this method to send audio files, if you want Telegram clients to - display the file as a playable voice message. For this to work, your - audio must be in an .ogg file encoded with OPUS (other formats may be - sent as Audio or Document). On success, the sent Message is returned. - Bots can currently send audio files of up to 50 MB in size, this limit - may be changed in the future. + """Use this method to send audio files, if you want Telegram clients to display the file as + a playable voice message. For this to work, your audio must be in an .ogg file encoded with + OPUS (other formats may be sent as Audio or Document). On success, the sent Message is + returned. Bots can currently send audio files of up to 50 MB in size, this limit may be + changed in the future. Args: - chat_id: - Unique identifier for the message recipient - Chat id. - voice: - Audio file to send. You can either pass a file_id as String to - resend an audio that is already on the Telegram servers, or upload - a new audio file using multipart/form-data. - duration: - Duration of sent audio in seconds. [Optional] - - Keyword Args: - disable_notification (Optional[bool]): Sends the message silently. - iOS users will not receive a notification, Android users will - receive a notification with no sound. - reply_to_message_id (Optional[int]): If the message is a reply, - ID of the original message. - reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the message recipient - Chat id. + voice: Audio file to send. You can either pass a file_id as String to resend an audio + that is already on the Telegram servers, or upload a new audio file using + multipart/form-data. + duration (Optional[int]): Duration of sent audio in seconds. + disable_notification (Optional[bool]): Sends the message silently. iOS users will not + receive a notification, Android users will receive a notification with no sound. + reply_to_message_id (Optional[int]): If the message is a reply, ID of the original + message. + reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, instance representing the - message posted. + :class:`telegram.Message`: On success, instance representing the message posted. Raises: :class:`telegram.TelegramError` """ - url = '{0}/sendVoice'.format(self.base_url) data = {'chat_id': chat_id, 'voice': voice} @@ -660,35 +592,27 @@ class Bot(TelegramObject): """Use this method to send point on the map. Args: - chat_id: - Unique identifier for the message recipient - Chat id. - latitude: - Latitude of location. - longitude: - Longitude of location. - - Keyword Args: - disable_notification (Optional[bool]): Sends the message silently. - iOS users will not receive a notification, Android users will - receive a notification with no sound. - reply_to_message_id (Optional[int]): If the message is a reply, - ID of the original message. - reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the message recipient - Chat id. + latitude (float): Latitude of location. + longitude (float): Longitude of location. + disable_notification (Optional[bool]): Sends the message silently. iOS users will not + receive a notification, Android users will receive a notification with no sound. + reply_to_message_id (Optional[int]): If the message is a reply, ID of the original + message. + reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, instance representing the - message posted. + :class:`telegram.Message`: On success, instance representing the message posted. Raises: :class:`telegram.TelegramError` """ - url = '{0}/sendLocation'.format(self.base_url) data = {'chat_id': chat_id, 'latitude': latitude, 'longitude': longitude} @@ -713,42 +637,31 @@ class Bot(TelegramObject): 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. - - Keyword Args: - disable_notification (Optional[bool]): Sends the message silently. - iOS users will not receive a notification, Android users will - receive a notification with no sound. - reply_to_message_id (Optional[int]): If the message is a reply, - ID of the original message. - reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the target chat or username of the target channel (in + the format @channelusername). + latitude (float): Latitude of the venue. + longitude (float): Longitude of the venue. + title (str): Name of the venue. + address (str): Address of the venue. + foursquare_id (Optional[str]): Foursquare identifier of the venue. + disable_notification (Optional[bool]): Sends the message silently. iOS users will not + receive a notification, Android users will receive a notification with no sound. + reply_to_message_id (Optional[int]): If the message is a reply, ID of the original + message. + reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, instance representing the - message posted. + :class:`telegram.Message`: On success, instance representing the message posted. Raises: :class:`telegram.TelegramError` """ - url = '{0}/sendVenue'.format(self.base_url) data = {'chat_id': chat_id, @@ -778,38 +691,29 @@ class Bot(TelegramObject): 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. - - Keyword Args: - disable_notification (Optional[bool]): Sends the message silently. - iOS users will not receive a notification, Android users will - receive a notification with no sound. - reply_to_message_id (Optional[int]): If the message is a reply, - ID of the original message. - reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the target chat or username of the target channel (in + the format @channelusername). + phone_number (str): Contact's phone number. + first_name (str): Contact's first name. + last_name (Optional[str]): Contact's last name. + disable_notification (Optional[bool]): Sends the message silently. iOS users will not + receive a notification, Android users will receive a notification with no sound. + reply_to_message_id (Optional[int]): If the message is a reply, ID of the original + message. + reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, instance representing the - message posted. + :class:`telegram.Message`: On success, instance representing the message posted. Raises: :class:`telegram.TelegramError` """ - url = '{0}/sendContact'.format(self.base_url) data = {'chat_id': chat_id, 'phone_number': phone_number, 'first_name': first_name} @@ -822,25 +726,23 @@ class Bot(TelegramObject): @log @message def sendChatAction(self, chat_id, action, **kwargs): - """Use this method when you need to tell the user that something is - happening on the bot's side. The status is set for 5 seconds or less - (when a message arrives from your bot, Telegram clients clear its - typing status). + """Use this method when you need to tell the user that something is happening on the bot's + side. The status is set for 5 seconds or less (when a message arrives from your bot, + Telegram clients clear its typing status). Args: - chat_id: - Unique identifier for the message recipient - Chat id. - action: - Type of action to broadcast. Choose one, depending on what the user - is about to receive: - - ChatAction.TYPING for text messages, - - ChatAction.UPLOAD_PHOTO for photos, - - ChatAction.UPLOAD_VIDEO for videos, - - ChatAction.UPLOAD_AUDIO for audio files, - - ChatAction.UPLOAD_DOCUMENT for general files, - - ChatAction.FIND_LOCATION for location data. - """ + chat_id: Unique identifier for the message recipient - Chat id. + action: Type of action to broadcast. Choose one, depending on what the user is about to + receive: + - ChatAction.TYPING for text messages, + - ChatAction.UPLOAD_PHOTO for photos, + - ChatAction.UPLOAD_VIDEO for videos, + - ChatAction.UPLOAD_AUDIO for audio files, + - ChatAction.UPLOAD_DOCUMENT for general files, + - ChatAction.FIND_LOCATION for location data. + **kwargs (dict): Arbitrary keyword arguments. + """ url = '{0}/sendChatAction'.format(self.base_url) data = {'chat_id': chat_id, 'action': action} @@ -858,34 +760,30 @@ class Bot(TelegramObject): switch_pm_parameter=None, timeout=None, **kwargs): - """Use this method to send answers to an inline query. No more than - 50 results per query are allowed. + """Use this method to send answers to an inline query. No more than 50 results per query + are allowed. Args: inline_query_id (str): Unique identifier for the answered query. - results (list[:class:`telegram.InlineQueryResult`]): A list of - results for the inline query. - - Keyword Args: - cache_time (Optional[int]): The maximum amount of time the - result of the inline query may be cached on the server. - is_personal (Optional[bool]): Pass `True`, if results may be - cached on the server side only for the user that sent the - query. By default, results may be returned to any user who - sends the same query. - next_offset (Optional[str]): Pass the offset that a client - should send in the next query with the same text to receive - more results. Pass an empty string if there are no more - results or if you don't support pagination. Offset length - can't exceed 64 bytes. - switch_pm_text (Optional[str]): If passed, clients will display - a button with specified text that switches the user to a - private chat with the bot and sends the bot a start message - with the parameter switch_pm_parameter. - switch_pm_parameter (Optional[str]): Parameter for the start - message sent to the bot when user presses the switch button. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + results (list[:class:`telegram.InlineQueryResult`]): A list of results for the inline + query. + cache_time (Optional[int]): The maximum amount of time the result of the inline query + may be cached on the server. + is_personal (Optional[bool]): Pass `True`, if results may be cached on the server side + only for the user that sent the query. By default, results may be returned to any + user who sends the same query. + next_offset (Optional[str]): Pass the offset that a client should send in the next + query with the same text to receive more results. Pass an empty string if there are + no more results or if you don't support pagination. Offset length can't exceed 64 + bytes. + switch_pm_text (Optional[str]): If passed, clients will display a button with specified + text that switches the user to a private chat with the bot and sends the bot a + start message with the parameter switch_pm_parameter. + switch_pm_parameter (Optional[str]): Parameter for the start message sent to the bot + when user presses the switch button. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: bool: On success, `True` is returned. @@ -894,7 +792,6 @@ class Bot(TelegramObject): :class:`telegram.TelegramError` """ - url = '{0}/answerInlineQuery'.format(self.base_url) results = [res.to_dict() for res in results] @@ -921,28 +818,23 @@ class Bot(TelegramObject): """Use this method to get a list of profile pictures for a user. Args: - user_id: - Unique identifier of the target user. - offset: - Sequential number of the first photo to be returned. By default, - all photos are returned. [Optional] - limit: - Limits the number of photos to be retrieved. Values between 1-100 - are accepted. Defaults to 100. [Optional] - - Keyword Args: - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + user_id: Unique identifier of the target user. + offset (Optional[int]: Sequential number of the first photo to be returned. By default, + all photos are returned. + limit (Optional[int]): Limits the number of photos to be retrieved. Values between + 1-100 are accepted. Defaults to 100. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - list[:class:`telegram.UserProfilePhotos`]: A list of - :class:`telegram.UserProfilePhotos` objects are returned. + list[:class:`telegram.UserProfilePhotos`]: A list of user profile photos objects is + returned. Raises: :class:`telegram.TelegramError` """ - url = '{0}/getUserProfilePhotos'.format(self.base_url) data = {'user_id': user_id} @@ -958,27 +850,22 @@ class Bot(TelegramObject): @log def getFile(self, file_id, timeout=None, **kwargs): - """Use this method to get basic info about a file and prepare it for - downloading. For the moment, bots can download files of up to 20MB in - size. + """Use this method to get basic info about a file and prepare it for downloading. For the + moment, bots can download files of up to 20MB in size. Args: - file_id: - File identifier to get info about. - - Keyword Args: - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + file_id: File identifier to get info about. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.File`: On success, a :class:`telegram.File` - object is returned. + :class:`telegram.File`: On success, a :class:`telegram.File` object is returned. Raises: :class:`telegram.TelegramError` """ - url = '{0}/getFile'.format(self.base_url) data = {'file_id': file_id} @@ -992,21 +879,19 @@ class Bot(TelegramObject): @log def kickChatMember(self, chat_id, user_id, timeout=None, **kwargs): - """Use this method to kick a user from a group or a supergroup. In the - case of supergroups, the user will not be able to return to the group - on their own using invite links, etc., unless unbanned first. The bot - must be an administrator in the group for this to work. + """Use this method to kick a user from a group or a supergroup. + + In the case of supergroups, the user will not be able to return to the group on their own + using invite links, etc., unless unbanned first. The bot must be an administrator in the + group for this to work. Args: - chat_id: - Unique identifier for the target group or username of the target - supergroup (in the format @supergroupusername). - user_id: - Unique identifier of the target user. - - Keyword Args: - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the target group or username of the target supergroup + (in the format @supergroupusername). + user_id: Unique identifier of the target user. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: bool: On success, `True` is returned. @@ -1015,7 +900,6 @@ class Bot(TelegramObject): :class:`telegram.TelegramError` """ - url = '{0}/kickChatMember'.format(self.base_url) data = {'chat_id': chat_id, 'user_id': user_id} @@ -1027,20 +911,16 @@ class Bot(TelegramObject): @log def unbanChatMember(self, chat_id, user_id, timeout=None, **kwargs): """Use this method to unban a previously kicked user in a supergroup. - The user will not return to the group automatically, but will be able - to join via link, etc. The bot must be an administrator in the group - for this to work. + The user will not return to the group automatically, but will be able to join via link, + etc. The bot must be an administrator in the group for this to work. Args: - chat_id: - Unique identifier for the target group or username of the target - supergroup (in the format @supergroupusername). - user_id: - Unique identifier of the target user. - - Keyword Args: - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the target group or username of the target supergroup + (in the format @supergroupusername). + user_id: Unique identifier of the target user. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: bool: On success, `True` is returned. @@ -1049,7 +929,6 @@ class Bot(TelegramObject): :class:`telegram.TelegramError` """ - url = '{0}/unbanChatMember'.format(self.base_url) data = {'chat_id': chat_id, 'user_id': user_id} @@ -1065,22 +944,19 @@ class Bot(TelegramObject): show_alert=False, timeout=None, **kwargs): - """Use this method to send answers to callback queries sent from - inline keyboards. The answer will be displayed to the user as a - notification at the top of the chat screen or as an alert. + """Use this method to send answers to callback queries sent from inline keyboards. The + answer will be displayed to the user as a notification at the top of the chat screen or as + an alert. Args: - callback_query_id (str): Unique identifier for the query to be - answered. - text (Optional[str]): Text of the notification. If not - specified, nothing will be shown to the user. - show_alert (Optional[bool]): If `True`, an alert will be shown - by the client instead of a notification at the top of the chat - screen. Defaults to `False`. - - Keyword Args: - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + callback_query_id (str): Unique identifier for the query to be answered. + text (Optional[str]): Text of the notification. If not specified, nothing will be shown + to the user. + show_alert (Optional[bool]): If `True`, an alert will be shown by the client instead of + a notification at the top of the chat screen. Defaults to `False`. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: bool: On success, `True` is returned. @@ -1089,7 +965,6 @@ class Bot(TelegramObject): :class:`telegram.TelegramError` """ - url = '{0}/answerCallbackQuery'.format(self.base_url) data = {'callback_query_id': callback_query_id} @@ -1115,48 +990,35 @@ class Bot(TelegramObject): reply_markup=None, timeout=None, **kwargs): - """Use this method to edit text messages sent by the bot or via the bot - (for inline bots). + """Use this method to edit text messages sent by the bot or via the bot (for inline bots). Args: - text: - New text of the message. - chat_id: - Required if inline_message_id is not specified. Unique identifier - for the target chat or username of the target channel (in the - format @channelusername). - message_id: - Required if inline_message_id is not specified. Unique identifier - of the sent message. - inline_message_id: - Required if chat_id and message_id are not specified. Identifier of - the inline message. - parse_mode: - Send Markdown or HTML, if you want Telegram apps to show bold, - italic, fixed-width text or inline URLs in your bot's message. - disable_web_page_preview: - Disables link previews for links in this message. - reply_markup: - A JSON-serialized object for an inline keyboard. - - Keyword Args: - reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + text: New text of the message. + chat_id: Required if inline_message_id is not specified. Unique identifier for the + target chat or username of the target channel (in the format @channelusername). + message_id: Required if inline_message_id is not specified. Unique identifier of the + sent message. + inline_message_id: Required if chat_id and message_id are not specified. Identifier of + the inline message. + parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, + fixed-width text or inline URLs in your bot's message. + disable_web_page_preview: Disables link previews for links in this message. + reply_markup: A JSON-serialized object for an inline keyboard. + reply_markup (Optional[:class:`telegram.ReplyMarkup`]): 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. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, if edited message is sent by - the bot, the edited message is returned, otherwise `True` is - returned. + :class:`telegram.Message`: On success, if edited message is sent by the bot, the edited + message is returned, otherwise `True` is returned. Raises: :class:`telegram.TelegramError` """ - url = '{0}/editMessageText'.format(self.base_url) data = {'text': text} @@ -1184,30 +1046,27 @@ class Bot(TelegramObject): reply_markup=None, timeout=None, **kwargs): - """Use this method to edit captions of messages sent by the bot or - via the bot (for inline bots). + """Use this method to edit captions of messages sent by the bot or via the bot (for inline + bots). Args: - chat_id (Optional[str]): Required if inline_message_id is not - specified. Unique identifier for the target chat or username of - the target channel (in the format @channelusername). - message_id (Optional[str]): Required if inline_message_id is not - specified. Unique identifier of the sent message. - inline_message_id (Optional[str]): Required if chat_id and - message_id are not specified. Identifier of the inline message. + chat_id (Optional[str]): Required if inline_message_id is not specified. Unique + identifier for the target chat or username of the target channel (in the format + @channelusername). + message_id (Optional[str]): Required if inline_message_id is not specified. Unique + identifier of the sent message. + inline_message_id (Optional[str]): Required if chat_id and message_id are not + specified. Identifier of the inline message. caption (Optional[str]): New caption of the message. - **kwargs (Optional[dict]): Arbitrary keyword arguments. - - Keyword Args: - reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): - A JSON-serialized object for an inline keyboard. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): A JSON-serialized + object for an inline keyboard. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.Message`: On success, if edited message is sent by - the bot, the edited message is returned, otherwise `True` is - returned. + :class:`telegram.Message`: On success, if edited message is sent by the bot, the edited + message is returned, otherwise `True` is returned. Raises: :class:`telegram.TelegramError` @@ -1242,24 +1101,22 @@ class Bot(TelegramObject): reply_markup=None, timeout=None, **kwargs): - """Use this method to edit only the reply markup of messages sent by - the bot or via the bot (for inline bots). + """Use this method to edit only the reply markup of messages sent by the bot or via the bot + (for inline bots). Args: - chat_id (Optional[str]): Required if inline_message_id is not - specified. Unique identifier for the target chat or username of - the target channel (in the format @channelusername). - message_id (Optional[str]): Required if inline_message_id is not - specified. Unique identifier of the sent message. - inline_message_id (Optional[str]): Required if chat_id and - message_id are not specified. Identifier of the inline message. - **kwargs (Optional[dict]): Arbitrary keyword arguments. - - Keyword Args: - reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): - A JSON-serialized object for an inline keyboard. - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id (Optional[str]): Required if inline_message_id is not specified. Unique + identifier for the target chat or username of the target channel (in the format + @channelusername). + message_id (Optional[str]): Required if inline_message_id is not specified. Unique + identifier of the sent message. + inline_message_id (Optional[str]): Required if chat_id and message_id are not + specified. Identifier of the inline message. + reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): A JSON-serialized + object for an inline keyboard. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: :class:`telegram.Message`: On success, if edited message is sent by @@ -1293,20 +1150,20 @@ class Bot(TelegramObject): """Use this method to receive incoming updates using long polling. Args: - offset (Optional[int]): - Identifier of the first update to be returned. Must be greater by one than the highest - among the identifiers of previously received updates. By default, updates starting with - the earliest unconfirmed update are returned. An update is considered confirmed as soon - as getUpdates is called with an offset higher than its update_id. - limit (Optional[int]): - Limits the number of updates to be retrieved. Values between 1-100 are accepted. - Defaults to 100. - timeout (Optional[int]): - Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. - network_delay (Optional[float]): - Additional timeout in seconds to allow the response from Telegram servers. This should - cover network latency around the globe, SSL handshake and slowness of the Telegram - servers (which unfortunately happens a lot recently - 2016-05-28). Defaults to 5. + offset (Optional[int]): Identifier of the first update to be returned. Must be greater + by one than the highest among the identifiers of previously received updates. By + default, updates starting with the earliest unconfirmed update are returned. An + update is considered confirmed as soon as getUpdates is called with an offset + higher than its update_id. + limit (Optional[int]): Limits the number of updates to be retrieved. Values between + 1-100 are accepted. Defaults to 100. + timeout (Optional[int]): Timeout in seconds for long polling. Defaults to 0, i.e. usual + short polling. + network_delay (Optional[float]): Additional timeout in seconds to allow the response + from Telegram servers. This should cover network latency around the globe, SSL + handshake and slowness of the Telegram servers (which unfortunately happens a lot + recently - 2016-05-28). Defaults to 5. + **kwargs (dict): Arbitrary keyword arguments. Returns: list[:class:`telegram.Update`] @@ -1315,7 +1172,6 @@ class Bot(TelegramObject): :class:`telegram.TelegramError` """ - url = '{0}/getUpdates'.format(self.base_url) data = {'timeout': timeout} @@ -1338,20 +1194,17 @@ class Bot(TelegramObject): @log def setWebhook(self, webhook_url=None, certificate=None, timeout=None, **kwargs): - """Use this method to specify a url and receive incoming updates via an - outgoing webhook. Whenever there is an update for the bot, we will send - an HTTPS POST request to the specified url, containing a - JSON-serialized Update. In case of an unsuccessful request, we will - give up after a reasonable amount of attempts. + """Use this method to specify a url and receive incoming updates via an outgoing webhook. + Whenever there is an update for the bot, we will send an HTTPS POST request to the + specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we + will give up after a reasonable amount of attempts. Args: - webhook_url: - HTTPS url to send updates to. - Use an empty string to remove webhook integration - - Keyword Args: + webhook_url: HTTPS url to send updates to. Use an empty string to remove webhook + integration timeout (Optional[float]): If this value is specified, use it as the definitive timeout (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: bool: On success, `True` is returned. @@ -1360,7 +1213,6 @@ class Bot(TelegramObject): :class:`telegram.TelegramError` """ - url = '{0}/setWebhook'.format(self.base_url) data = {} @@ -1376,17 +1228,14 @@ class Bot(TelegramObject): @log def leaveChat(self, chat_id, timeout=None, **kwargs): - """Use this method for your bot to leave a group, supergroup or - channel. + """Use this method for your bot to leave a group, supergroup or channel. Args: - chat_id: - Unique identifier for the target chat or username of the target - channel (in the format @channelusername). - - Keyword Args: - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the target chat or username of the target channel (in + the format @channelusername). + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: bool: On success, `True` is returned. @@ -1395,7 +1244,6 @@ class Bot(TelegramObject): :class:`telegram.TelegramError` """ - url = '{0}/leaveChat'.format(self.base_url) data = {'chat_id': chat_id} @@ -1406,18 +1254,15 @@ class Bot(TelegramObject): @log def getChat(self, chat_id, timeout=None, **kwargs): - """Use this method to get up to date information about the chat - (current name of the user for one-on-one conversations, current - username of a user, group or channel, etc.). + """Use this method to get up to date information about the chat (current name of the user + for one-on-one conversations, current username of a user, group or channel, etc.). Args: - chat_id: - Unique identifier for the target chat or username of the target - channel (in the format @channelusername). - - Keyword Args: - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the target chat or username of the target channel (in + the format @channelusername). + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: :class:`telegram.Chat`: On success, :class:`telegram.Chat` is @@ -1427,7 +1272,6 @@ class Bot(TelegramObject): :class:`telegram.TelegramError` """ - url = '{0}/getChat'.format(self.base_url) data = {'chat_id': chat_id} @@ -1438,31 +1282,25 @@ class Bot(TelegramObject): @log def getChatAdministrators(self, chat_id, timeout=None, **kwargs): - """Use this method to get a list of administrators in a chat. On - success, returns an Array of ChatMember objects that contains - information about all chat administrators except other bots. If the - chat is a group or a supergroup and no administrators were appointed, - only the creator will be returned. + """Use this method to get a list of administrators in a chat. On success, returns an Array + of ChatMember objects that contains information about all chat administrators except other + bots. If the chat is a group or a supergroup and no administrators were appointed, only the + creator will be returned. Args: - chat_id: - Unique identifier for the target chat or username of the target - channel (in the format @channelusername). - - - Keyword Args: - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the target chat or username of the target channel (in + the format @channelusername). + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - list[:class:`telegram.ChatMember`]: On success, a list of - :class:`telegram.ChatMember` objects are returned. + list[:class:`telegram.ChatMember`]: A list of chat member objects. Raises: :class:`telegram.TelegramError` """ - url = '{0}/getChatAdministrators'.format(self.base_url) data = {'chat_id': chat_id} @@ -1476,14 +1314,11 @@ class Bot(TelegramObject): """Use this method to get the number of members in a chat. Args: - chat_id: - Unique identifier for the target chat or username of the target - channel (in the format @channelusername). - - - Keyword Args: - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the target chat or username of the target channel (in + the format @channelusername). + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: int: On success, an `int` is returned. @@ -1492,7 +1327,6 @@ class Bot(TelegramObject): :class:`telegram.TelegramError` """ - url = '{0}/getChatMembersCount'.format(self.base_url) data = {'chat_id': chat_id} @@ -1506,26 +1340,20 @@ class Bot(TelegramObject): """Use this method to get information about a member of a chat. Args: - chat_id: - Unique identifier for the target chat or username of the target - channel (in the format @channelusername). - user_id: - Unique identifier of the target user. - - - Keyword Args: - timeout (Optional[float]): If this value is specified, use it as - the definitive timeout (in seconds) for urlopen() operations. + chat_id: Unique identifier for the target chat or username of the target channel (in + the format @channelusername). + user_id: Unique identifier of the target user. + timeout (Optional[float]): If this value is specified, use it as the definitive timeout + (in seconds) for urlopen() operations. + **kwargs (dict): Arbitrary keyword arguments. Returns: - :class:`telegram.ChatMember`: On success, - :class:`telegram.ChatMember` is returned. + :class:`telegram.ChatMember`: On success, chat member object is returned. Raises: :class:`telegram.TelegramError` """ - url = '{0}/getChatMember'.format(self.base_url) data = {'chat_id': chat_id, 'user_id': user_id} @@ -1552,8 +1380,7 @@ class Bot(TelegramObject): return (self.__class__, (self.token, self.base_url.replace(self.token, ''), self.base_file_url.replace(self.token, ''))) -# snake_case (PEP8) aliases - + # snake_case (PEP8) aliases get_me = getMe send_message = sendMessage forward_message = forwardMessage diff --git a/telegram/chat.py b/telegram/chat.py index c28d7d3d4..3042a7254 100644 --- a/telegram/chat.py +++ b/telegram/chat.py @@ -36,13 +36,14 @@ class Chat(TelegramObject): Args: id (int): type (str): - **kwargs: Arbitrary keyword arguments. - - Keyword Args: - type (Optional[str]): + title (Optional[str]): + username(Optional[str]): + first_name(Optional[str]): + last_name(Optional[str]): bot (Optional[Bot]): The Bot to use for instance methods - """ + **kwargs (dict): Arbitrary keyword arguments. + """ PRIVATE = 'private' GROUP = 'group' SUPERGROUP = 'supergroup' diff --git a/telegram/chatmember.py b/telegram/chatmember.py index dfcfce055..5eb4db637 100644 --- a/telegram/chatmember.py +++ b/telegram/chatmember.py @@ -32,8 +32,9 @@ class ChatMember(TelegramObject): Args: user (:class:`telegram.User`): status (str): - """ + **kwargs (dict): Arbitrary keyword arguments. + """ CREATOR = 'creator' ADMINISTRATOR = 'administrator' MEMBER = 'member' diff --git a/telegram/choseninlineresult.py b/telegram/choseninlineresult.py index edc9c3515..46a62a05c 100644 --- a/telegram/choseninlineresult.py +++ b/telegram/choseninlineresult.py @@ -33,11 +33,16 @@ class ChosenInlineResult(TelegramObject): result_id (str): from_user (:class:`telegram.User`): query (str): + location (:class:`telegram.Location`): + inline_message_id (str): Args: result_id (str): from_user (:class:`telegram.User`): query (str): + location (Optional[:class:`telegram.Location`]): + inline_message_id (Optional[str]): + **kwargs (dict): Arbitrary keyword arguments. """ diff --git a/telegram/contact.py b/telegram/contact.py index bd29cf984..790228949 100644 --- a/telegram/contact.py +++ b/telegram/contact.py @@ -33,11 +33,10 @@ class Contact(TelegramObject): Args: phone_number (str): first_name (str): - **kwargs: Arbitrary keyword arguments. - - Keyword Args: last_name (Optional[str]): user_id (Optional[int]): + **kwargs: Arbitrary keyword arguments. + """ def __init__(self, phone_number, first_name, last_name='', user_id=0, **kwargs): diff --git a/telegram/document.py b/telegram/document.py index 2bc08ff8d..116037bb1 100644 --- a/telegram/document.py +++ b/telegram/document.py @@ -33,13 +33,12 @@ class Document(TelegramObject): Args: file_id (str): - **kwargs: Arbitrary keyword arguments. - - Keyword Args: thumb (Optional[:class:`telegram.PhotoSize`]): file_name (Optional[str]): mime_type (Optional[str]): file_size (Optional[int]): + **kwargs (dict): Arbitrary keyword arguments. + """ def __init__(self, file_id, thumb=None, file_name='', mime_type='', file_size=0, **kwargs): diff --git a/telegram/file.py b/telegram/file.py index 7b0fd0e08..030977d0b 100644 --- a/telegram/file.py +++ b/telegram/file.py @@ -34,11 +34,9 @@ class File(TelegramObject): Args: file_id (str): bot (telegram.Bot): - **kwargs: Arbitrary keyword arguments. - - Keyword Args: file_size (Optional[int]): file_path (Optional[str]): + **kwargs (dict): Arbitrary keyword arguments. """ diff --git a/telegram/forcereply.py b/telegram/forcereply.py index 8ce2925c0..e9ab9e80c 100644 --- a/telegram/forcereply.py +++ b/telegram/forcereply.py @@ -30,10 +30,9 @@ class ForceReply(ReplyMarkup): Args: force_reply (bool): - **kwargs: Arbitrary keyword arguments. - - Keyword Args: selective (Optional[bool]): + **kwargs (dict): Arbitrary keyword arguments. + """ def __init__(self, force_reply=True, selective=False, **kwargs): diff --git a/telegram/inlinekeyboardbutton.py b/telegram/inlinekeyboardbutton.py index 0abf0552b..d7c3cac88 100644 --- a/telegram/inlinekeyboardbutton.py +++ b/telegram/inlinekeyboardbutton.py @@ -33,12 +33,10 @@ class InlineKeyboardButton(TelegramObject): Args: text (str): - **kwargs: Arbitrary keyword arguments. - - Keyword Args: url (Optional[str]): callback_data (Optional[str]): switch_inline_query (Optional[str]): + **kwargs (dict): Arbitrary keyword arguments. """ diff --git a/telegram/inlinekeyboardmarkup.py b/telegram/inlinekeyboardmarkup.py index 5a82d1b30..b6c4e4fc1 100644 --- a/telegram/inlinekeyboardmarkup.py +++ b/telegram/inlinekeyboardmarkup.py @@ -30,6 +30,7 @@ class InlineKeyboardMarkup(ReplyMarkup): Args: inline_keyboard (List[List[:class:`telegram.InlineKeyboardButton`]]): + **kwargs (dict): Arbitrary keyword arguments. """ @@ -46,6 +47,7 @@ class InlineKeyboardMarkup(ReplyMarkup): Returns: telegram.InlineKeyboardMarkup: + """ data = super(InlineKeyboardMarkup, InlineKeyboardMarkup).de_json(data, bot) diff --git a/telegram/inlinequery.py b/telegram/inlinequery.py index 17a9ad462..6ba1d6f52 100644 --- a/telegram/inlinequery.py +++ b/telegram/inlinequery.py @@ -38,11 +38,10 @@ class InlineQuery(TelegramObject): from_user (:class:`telegram.User`): query (str): offset (str): - **kwargs: Arbitrary keyword arguments. - - Keyword Args: location (optional[:class:`telegram.Location`]): bot (Optional[Bot]): The Bot to use for instance methods + **kwargs (dict): Arbitrary keyword arguments. + """ def __init__(self, id, from_user, query, offset, location=None, bot=None, **kwargs): diff --git a/telegram/inlinequeryresult.py b/telegram/inlinequeryresult.py index b161d7253..b8afa219a 100644 --- a/telegram/inlinequeryresult.py +++ b/telegram/inlinequeryresult.py @@ -26,12 +26,13 @@ class InlineQueryResult(TelegramObject): """This object represents a Telegram InlineQueryResult. Attributes: - type (str): - id (str): + type (str): Type of the result. + id (str): Unique identifier for this result, 1-64 Bytes Args: - type (str): + type (str): Type of the result. id (str): Unique identifier for this result, 1-64 Bytes + **kwargs (dict): Arbitrary keyword arguments. """ diff --git a/telegram/inlinequeryresultarticle.py b/telegram/inlinequeryresultarticle.py index bbf528520..324916a45 100644 --- a/telegram/inlinequeryresultarticle.py +++ b/telegram/inlinequeryresultarticle.py @@ -42,21 +42,20 @@ class InlineQueryResultArticle(InlineQueryResult): parse_mode (str): Use :class:`InputTextMessageContent` instead. - disable_web_page_preview (bool): Use :class:`InputTextMessageContent` - instead. + disable_web_page_preview (bool): Use :class:`InputTextMessageContent` instead. Args: id (str): Unique identifier for this result, 1-64 Bytes title (str): reply_markup (:class:`telegram.ReplyMarkup`): - - Keyword Args: url (Optional[str]): hide_url (Optional[bool]): description (Optional[str]): thumb_url (Optional[str]): thumb_width (Optional[int]): thumb_height (Optional[int]): + **kwargs (dict): Arbitrary keyword arguments. + """ def __init__(self, diff --git a/telegram/inlinequeryresultaudio.py b/telegram/inlinequeryresultaudio.py index eabf551cb..324788cd4 100644 --- a/telegram/inlinequeryresultaudio.py +++ b/telegram/inlinequeryresultaudio.py @@ -34,28 +34,24 @@ class InlineQueryResultAudio(InlineQueryResult): performer (Optional[str]): audio_duration (Optional[str]): reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): - input_message_content (Optional[ - :class:`telegram.input_message_content`]): + input_message_content (Optional[:class:`telegram.input_message_content`]): Deprecated: 4.0 message_text (str): Use :class:`InputTextMessageContent` instead. parse_mode (str): Use :class:`InputTextMessageContent` instead. - disable_web_page_preview (bool): Use :class:`InputTextMessageContent` - instead. + disable_web_page_preview (bool): Use :class:`InputTextMessageContent` instead. Args: audio_url (str): title (str): - **kwargs: Arbitrary keyword arguments. - - Keyword Args: performer (Optional[str]): audio_duration (Optional[str]): reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): - input_message_content (Optional[ - :class:`telegram.input_message_content`]): + input_message_content (Optional[:class:`telegram.input_message_content`]): + **kwargs (dict): Arbitrary keyword arguments. + """ def __init__(self, diff --git a/telegram/inlinequeryresultcachedaudio.py b/telegram/inlinequeryresultcachedaudio.py index 44779ed71..96572649b 100644 --- a/telegram/inlinequeryresultcachedaudio.py +++ b/telegram/inlinequeryresultcachedaudio.py @@ -23,34 +23,29 @@ from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageConten class InlineQueryResultCachedAudio(InlineQueryResult): - """Represents a link to an mp3 audio file stored on the Telegram - servers. By default, this audio file will be sent by the user. - Alternatively, you can use input_message_content to send a message with - the specified content instead of the audio. + """Represents a link to an mp3 audio file stored on the Telegram servers. By default, this + audio file will be sent by the user. Alternatively, you can use input_message_content to send a + message with the specified content instead of the audio. Attributes: id (str): audio_file_id (str): reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): - input_message_content (Optional[ - :class:`telegram.input_message_content`]): + input_message_content (Optional[:class:`telegram.input_message_content`]): Deprecated: 4.0 message_text (str): Use :class:`InputTextMessageContent` instead. parse_mode (str): Use :class:`InputTextMessageContent` instead. - disable_web_page_preview (bool): Use :class:`InputTextMessageContent` - instead. + disable_web_page_preview (bool): Use :class:`InputTextMessageContent` instead. Args: audio_file_id (str): - **kwargs: Arbitrary keyword arguments. - - Keyword Args: reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): - input_message_content (Optional[ - :class:`telegram.input_message_content`]): + input_message_content (Optional[:class:`telegram.input_message_content`]): + **kwargs (dict): Arbitrary keyword arguments. + """ def __init__(self, id, audio_file_id, reply_markup=None, input_message_content=None, **kwargs): diff --git a/telegram/inlinequeryresultcacheddocument.py b/telegram/inlinequeryresultcacheddocument.py index 8439e877d..26af1db4f 100644 --- a/telegram/inlinequeryresultcacheddocument.py +++ b/telegram/inlinequeryresultcacheddocument.py @@ -16,13 +16,38 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -"""This module contains the classes that represent Telegram -InlineQueryResultCachedDocument""" +"""This module contains the classes that represent Telegram InlineQueryResultCachedDocument""" from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent class InlineQueryResultCachedDocument(InlineQueryResult): + """Represents a link to a file stored on the Telegram servers. By default, this file will be + sent by the user with an optional caption. Alternatively, you can use input_message_content to + send a message with the specified content instead of the file. Currently, only pdf-files and + zip archives can be sent using this method. + + Attributes: + title (str): Title for the result. + document_file_id (str): A valid file identifier for the file. + description (Optional[str]): Short description of the result. + caption (Optional[str]): Caption of the document to be sent, 0-200 characters. + reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): Inline keyboard attached + to the message. + input_message_content (Optional[:class:`telegram.InputMessageContent`]): Content of the + message to be sent instead of the file. + + Args: + id (str): + title (str): + document_file_id (str): + description (Optional[str]): + caption (Optional[str]): + reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): + input_message_content (Optional[:class:`telegram.InputMessageContent`]): + **kwargs (dict): Arbitrary keyword arguments. + + """ def __init__(self, id, diff --git a/telegram/inlinequeryresultcachedgif.py b/telegram/inlinequeryresultcachedgif.py index 2e9820cb3..ec6a12ce7 100644 --- a/telegram/inlinequeryresultcachedgif.py +++ b/telegram/inlinequeryresultcachedgif.py @@ -23,6 +23,29 @@ from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageConten class InlineQueryResultCachedGif(InlineQueryResult): + """Represents a link to an animated GIF file stored on the Telegram servers. By default, this + animated GIF file will be sent by the user with an optional caption. Alternatively, you can use + input_message_content to send a message with specified content instead of the animation. + + Attributes: + gif_file_id (str): A valid file identifier for the GIF file. + title (Optional[str]): Title for the result. + caption (Optional[str]): Caption of the GIF file to be sent, 0-200 characters. + reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): Inline keyboard attached + to the message. + input_message_content (Optional[:class:`telegram.InputMessageContent`]): Content of the + message to be sent instead of the GIF animation. + + Args: + id (str): + gif_file_id (str): + title (Optional[str]): + caption (Optional[str]): + reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): + input_message_content (Optional[:class:`telegram.InputMessageContent`]): + **kwargs (dict): Arbitrary keyword arguments. + + """ def __init__(self, id, diff --git a/telegram/inlinequeryresultcachedmpeg4gif.py b/telegram/inlinequeryresultcachedmpeg4gif.py index ea1ed6ec6..9cc977251 100644 --- a/telegram/inlinequeryresultcachedmpeg4gif.py +++ b/telegram/inlinequeryresultcachedmpeg4gif.py @@ -23,6 +23,30 @@ from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageConten class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): + """Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the + Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an + optional caption. Alternatively, you can use input_message_content to send a message with the + specified content instead of the animation. + + Attributes: + mpeg4_file_id (str): A valid file identifier for the MP4 file. + title (Optional[str]): Title for the result. + caption (Optional[str]): Caption of the MPEG-4 file to be sent, 0-200 characters. + reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): Inline keyboard attached + to the message. + input_message_content (Optional[:class:`telegram.InputMessageContent`]): Content of the + message to be sent instead of the video animation + + Args: + id (str): + mpeg4_file_id (str): + title (Optional[str]): + caption (Optional[str]): + reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]): + input_message_content (Optional[:class:`telegram.InputMessageContent`]): + **kwargs (dict): Arbitrary keyword arguments. + + """ def __init__(self, id, diff --git a/telegram/message.py b/telegram/message.py index 9c7865d4d..a79849fad 100644 --- a/telegram/message.py +++ b/telegram/message.py @@ -153,9 +153,7 @@ class Message(TelegramObject): self.reply_to_message = reply_to_message self.edit_date = edit_date self.text = text - if entities is None: - entities = list() - self.entities = entities + self.entities = entities or list() self.audio = audio self.document = document self.photo = photo