Skip to content

Commit cd24bb4

Browse files
committed
payment: Small fixes
- Semantic fixes bot.py (if XXX is not None: ...). - Documentation fixes (arguments which are optional).
1 parent 630b63e commit cd24bb4

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

telegram/bot.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,21 +1843,21 @@ def send_invoice(self,
18431843
'prices': [p.to_dict() for p in prices]
18441844
}
18451845

1846-
if photo_url:
1846+
if photo_url is not None:
18471847
data['photo_url'] = photo_url
1848-
if photo_size:
1848+
if photo_size is not None:
18491849
data['photo_size'] = photo_size
1850-
if photo_width:
1850+
if photo_width is not None:
18511851
data['photo_width'] = photo_width
1852-
if photo_height:
1852+
if photo_height is not None:
18531853
data['photo_height'] = photo_height
1854-
if need_name:
1854+
if need_name is not None:
18551855
data['need_name'] = need_name
1856-
if need_phone_number:
1856+
if need_phone_number is not None:
18571857
data['need_phone_number'] = need_phone_number
1858-
if need_shipping_address:
1858+
if need_shipping_address is not None:
18591859
data['need_shipping_address'] = need_shipping_address
1860-
if is_flexible:
1860+
if is_flexible is not None:
18611861
data['is_flexible'] = is_flexible
18621862

18631863
return url, data
@@ -1877,12 +1877,12 @@ def answer_shipping_query(self,
18771877
ok (bool): Specify True if delivery to the specified address is possible and False if
18781878
there are any problems (for example, if delivery to the specified address
18791879
is not possible)
1880-
shipping_options (List[:class:`telegram.ShippingOption`]): Required if ok is True. A
1881-
list of available shipping options.
1882-
error_message (str): Required if ok is False. Error message in human readable form
1883-
that explains why it is impossible to complete the order (e.g. "Sorry, delivery
1884-
to your desired address is unavailable'). Telegram will display this message
1885-
to the user.
1880+
shipping_options (Optional[List[:class:`telegram.ShippingOption`]]): Required if ok is
1881+
True. A list of available shipping options.
1882+
error_message (Optional[str]): Required if ok is False. Error message in human readable
1883+
form that explains why it is impossible to complete the order (e.g. "Sorry,
1884+
delivery to your desired address is unavailable'). Telegram will display this
1885+
message to the user.
18861886
18871887
Returns:
18881888
bool: On success, `True` is returned.
@@ -1895,9 +1895,9 @@ def answer_shipping_query(self,
18951895

18961896
data = {'shipping_query_id': shipping_query_id, 'ok': ok}
18971897

1898-
if shipping_options:
1898+
if shipping_options is not None:
18991899
data['shipping_options'] = shipping_options
1900-
if error_message:
1900+
if error_message is not None:
19011901
data['error_message'] = error_message
19021902

19031903
return url, data
@@ -1912,11 +1912,11 @@ def answer_pre_checkout_query(self, pre_checkout_query_id, ok, error_message=Non
19121912
pre_checkout_query_id (str): Unique identifier for the query to be answered
19131913
ok (bool): Specify True if everything is alright (goods are available, etc.) and the
19141914
bot is ready to proceed with the order. Use False if there are any problems.
1915-
error_message (str): Required if ok is False. Error message in human readable form that
1916-
explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody
1917-
just bought the last of our amazing black T-shirts while you were busy filling out
1918-
your payment details. Please choose a different color or garment!"). Telegram will
1919-
display this message to the user.
1915+
error_message (Optional[str]): Required if ok is False. Error message in human readable
1916+
form that explains the reason for failure to proceed with the checkout (e.g.
1917+
"Sorry, somebody just bought the last of our amazing black T-shirts while you were
1918+
busy filling out your payment details. Please choose a different color or
1919+
garment!"). Telegram will display this message to the user.
19201920
19211921
Returns:
19221922
bool: On success, `True` is returned.
@@ -1929,7 +1929,7 @@ def answer_pre_checkout_query(self, pre_checkout_query_id, ok, error_message=Non
19291929

19301930
data = {'pre_checkout_query_id': pre_checkout_query_id, 'ok': ok}
19311931

1932-
if error_message:
1932+
if error_message is not None:
19331933
data['error_message'] = error_message
19341934

19351935
return url, data

0 commit comments

Comments
 (0)