Skip to content

Commit

Permalink
Fixes to bot API 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
coder2020official committed May 31, 2024
1 parent a95d100 commit 2e4f92d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
10 changes: 6 additions & 4 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4954,7 +4954,7 @@ def get_game_high_scores(

def send_invoice(
self, chat_id: Union[int, str], title: str, description: str,
invoice_payload: str, provider_token: str, currency: str,
invoice_payload: str, provider_token: Union[str, None], currency: str,
prices: List[types.LabeledPrice], start_parameter: Optional[str]=None,
photo_url: Optional[str]=None, photo_size: Optional[int]=None,
photo_width: Optional[int]=None, photo_height: Optional[int]=None,
Expand Down Expand Up @@ -4993,7 +4993,8 @@ def send_invoice(
use for your internal processes.
:type invoice_payload: :obj:`str`
:param provider_token: Payments provider token, obtained via @Botfather
:param provider_token: Payments provider token, obtained via @Botfather; Pass None to omit the parameter
to use "XTR" currency
:type provider_token: :obj:`str`
:param currency: Three-letter ISO 4217 currency code,
Expand Down Expand Up @@ -5125,7 +5126,7 @@ def send_invoice(
)

def create_invoice_link(self,
title: str, description: str, payload:str, provider_token: str,
title: str, description: str, payload:str, provider_token: Union[str, None],
currency: str, prices: List[types.LabeledPrice],
max_tip_amount: Optional[int] = None,
suggested_tip_amounts: Optional[List[int]]=None,
Expand Down Expand Up @@ -5159,7 +5160,8 @@ def create_invoice_link(self,
use for your internal processes.
:type payload: :obj:`str`
:param provider_token: Payments provider token, obtained via @Botfather
:param provider_token: Payments provider token, obtained via @Botfather; Pass None to omit the parameter
to use "XTR" currency
:type provider_token: :obj:`str`
:param currency: Three-letter ISO 4217 currency code,
Expand Down
12 changes: 8 additions & 4 deletions telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ def send_invoice(
"""
method_url = r'sendInvoice'
payload = {'chat_id': chat_id, 'title': title, 'description': description, 'payload': invoice_payload,
'provider_token': provider_token, 'currency': currency,
'currency': currency,
'prices': _convert_list_json_serializable(prices)}
if start_parameter:
payload['start_parameter'] = start_parameter
Expand Down Expand Up @@ -1626,6 +1626,8 @@ def send_invoice(
payload['reply_parameters'] = reply_parameters.to_json()
if message_effect_id:
payload['message_effect_id'] = message_effect_id
if provider_token is not None:
payload['provider_token'] = provider_token
return _make_request(token, method_url, params=payload)


Expand Down Expand Up @@ -1666,13 +1668,13 @@ def answer_pre_checkout_query(token, pre_checkout_query_id, ok, error_message=No
def refund_star_payment(token, user_id, telegram_payment_charge_id):
method_url = 'refundStarPayment'
payload = {'user_id': user_id, 'telegram_payment_charge_id': telegram_payment_charge_id}
return _make_request(token, method_url, params=payload, method='post')
return _make_request(token, method_url, params=payload)


def unpin_all_general_forum_topic_messages(token, chat_id):
method_url = 'unpinAllGeneralForumTopicMessages'
payload = {'chat_id': chat_id}
return _make_request(token, method_url, params=payload, method='post')
return _make_request(token, method_url, params=payload)

# InlineQuery

Expand Down Expand Up @@ -1835,7 +1837,7 @@ def create_invoice_link(token, title, description, payload, provider_token,
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,
payload = {'title': title, 'description': description, 'payload': payload,
'currency': currency, 'prices': _convert_list_json_serializable(prices)}
if max_tip_amount:
payload['max_tip_amount'] = max_tip_amount
Expand Down Expand Up @@ -1865,6 +1867,8 @@ def create_invoice_link(token, title, description, payload, provider_token,
payload['send_email_to_provider'] = send_email_to_provider
if is_flexible is not None:
payload['is_flexible'] = is_flexible
if provider_token is not None:
payload['provider_token'] = provider_token
return _make_request(token, method_url, params=payload, method='post')


Expand Down
10 changes: 6 additions & 4 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6291,7 +6291,7 @@ async def get_game_high_scores(

async def send_invoice(
self, chat_id: Union[int, str], title: str, description: str,
invoice_payload: str, provider_token: str, currency: str,
invoice_payload: str, provider_token: Union[str, None], currency: str,
prices: List[types.LabeledPrice], start_parameter: Optional[str]=None,
photo_url: Optional[str]=None, photo_size: Optional[int]=None,
photo_width: Optional[int]=None, photo_height: Optional[int]=None,
Expand Down Expand Up @@ -6330,7 +6330,8 @@ async def send_invoice(
use for your internal processes.
:type invoice_payload: :obj:`str`
:param provider_token: Payments provider token, obtained via @Botfather
:param provider_token: Payments provider token, obtained via @Botfather; Pass None to omit the parameter
to use "XTR" currency
:type provider_token: :obj:`str`
:param currency: Three-letter ISO 4217 currency code,
Expand Down Expand Up @@ -6458,7 +6459,7 @@ async def send_invoice(


async def create_invoice_link(self,
title: str, description: str, payload:str, provider_token: str,
title: str, description: str, payload:str, provider_token: Union[str, None],
currency: str, prices: List[types.LabeledPrice],
max_tip_amount: Optional[int] = None,
suggested_tip_amounts: Optional[List[int]]=None,
Expand Down Expand Up @@ -6492,7 +6493,8 @@ async def create_invoice_link(self,
use for your internal processes.
:type payload: :obj:`str`
:param provider_token: Payments provider token, obtained via @Botfather
:param provider_token: Payments provider token, obtained via @Botfather; Pass None to omit the parameter
to use "XTR" currency
:type provider_token: :obj:`str`
:param currency: Three-letter ISO 4217 currency code,
Expand Down
14 changes: 9 additions & 5 deletions telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,8 +1561,8 @@ async def send_invoice(
"""
method_url = r'sendInvoice'
payload = {'chat_id': chat_id, 'title': title, 'description': description, 'payload': invoice_payload,
'provider_token': provider_token, 'currency': currency,
'prices': await _convert_list_json_serializable(prices)}
'currency': currency,
'prices': await _convert_list_json_serializable(prices)}
if start_parameter:
payload['start_parameter'] = start_parameter
if photo_url:
Expand Down Expand Up @@ -1607,6 +1607,8 @@ async def send_invoice(
payload['message_thread_id'] = message_thread_id
if message_effect_id:
payload['message_effect_id'] = message_effect_id
if provider_token is not None:
payload['provider_token'] = provider_token
return await _process_request(token, method_url, params=payload)


Expand Down Expand Up @@ -1648,13 +1650,13 @@ async def answer_pre_checkout_query(token, pre_checkout_query_id, ok, error_mess
async def refund_star_payment(token, user_id, telegram_payment_charge_id):
method_url = 'refundStarPayment'
payload = {'user_id': user_id, 'telegram_payment_charge_id': telegram_payment_charge_id}
return await _process_request(token, method_url, params=payload, method='post')
return await _process_request(token, method_url, params=payload)


async def unpin_all_general_forum_topic_messages(token, chat_id):
method_url = 'unpinAllGeneralForumTopicMessages'
payload = {'chat_id': chat_id}
return await _process_request(token, method_url, params=payload, method='post')
return await _process_request(token, method_url, params=payload)

# InlineQuery

Expand Down Expand Up @@ -1812,7 +1814,7 @@ async def create_invoice_link(token, title, description, payload, provider_token
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,
payload = {'title': title, 'description': description, 'payload': payload,
'currency': currency, 'prices': await _convert_list_json_serializable(prices)}
if max_tip_amount:
payload['max_tip_amount'] = max_tip_amount
Expand Down Expand Up @@ -1842,6 +1844,8 @@ async def create_invoice_link(token, title, description, payload, provider_token
payload['send_email_to_provider'] = send_email_to_provider
if is_flexible is not None:
payload['is_flexible'] = is_flexible
if provider_token is not None:
payload['provider_token'] = provider_token
return await _process_request(token, method_url, params=payload, method='post')


Expand Down
10 changes: 5 additions & 5 deletions telebot/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4494,7 +4494,7 @@ def to_dict(self):
json_dict['photo_height'] = self.photo_height
if self.description:
json_dict['description'] = self.description
if self.show_caption_above_media:
if self.show_caption_above_media is not None:
json_dict['show_caption_above_media'] = self.show_caption_above_media
return json_dict

Expand Down Expand Up @@ -4593,7 +4593,7 @@ def to_dict(self):
json_dict['gif_duration'] = self.gif_duration
if self.thumbnail_mime_type:
json_dict['thumbnail_mime_type'] = self.thumbnail_mime_type
if self.show_caption_above_media:
if self.show_caption_above_media is not None:
json_dict['show_caption_above_media'] = self.show_caption_above_media
return json_dict

Expand Down Expand Up @@ -4692,7 +4692,7 @@ def to_dict(self):
json_dict['mpeg4_duration '] = self.mpeg4_duration
if self.thumbnail_mime_type:
json_dict['thumbnail_mime_type'] = self.thumbnail_mime_type
if self.show_caption_above_media:
if self.show_caption_above_media is not None:
json_dict['show_caption_above_media'] = self.show_caption_above_media
return json_dict

Expand Down Expand Up @@ -4790,7 +4790,7 @@ def to_dict(self):
json_dict['video_duration'] = self.video_duration
if self.description:
json_dict['description'] = self.description
if self.show_caption_above_media:
if self.show_caption_above_media is not None:
json_dict['show_caption_above_media'] = self.show_caption_above_media
return json_dict

Expand Down Expand Up @@ -5381,7 +5381,7 @@ def to_json(self):
json_dict['parse_mode'] = self.parse_mode
if self.caption_entities:
json_dict['caption_entities'] = MessageEntity.to_list_of_dicts(self.caption_entities)
if self.show_caption_above_media:
if self.show_caption_above_media is not None:
json_dict['show_caption_above_media'] = self.show_caption_above_media
return json.dumps(json_dict)

Expand Down

0 comments on commit 2e4f92d

Please sign in to comment.