From 4247dc0e215b550cef44ce7696e621af49c1e14a Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 8 Jun 2017 09:47:19 +0800 Subject: [PATCH] tiny changes upon PR review --- telegram/__init__.py | 2 +- telegram/bot.py | 5 ++--- telegram/ext/precheckoutqueryhandler.py | 3 +-- telegram/ext/shippingqueryhandler.py | 3 +-- telegram/message.py | 1 + telegram/precheckoutquery.py | 3 +-- telegram/shippingquery.py | 1 + telegram/update.py | 13 +++++++------ 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/telegram/__init__.py b/telegram/__init__.py index ed2f90708..388cd851a 100644 --- a/telegram/__init__.py +++ b/telegram/__init__.py @@ -54,7 +54,6 @@ from .shippingaddress import ShippingAddress from .orderinfo import OrderInfo from .successfulpayment import SuccessfulPayment from .invoice import Invoice -from .videonote import VideoNote from .message import Message from .inputmessagecontent import InputMessageContent from .callbackquery import CallbackQuery @@ -93,6 +92,7 @@ from .precheckoutquery import PreCheckoutQuery from .shippingquery import ShippingQuery from .webhookinfo import WebhookInfo from .gamehighscore import GameHighScore +from .videonote import VideoNote from .update import Update from .bot import Bot from .constants import (MAX_MESSAGE_LENGTH, MAX_CAPTION_LENGTH, SUPPORTED_WEBHOOK_PORTS, diff --git a/telegram/bot.py b/telegram/bot.py index 705958ba6..fb50b055d 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -1918,7 +1918,7 @@ class Bot(TelegramObject): data['need_name'] = need_name if need_phone_number is not None: data['need_phone_number'] = need_phone_number - if need_email: + if need_email is not None: data['need_email'] = need_email if need_shipping_address is not None: data['need_shipping_address'] = need_shipping_address @@ -2009,8 +2009,7 @@ class Bot(TelegramObject): """ - if ((ok is not True and error_message is None) or - (ok is True and error_message is not None)): + if not (ok ^ (error_message is None)): raise TelegramError( 'answerPreCheckoutQuery: If ok is True, there should ' 'not be error_message; if ok is False, error_message ' diff --git a/telegram/ext/precheckoutqueryhandler.py b/telegram/ext/precheckoutqueryhandler.py index 9de207d97..481eb40ca 100644 --- a/telegram/ext/precheckoutqueryhandler.py +++ b/telegram/ext/precheckoutqueryhandler.py @@ -62,8 +62,7 @@ class PreCheckoutQueryHandler(Handler): pass_chat_data=pass_chat_data) def check_update(self, update): - if isinstance(update, Update) and update.pre_checkout_query: - return True + return isinstance(update, Update) and update.pre_checkout_query def handle_update(self, update, dispatcher): optional_args = self.collect_optional_args(dispatcher, update) diff --git a/telegram/ext/shippingqueryhandler.py b/telegram/ext/shippingqueryhandler.py index 746338bf8..781244e8a 100644 --- a/telegram/ext/shippingqueryhandler.py +++ b/telegram/ext/shippingqueryhandler.py @@ -62,8 +62,7 @@ class ShippingQueryHandler(Handler): pass_chat_data=pass_chat_data) def check_update(self, update): - if isinstance(update, Update) and update.shipping_query: - return True + return isinstance(update, Update) and update.shipping_query def handle_update(self, update, dispatcher): optional_args = self.collect_optional_args(dispatcher, update) diff --git a/telegram/message.py b/telegram/message.py index 5e9dc3837..96217447a 100644 --- a/telegram/message.py +++ b/telegram/message.py @@ -106,6 +106,7 @@ class Message(TelegramObject): left_chat_participant (:class:`telegram.User`): Use `left_chat_member` instead. + """ def __init__(self, diff --git a/telegram/precheckoutquery.py b/telegram/precheckoutquery.py index 78700216f..327449a92 100644 --- a/telegram/precheckoutquery.py +++ b/telegram/precheckoutquery.py @@ -33,10 +33,9 @@ class PreCheckoutQuery(TelegramObject): currency (str): Three-letter ISO 4217 currency code total_amount (int): Total price in the smallest units of the currency (integer) invoice_payload (str): Bot specified invoice payload - - Keyword Args: shipping_option_id (Optional[str]): Identifier of the shipping option chosen by the user order_info (Optional[:class:`telegram.OrderInfo`]): Order info provided by the user + bot (Optional[Bot]): The Bot to use for instance methods **kwargs (dict): Arbitrary keyword arguments. """ diff --git a/telegram/shippingquery.py b/telegram/shippingquery.py index dde670eee..b267b2f25 100644 --- a/telegram/shippingquery.py +++ b/telegram/shippingquery.py @@ -32,6 +32,7 @@ class ShippingQuery(TelegramObject): from_user (:class:`telegram.User`): User who sent the query invoice_payload (str): Bot specified invoice payload shipping_address (:class:`telegram.ShippingQuery`): User specified shipping address + bot (Optional[Bot]): The Bot to use for instance methods **kwargs (dict): Arbitrary keyword arguments. """ diff --git a/telegram/update.py b/telegram/update.py index a26849312..cdef6e085 100644 --- a/telegram/update.py +++ b/telegram/update.py @@ -32,8 +32,6 @@ class Update(TelegramObject): edited_message (:class:`telegram.Message`): New version of a message that is known to the bot and was edited inline_query (:class:`telegram.InlineQuery`): New incoming inline query. - shipping_query (:class:`telegram.ShippingQuery`): New incoming shipping query. - pre_checkout_query (:class:`telegram.PreCheckoutQuery`): New incoming pre-checkout query. chosen_inline_result (:class:`telegram.ChosenInlineResult`): The result of an inline query that was chosen by a user and sent to their chat partner. callback_query (:class:`telegram.CallbackQuery`): New incoming callback query. @@ -41,6 +39,9 @@ class Update(TelegramObject): text, photo, sticker, etc. edited_channel_post (Optional[:class:`telegram.Message`]): New version of a channel post that is known to the bot and was edited. + shipping_query (:class:`telegram.ShippingQuery`): New incoming shipping query. + pre_checkout_query (:class:`telegram.PreCheckoutQuery`): New incoming pre-checkout query. + Args: update_id (int): @@ -49,10 +50,10 @@ class Update(TelegramObject): inline_query (Optional[:class:`telegram.InlineQuery`]): chosen_inline_result (Optional[:class:`telegram.ChosenInlineResult`]) callback_query (Optional[:class:`telegram.CallbackQuery`]): - shipping_query (Optional[:class:`telegram.ShippingQuery`]): - pre_checkout_query (Optional[:class:`telegram.PreCheckoutQuery`]): channel_post (Optional[:class:`telegram.Message`]): edited_channel_post (Optional[:class:`telegram.Message`]): + shipping_query (Optional[:class:`telegram.ShippingQuery`]): + pre_checkout_query (Optional[:class:`telegram.PreCheckoutQuery`]): **kwargs: Arbitrary keyword arguments. """ @@ -64,10 +65,10 @@ class Update(TelegramObject): inline_query=None, chosen_inline_result=None, callback_query=None, - shipping_query=None, - pre_checkout_query=None, channel_post=None, edited_channel_post=None, + shipping_query=None, + pre_checkout_query=None, **kwargs): # Required self.update_id = int(update_id)