Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions telegram/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1960,12 +1960,14 @@ def answer_shipping_query(self,

"""

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')
Expand All @@ -1974,7 +1976,7 @@ def answer_shipping_query(self,

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
Expand Down Expand Up @@ -2009,6 +2011,8 @@ def answer_pre_checkout_query(self, pre_checkout_query_id, ok,

"""

ok = bool(ok)

if not (ok ^ (error_message is not None)):
raise TelegramError(
'answerPreCheckoutQuery: If ok is True, there should '
Expand Down