Skip to content

Commit

Permalink
added payload to sendpaidmedia
Browse files Browse the repository at this point in the history
  • Loading branch information
coder2020official committed Sep 6, 2024
1 parent 6ebe88d commit e3081fb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
7 changes: 6 additions & 1 deletion telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3146,6 +3146,7 @@ def send_paid_media(
show_caption_above_media: Optional[bool]=None, disable_notification: Optional[bool]=None,
protect_content: Optional[bool]=None, reply_parameters: Optional[types.ReplyParameters]=None,
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, business_connection_id: Optional[str]=None,
payload: Optional[str]=None
) -> types.Message:
"""
Use this method to send paid media to channel chats. On success, the sent Message is returned.
Expand Down Expand Up @@ -3188,6 +3189,9 @@ def send_paid_media(
:param business_connection_id: Identifier of a business connection, in which the message will be sent
:type business_connection_id: :obj:`str`
:param payload: Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
:type payload: :obj:`str`
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
Expand All @@ -3196,7 +3200,8 @@ def send_paid_media(
self.token, chat_id, star_count, media, caption=caption, parse_mode=parse_mode,
caption_entities=caption_entities, show_caption_above_media=show_caption_above_media,
disable_notification=disable_notification, protect_content=protect_content,
reply_parameters=reply_parameters, reply_markup=reply_markup, business_connection_id=business_connection_id)
reply_parameters=reply_parameters, reply_markup=reply_markup, business_connection_id=business_connection_id,
media_payload=payload)
)


Expand Down
4 changes: 3 additions & 1 deletion telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def send_paid_media(
token, chat_id, star_count, media,
caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None,
disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None,
business_connection_id=None):
business_connection_id=None, media_payload=None):
method_url = r'sendPaidMedia'
media_json, files = convert_input_media_array(media)
payload = {'chat_id': chat_id, 'star_count': star_count, 'media': media_json}
Expand All @@ -552,6 +552,8 @@ def send_paid_media(
payload['reply_markup'] = _convert_markup(reply_markup)
if business_connection_id:
payload['business_connection_id'] = business_connection_id
if media_payload:
payload['payload'] = media_payload
return _make_request(
token, method_url, params=payload,
method='post' if files else 'get',
Expand Down
9 changes: 7 additions & 2 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4627,7 +4627,8 @@ async def send_paid_media(
caption: Optional[str]=None, parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None,
show_caption_above_media: Optional[bool]=None, disable_notification: Optional[bool]=None,
protect_content: Optional[bool]=None, reply_parameters: Optional[types.ReplyParameters]=None,
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, business_connection_id: Optional[str]=None) -> types.Message:
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, business_connection_id: Optional[str]=None,
payload: Optional[str]=None) -> types.Message:
"""
Use this method to send paid media to channel chats. On success, the sent Message is returned.
Expand Down Expand Up @@ -4669,6 +4670,9 @@ async def send_paid_media(
:param business_connection_id: Identifier of a business connection, in which the message will be sent
:type business_connection_id: :obj:`str`
:param payload: Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
:type payload: :obj:`str`
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
Expand All @@ -4677,7 +4681,8 @@ async def send_paid_media(
self.token, chat_id, star_count, media, caption=caption, parse_mode=parse_mode,
caption_entities=caption_entities, show_caption_above_media=show_caption_above_media,
disable_notification=disable_notification, protect_content=protect_content,
reply_parameters=reply_parameters, reply_markup=reply_markup, business_connection_id=business_connection_id))
reply_parameters=reply_parameters, reply_markup=reply_markup, business_connection_id=business_connection_id,
media_payload=payload))

async def send_media_group(
self, chat_id: Union[int, str],
Expand Down
5 changes: 4 additions & 1 deletion telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ async def send_paid_media(
token, chat_id, star_count, media,
caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None,
disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None,
business_connection_id=None):
business_connection_id=None, media_payload=None):
method_url = r'sendPaidMedia'
media_json, files = convert_input_media_array(media)
payload = {'chat_id': chat_id, 'star_count': star_count, 'media': media_json}
Expand All @@ -542,6 +542,9 @@ async def send_paid_media(
payload['reply_markup'] = _convert_markup(reply_markup)
if business_connection_id:
payload['business_connection_id'] = business_connection_id
if media_payload:
payload['payload'] = media_payload

return await _process_request(
token, method_url, params=payload,
method='post' if files else 'get',
Expand Down

0 comments on commit e3081fb

Please sign in to comment.