diff --git a/telegram/bot.py b/telegram/bot.py index 05b617405..0776b66d7 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -1960,12 +1960,14 @@ class Bot(TelegramObject): """ - if ok is True and (shipping_options is None or error_message is not None): + ok = bool(ok) + + if ok and (shipping_options is None or error_message is not None): raise TelegramError( 'answerShippingQuery: If ok is True, shipping_options ' 'should not be empty and there should not be error_message') - if ok is False and (shipping_options is not None or error_message is None): + if not ok and (shipping_options is not None or error_message is None): raise TelegramError( 'answerShippingQuery: If ok is False, error_message ' 'should not be empty and there should not be shipping_options') @@ -1974,7 +1976,7 @@ class Bot(TelegramObject): data = {'shipping_query_id': shipping_query_id, 'ok': ok} - if ok is True: + if ok: data['shipping_options'] = [option.to_dict() for option in shipping_options] if error_message is not None: data['error_message'] = error_message @@ -2009,6 +2011,8 @@ class Bot(TelegramObject): """ + ok = bool(ok) + if not (ok ^ (error_message is not None)): raise TelegramError( 'answerPreCheckoutQuery: If ok is True, there should '