From 24cdcb1bcc6c576b428180f1f463fdcffc69bb97 Mon Sep 17 00:00:00 2001 From: _run Date: Tue, 21 Jun 2022 14:22:57 +0500 Subject: [PATCH 1/9] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ef79d1e44..027139d09 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@

A simple, but extensible Python implementation for the Telegram Bot API.

Both synchronous and asynchronous.

-##

Supported Bot API version: 6.0! +##

Supported Bot API version: 6.1!

Official documentation

@@ -727,6 +727,7 @@ Result will be: ## API conformance +* ✔ [Bot API 6.1](https://core.telegram.org/bots/api#june-20-2022) * ✔ [Bot API 6.0](https://core.telegram.org/bots/api#april-16-2022) * ✔ [Bot API 5.7](https://core.telegram.org/bots/api#january-31-2022) * ✔ [Bot API 5.6](https://core.telegram.org/bots/api#december-30-2021) From 0d0f9ef33015c8d6ced5ed218777b678dab3e979 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Tue, 21 Jun 2022 15:20:55 +0500 Subject: [PATCH 2/9] Added secret token and create_invoice_link --- telebot/__init__.py | 68 ++++++++++++++++++++++++++++++++++++++++++-- telebot/apihelper.py | 43 +++++++++++++++++++++++++++- 2 files changed, 108 insertions(+), 3 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index abadfe557..85454c5f4 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -261,7 +261,7 @@ def load_reply_handlers(self, filename="./.handler-saves/reply.save", del_file_a self.reply_backend.load_handlers(filename, del_file_after_loading) def set_webhook(self, url=None, certificate=None, max_connections=None, allowed_updates=None, ip_address=None, - drop_pending_updates = None, timeout=None): + drop_pending_updates = None, timeout=None, secret_token=None): """ 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, @@ -286,10 +286,11 @@ def set_webhook(self, url=None, certificate=None, max_connections=None, allowed_ resolved through DNS :param drop_pending_updates: Pass True to drop all pending updates :param timeout: Integer. Request connection timeout + :param secret_token: Secret token to be used to verify the webhook request. :return: API reply. """ return apihelper.set_webhook(self.token, url, certificate, max_connections, allowed_updates, ip_address, - drop_pending_updates, timeout) + drop_pending_updates, timeout, secret_token) def delete_webhook(self, drop_pending_updates=None, timeout=None): """ @@ -2462,6 +2463,69 @@ def send_invoice( max_tip_amount, suggested_tip_amounts, protect_content) return types.Message.de_json(result) + + def create_invoice_link(self, + title: str, description: str, payload:str, provider_token: str, + currency: str, prices: List[types.LabeledPrice], + max_tip_amount: Optional[int] = None, + suggested_tip_amounts: Optional[List[int]]=None, + provider_data: Optional[str]=None, + photo_url: Optional[str]=None, + photo_size: Optional[int]=None, + photo_width: Optional[int]=None, + photo_height: Optional[int]=None, + need_name: Optional[bool]=None, + need_phone_number: Optional[bool]=None, + need_email: Optional[bool]=None, + need_shipping_address: Optional[bool]=None, + send_phone_number_to_provider: Optional[bool]=None, + send_email_to_provider: Optional[bool]=None, + is_flexible: Optional[bool]=None) -> str: + + """ + Use this method to create a link for an invoice. + Returns the created invoice link as String on success. + + Telegram documentation: + https://core.telegram.org/bots/api#createinvoicelink + + :param title: Product name, 1-32 characters + :param description: Product description, 1-255 characters + :param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, + use for your internal processes. + :param provider_token: Payments provider token, obtained via @Botfather + :param currency: Three-letter ISO 4217 currency code, + see https://core.telegram.org/bots/payments#supported-currencies + :param prices: Price breakdown, a list of components + (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + :param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency + :param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the smallest + :param provider_data: A JSON-serialized data about the invoice, which will be shared with the payment provider. + A detailed description of required fields should be provided by the payment provider. + :param photo_url: URL of the product photo for the invoice. Can be a photo of the goods + :param photo_size: Photo size in bytes + :param photo_width: Photo width + :param photo_height: Photo height + :param need_name: Pass True, if you require the user's full name to complete the order + :param need_phone_number: Pass True, if you require the user's phone number to complete the order + :param need_email: Pass True, if you require the user's email to complete the order + :param need_shipping_address: Pass True, if you require the user's shipping address to complete the order + :param send_phone_number_to_provider: Pass True, if user's phone number should be sent to provider + :param send_email_to_provider: Pass True, if user's email address should be sent to provider + :param is_flexible: Pass True, if the final price depends on the shipping method + + :return: Created invoice link as String on success. + """ + result = apihelper.create_invoice_link( + self.token, title, description, payload, provider_token, + currency, prices, max_tip_amount, suggested_tip_amounts, provider_data, + photo_url, photo_size, photo_width, photo_height, need_name, need_phone_number, + need_email, need_shipping_address, send_phone_number_to_provider, + send_email_to_provider, is_flexible) + return result + + + # noinspection PyShadowingBuiltins # TODO: rewrite this method like in API def send_poll( diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 8d4b2f765..ff8c8e231 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -268,7 +268,7 @@ def send_message( def set_webhook(token, url=None, certificate=None, max_connections=None, allowed_updates=None, ip_address=None, - drop_pending_updates = None, timeout=None): + drop_pending_updates = None, timeout=None, secret_token=None): method_url = r'setWebhook' payload = { 'url': url if url else "", @@ -286,6 +286,8 @@ def set_webhook(token, url=None, certificate=None, max_connections=None, allowed payload['drop_pending_updates'] = drop_pending_updates if timeout: payload['timeout'] = timeout + if secret_token: + payload['secret_token'] = secret_token return _make_request(token, method_url, params=payload, files=files) @@ -1622,6 +1624,45 @@ def answer_web_app_query(token, web_app_query_id, result: types.InlineQueryResul return _make_request(token, method_url, params=payload, method='post') +def create_invoice_link(token, title, description, payload, provider_token, + currency, prices, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None, + photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None, + need_email=None, need_shipping_address=None, send_phone_number_to_provider=None, + send_email_to_provider=None, is_flexible=None): + method_url = r'createInvoiceLink' + payload = {'title': title, 'description': description, 'payload': payload, 'provider_token': provider_token, + 'currency': currency, 'prices': _convert_list_json_serializable(prices)} + if max_tip_amount: + payload['max_tip_amount'] = max_tip_amount + if suggested_tip_amounts: + payload['suggested_tip_amounts'] = json.dumps(suggested_tip_amounts) + if provider_data: + payload['provider_data'] = provider_data + if photo_url: + payload['photo_url'] = photo_url + if photo_size: + payload['photo_size'] = photo_size + if photo_width: + payload['photo_width'] = photo_width + if photo_height: + payload['photo_height'] = photo_height + if need_name: + payload['need_name'] = need_name + if need_phone_number: + payload['need_phone_number'] = need_phone_number + if need_email: + payload['need_email'] = need_email + if need_shipping_address: + payload['need_shipping_address'] = need_shipping_address + if send_phone_number_to_provider: + payload['send_phone_number_to_provider'] = send_phone_number_to_provider + if send_email_to_provider: + payload['send_email_to_provider'] = send_email_to_provider + if is_flexible: + payload['is_flexible'] = is_flexible + return _make_request(token, method_url, params=payload, method='post') + + # noinspection PyShadowingBuiltins def send_poll( token, chat_id, From f52124827fa813936c89c36543aedc37c01cf1ed Mon Sep 17 00:00:00 2001 From: coder2020official Date: Tue, 21 Jun 2022 15:21:35 +0500 Subject: [PATCH 3/9] Added all new changes for types (is_premium, added_to_attachment_menu, and etc) --- telebot/types.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/telebot/types.py b/telebot/types.py index ff08fc697..4b252b966 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -215,7 +215,8 @@ def de_json(cls, json_string): return cls(**obj) def __init__(self, id, is_bot, first_name, last_name=None, username=None, language_code=None, - can_join_groups=None, can_read_all_group_messages=None, supports_inline_queries=None, **kwargs): + can_join_groups=None, can_read_all_group_messages=None, supports_inline_queries=None, + is_premium=None, added_to_attachment_menu=None, **kwargs): self.id: int = id self.is_bot: bool = is_bot self.first_name: str = first_name @@ -225,6 +226,9 @@ def __init__(self, id, is_bot, first_name, last_name=None, username=None, langua self.can_join_groups: bool = can_join_groups self.can_read_all_group_messages: bool = can_read_all_group_messages self.supports_inline_queries: bool = supports_inline_queries + self.is_premium: bool = is_premium + self.added_to_attachment_menu: bool = added_to_attachment_menu + @property def full_name(self): @@ -280,7 +284,8 @@ def __init__(self, id, type, title=None, username=None, first_name=None, description=None, invite_link=None, pinned_message=None, permissions=None, slow_mode_delay=None, message_auto_delete_time=None, has_protected_content=None, sticker_set_name=None, - can_set_sticker_set=None, linked_chat_id=None, location=None, **kwargs): + can_set_sticker_set=None, linked_chat_id=None, location=None, + join_to_send_messages=None, join_by_request=None, **kwargs): self.id: int = id self.type: str = type self.title: str = title @@ -289,6 +294,8 @@ def __init__(self, id, type, title=None, username=None, first_name=None, self.last_name: str = last_name self.photo: ChatPhoto = photo self.bio: str = bio + self.join_to_send_messages: bool = join_to_send_messages + self.join_by_request: bool = join_by_request self.has_private_forwards: bool = has_private_forwards self.description: str = description self.invite_link: str = invite_link @@ -2576,10 +2583,13 @@ def de_json(cls, json_string): obj['thumb'] = None if 'mask_position' in obj: obj['mask_position'] = MaskPosition.de_json(obj['mask_position']) + if 'premium_animation': + obj['premium_animation'] = File.de_json(obj['premium_animation']) return cls(**obj) def __init__(self, file_id, file_unique_id, width, height, is_animated, - is_video, thumb=None, emoji=None, set_name=None, mask_position=None, file_size=None, **kwargs): + is_video, thumb=None, emoji=None, set_name=None, mask_position=None, file_size=None, + premium_animation=None, **kwargs): self.file_id: str = file_id self.file_unique_id: str = file_unique_id self.width: int = width @@ -2591,6 +2601,7 @@ def __init__(self, file_id, file_unique_id, width, height, is_animated, self.set_name: str = set_name self.mask_position: MaskPosition = mask_position self.file_size: int = file_size + self.premium_animation: File = premium_animation From 7d931abe376195f7fd8b8e859d213dacbd942125 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Tue, 21 Jun 2022 15:22:00 +0500 Subject: [PATCH 4/9] Added secret token and create_invoice_link for asynctelebot --- telebot/async_telebot.py | 66 +++++++++++++++++++++++++++++++++++++-- telebot/asyncio_helper.py | 45 +++++++++++++++++++++++++- 2 files changed, 108 insertions(+), 3 deletions(-) diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index e2df52509..156665770 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -1384,7 +1384,7 @@ def enable_saving_states(self, filename="./.state-save/states.pkl"): self.current_states = StatePickleStorage(file_path=filename) async def set_webhook(self, url=None, certificate=None, max_connections=None, allowed_updates=None, ip_address=None, - drop_pending_updates = None, timeout=None): + drop_pending_updates = None, timeout=None, secret_token=None): """ 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, @@ -1409,10 +1409,11 @@ async def set_webhook(self, url=None, certificate=None, max_connections=None, al resolved through DNS :param drop_pending_updates: Pass True to drop all pending updates :param timeout: Integer. Request connection timeout + :param secret_token: Secret token to be used to verify the webhook :return: """ return await asyncio_helper.set_webhook(self.token, url, certificate, max_connections, allowed_updates, ip_address, - drop_pending_updates, timeout) + drop_pending_updates, timeout, secret_token) @@ -3066,6 +3067,67 @@ async def send_invoice( max_tip_amount, suggested_tip_amounts, protect_content) return types.Message.de_json(result) + + async def create_invoice_link(self, + title: str, description: str, payload:str, provider_token: str, + currency: str, prices: List[types.LabeledPrice], + max_tip_amount: Optional[int] = None, + suggested_tip_amounts: Optional[List[int]]=None, + provider_data: Optional[str]=None, + photo_url: Optional[str]=None, + photo_size: Optional[int]=None, + photo_width: Optional[int]=None, + photo_height: Optional[int]=None, + need_name: Optional[bool]=None, + need_phone_number: Optional[bool]=None, + need_email: Optional[bool]=None, + need_shipping_address: Optional[bool]=None, + send_phone_number_to_provider: Optional[bool]=None, + send_email_to_provider: Optional[bool]=None, + is_flexible: Optional[bool]=None) -> str: + + """ + Use this method to create a link for an invoice. + Returns the created invoice link as String on success. + + Telegram documentation: + https://core.telegram.org/bots/api#createinvoicelink + + :param title: Product name, 1-32 characters + :param description: Product description, 1-255 characters + :param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, + use for your internal processes. + :param provider_token: Payments provider token, obtained via @Botfather + :param currency: Three-letter ISO 4217 currency code, + see https://core.telegram.org/bots/payments#supported-currencies + :param prices: Price breakdown, a list of components + (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + :param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency + :param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the smallest + :param provider_data: A JSON-serialized data about the invoice, which will be shared with the payment provider. + A detailed description of required fields should be provided by the payment provider. + :param photo_url: URL of the product photo for the invoice. Can be a photo of the goods + :param photo_size: Photo size in bytes + :param photo_width: Photo width + :param photo_height: Photo height + :param need_name: Pass True, if you require the user's full name to complete the order + :param need_phone_number: Pass True, if you require the user's phone number to complete the order + :param need_email: Pass True, if you require the user's email to complete the order + :param need_shipping_address: Pass True, if you require the user's shipping address to complete the order + :param send_phone_number_to_provider: Pass True, if user's phone number should be sent to provider + :param send_email_to_provider: Pass True, if user's email address should be sent to provider + :param is_flexible: Pass True, if the final price depends on the shipping method + + :return: Created invoice link as String on success. + """ + result = await asyncio_helper.create_invoice_link( + self.token, title, description, payload, provider_token, + currency, prices, max_tip_amount, suggested_tip_amounts, provider_data, + photo_url, photo_size, photo_width, photo_height, need_name, need_phone_number, + need_email, need_shipping_address, send_phone_number_to_provider, + send_email_to_provider, is_flexible) + return result + # noinspection PyShadowingBuiltins async def send_poll( self, chat_id: Union[int, str], question: str, options: List[str], diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index a7bcccfa3..51b60e98f 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -171,7 +171,7 @@ async def download_file(token, file_path): async def set_webhook(token, url=None, certificate=None, max_connections=None, allowed_updates=None, ip_address=None, - drop_pending_updates = None, timeout=None): + drop_pending_updates = None, timeout=None, secret_token=None): method_url = r'setWebhook' payload = { 'url': url if url else "", @@ -189,6 +189,8 @@ async def set_webhook(token, url=None, certificate=None, max_connections=None, a payload['drop_pending_updates'] = drop_pending_updates if timeout: payload['timeout'] = timeout + if secret_token: + payload['secret_token'] = secret_token return await _process_request(token, method_url, params=payload, files=files) @@ -1599,6 +1601,47 @@ async def delete_sticker_from_set(token, sticker): return await _process_request(token, method_url, params=payload, method='post') + +async def create_invoice_link(token, title, description, payload, provider_token, + currency, prices, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None, + photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None, + need_email=None, need_shipping_address=None, send_phone_number_to_provider=None, + send_email_to_provider=None, is_flexible=None): + method_url = r'createInvoiceLink' + payload = {'title': title, 'description': description, 'payload': payload, 'provider_token': provider_token, + 'currency': currency, 'prices': await _convert_list_json_serializable(prices)} + if max_tip_amount: + payload['max_tip_amount'] = max_tip_amount + if suggested_tip_amounts: + payload['suggested_tip_amounts'] = json.dumps(suggested_tip_amounts) + if provider_data: + payload['provider_data'] = provider_data + if photo_url: + payload['photo_url'] = photo_url + if photo_size: + payload['photo_size'] = photo_size + if photo_width: + payload['photo_width'] = photo_width + if photo_height: + payload['photo_height'] = photo_height + if need_name: + payload['need_name'] = need_name + if need_phone_number: + payload['need_phone_number'] = need_phone_number + if need_email: + payload['need_email'] = need_email + if need_shipping_address: + payload['need_shipping_address'] = need_shipping_address + if send_phone_number_to_provider: + payload['send_phone_number_to_provider'] = send_phone_number_to_provider + if send_email_to_provider: + payload['send_email_to_provider'] = send_email_to_provider + if is_flexible: + payload['is_flexible'] = is_flexible + return await _process_request(token, method_url, params=payload, method='post') + + + # noinspection PyShadowingBuiltins async def send_poll( token, chat_id, From d7f34ae37052e2ae61adef97e4f8a9d800ac6c76 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Tue, 21 Jun 2022 15:27:45 +0500 Subject: [PATCH 5/9] Fix the typo --- telebot/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telebot/types.py b/telebot/types.py index 4b252b966..ee67cb99a 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -2583,7 +2583,7 @@ def de_json(cls, json_string): obj['thumb'] = None if 'mask_position' in obj: obj['mask_position'] = MaskPosition.de_json(obj['mask_position']) - if 'premium_animation': + if 'premium_animation' in obj: obj['premium_animation'] = File.de_json(obj['premium_animation']) return cls(**obj) From a7fb8a2becd5a5c5de8c49e16a0664579598ac46 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Tue, 21 Jun 2022 15:28:01 +0500 Subject: [PATCH 6/9] Implemented some tests --- tests/test_types.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_types.py b/tests/test_types.py index dedee19dd..29a50752c 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -6,10 +6,13 @@ def test_json_user(): - jsonstring = r'{"id":101176298,"first_name":"RDSSBOT","last_name":")))","username":"rdss_bot","is_bot":true}' + jsonstring = r'{"id":101176298,"first_name":"RDSSBOT","last_name":")))","username":"rdss_bot","is_bot":true, "is_premium":true, "added_to_attachment_menu": true}' u = types.User.de_json(jsonstring) assert u.id == 101176298 assert u.full_name == 'RDSSBOT )))' + assert u.is_premium is True + assert u.added_to_attachment_menu is True + def test_json_message(): @@ -155,12 +158,14 @@ def test_json_update(): def test_json_chat(): - json_string = r'{"id": -111111,"title": "Test Title","type": "group"}' + json_string = r'{"id": -111111,"title": "Test Title","type": "group", "join_to_send_messages": true, "join_by_request": true}' chat = types.Chat.de_json(json_string) assert chat.id == -111111 assert chat.type == 'group' assert chat.title == 'Test Title' - + assert chat.join_to_send_messages is True + assert chat.join_by_request is True + def test_InlineQueryResultCachedPhoto(): iq = types.InlineQueryResultCachedPhoto('aaa', 'Fileid') From 87698027447bdb09db3b0ffc99f48e2d4f0cfc37 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Tue, 21 Jun 2022 15:44:42 +0500 Subject: [PATCH 7/9] Bump version to 4.6.0 --- docs/source/conf.py | 2 +- telebot/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 8344e6d42..20ef458f2 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,7 +22,7 @@ author = 'coder2020official' # The full version, including alpha/beta/rc tags -release = '4.5.1' +release = '4.6.0' # -- General configuration --------------------------------------------------- diff --git a/telebot/version.py b/telebot/version.py index 6293a1798..ff913fb13 100644 --- a/telebot/version.py +++ b/telebot/version.py @@ -1,3 +1,3 @@ # Versions should comply with PEP440. # This line is parsed in setup.py: -__version__ = '4.5.1' +__version__ = '4.6.0' From 1342cab25933ff7904b918003bb503f73003e60b Mon Sep 17 00:00:00 2001 From: coder2020official Date: Thu, 23 Jun 2022 12:05:26 +0500 Subject: [PATCH 8/9] Fix boolean parameters --- telebot/apihelper.py | 2 +- telebot/asyncio_helper.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/telebot/apihelper.py b/telebot/apihelper.py index ff8c8e231..fc76a0016 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -1658,7 +1658,7 @@ def create_invoice_link(token, title, description, payload, provider_token, payload['send_phone_number_to_provider'] = send_phone_number_to_provider if send_email_to_provider: payload['send_email_to_provider'] = send_email_to_provider - if is_flexible: + if is_flexible is not None: payload['is_flexible'] = is_flexible return _make_request(token, method_url, params=payload, method='post') diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 51b60e98f..1c01893bd 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -1636,7 +1636,7 @@ async def create_invoice_link(token, title, description, payload, provider_token payload['send_phone_number_to_provider'] = send_phone_number_to_provider if send_email_to_provider: payload['send_email_to_provider'] = send_email_to_provider - if is_flexible: + if is_flexible is not None: payload['is_flexible'] = is_flexible return await _process_request(token, method_url, params=payload, method='post') From 7f9dac414796c99493bd09c5ff6ff553f64f2982 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Thu, 23 Jun 2022 12:46:27 +0500 Subject: [PATCH 9/9] Fix previous commit --- telebot/apihelper.py | 12 ++++++------ telebot/asyncio_helper.py | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/telebot/apihelper.py b/telebot/apihelper.py index fc76a0016..07f2f57bc 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -1646,17 +1646,17 @@ def create_invoice_link(token, title, description, payload, provider_token, payload['photo_width'] = photo_width if photo_height: payload['photo_height'] = photo_height - if need_name: + if need_name is not None: payload['need_name'] = need_name - if need_phone_number: + if need_phone_number is not None: payload['need_phone_number'] = need_phone_number - if need_email: + if need_email is not None: payload['need_email'] = need_email - if need_shipping_address: + if need_shipping_address is not None: payload['need_shipping_address'] = need_shipping_address - if send_phone_number_to_provider: + if send_phone_number_to_provider is not None: payload['send_phone_number_to_provider'] = send_phone_number_to_provider - if send_email_to_provider: + if send_email_to_provider is not None: payload['send_email_to_provider'] = send_email_to_provider if is_flexible is not None: payload['is_flexible'] = is_flexible diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 1c01893bd..168edff7e 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -1624,17 +1624,17 @@ async def create_invoice_link(token, title, description, payload, provider_token payload['photo_width'] = photo_width if photo_height: payload['photo_height'] = photo_height - if need_name: + if need_name is not None: payload['need_name'] = need_name - if need_phone_number: + if need_phone_number is not None: payload['need_phone_number'] = need_phone_number - if need_email: + if need_email is not None: payload['need_email'] = need_email - if need_shipping_address: + if need_shipping_address is not None: payload['need_shipping_address'] = need_shipping_address - if send_phone_number_to_provider: + if send_phone_number_to_provider is not None: payload['send_phone_number_to_provider'] = send_phone_number_to_provider - if send_email_to_provider: + if send_email_to_provider is not None: payload['send_email_to_provider'] = send_email_to_provider if is_flexible is not None: payload['is_flexible'] = is_flexible