Skip to content

Commit

Permalink
Fixes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
coder2020official committed Sep 16, 2024
1 parent e7d0672 commit 3759a95
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3201,7 +3201,7 @@ def send_paid_media(
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,
media_payload=payload)
payload=payload)
)


Expand Down
28 changes: 14 additions & 14 deletions telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,32 +530,32 @@ 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, media_payload=None):
business_connection_id=None, 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}
_payload = {'chat_id': chat_id, 'star_count': star_count, 'media': media_json}
if caption:
payload['caption'] = caption
_payload['caption'] = caption
if parse_mode:
payload['parse_mode'] = parse_mode
_payload['parse_mode'] = parse_mode
if caption_entities:
payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
_payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
if show_caption_above_media is not None:
payload['show_caption_above_media'] = show_caption_above_media
_payload['show_caption_above_media'] = show_caption_above_media
if disable_notification is not None:
payload['disable_notification'] = disable_notification
_payload['disable_notification'] = disable_notification
if protect_content is not None:
payload['protect_content'] = protect_content
_payload['protect_content'] = protect_content
if reply_parameters is not None:
payload['reply_parameters'] = reply_parameters.to_json()
_payload['reply_parameters'] = reply_parameters.to_json()
if reply_markup:
payload['reply_markup'] = _convert_markup(reply_markup)
_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
_payload['business_connection_id'] = business_connection_id
if payload:
_payload['payload'] = payload
return _make_request(
token, method_url, params=payload,
token, method_url, params=_payload,
method='post' if files else 'get',
files=files if files else None)

Expand Down
2 changes: 1 addition & 1 deletion telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4682,7 +4682,7 @@ async def send_paid_media(
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,
media_payload=payload))
payload=payload))

async def send_media_group(
self, chat_id: Union[int, str],
Expand Down
29 changes: 15 additions & 14 deletions telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,33 +520,34 @@ 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, media_payload=None):
business_connection_id=None, 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}
_payload = {'chat_id': chat_id, 'star_count': star_count, 'media': media_json}
# USE _payload for request payload
if caption:
payload['caption'] = caption
_payload['caption'] = caption
if parse_mode:
payload['parse_mode'] = parse_mode
_payload['parse_mode'] = parse_mode
if caption_entities:
payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
_payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
if show_caption_above_media is not None:
payload['show_caption_above_media'] = show_caption_above_media
_payload['show_caption_above_media'] = show_caption_above_media
if disable_notification is not None:
payload['disable_notification'] = disable_notification
_payload['disable_notification'] = disable_notification
if protect_content is not None:
payload['protect_content'] = protect_content
_payload['protect_content'] = protect_content
if reply_parameters is not None:
payload['reply_parameters'] = reply_parameters.to_json()
_payload['reply_parameters'] = reply_parameters.to_json()
if reply_markup:
payload['reply_markup'] = _convert_markup(reply_markup)
_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
_payload['business_connection_id'] = business_connection_id
if payload:
_payload['payload'] = payload

return await _process_request(
token, method_url, params=payload,
token, method_url, params=_payload,
method='post' if files else 'get',
files=files if files else None)

Expand Down
4 changes: 2 additions & 2 deletions telebot/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9502,8 +9502,8 @@ def de_json(cls, json_string):
def __init__(self, source, giveaway_message_id, user=None, is_unclaimed=None, prize_star_count=None, **kwargs):
self.source: str = source
self.giveaway_message_id: int = giveaway_message_id
self.user: User = user
self.is_unclaimed: bool = is_unclaimed
self.user: Optional[User] = user
self.is_unclaimed: Optional[bool] = is_unclaimed
self.prize_star_count: Optional[int] = prize_star_count


Expand Down
2 changes: 1 addition & 1 deletion telebot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result",
"callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_member",
"chat_join_request", "message_reaction", "message_reaction_count", "chat_boost", "removed_chat_boost",
"business_connection", "business_message", "edited_business_message", "deleted_business_messages"
"business_connection", "business_message", "edited_business_message", "deleted_business_messages", "purchased_paid_media"
]


Expand Down

0 comments on commit 3759a95

Please sign in to comment.