Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c448bba
Update types.py
coder2020official Apr 12, 2025
805c78f
Add business account methods
coder2020official Apr 12, 2025
1d32718
Added AcceptedGiftTypes and set_business_account_gift_settings
coder2020official Apr 12, 2025
3e0f06a
Add get_business_account_star_balance
coder2020official Apr 12, 2025
af858de
Added transfer_business_account_stars
coder2020official Apr 12, 2025
c012a59
Added get_business_account_gifts, OwnedGiftRegular, OwnedGiftUnique, …
coder2020official Apr 12, 2025
3d238a4
Added convert_gift_to_stars
coder2020official Apr 12, 2025
817f2ad
Added upgrade_gift and transfer_gift methods
coder2020official Apr 12, 2025
b47c73f
Added InputStoryContent
coder2020official Apr 12, 2025
1713909
Stories
coder2020official Apr 12, 2025
1c08163
posting, editing, deleting stories(needs testing)
coder2020official Apr 12, 2025
b05d209
Replaced the field can_send_gift with the field accepted_gift_types …
coder2020official Apr 12, 2025
6fedece
Added unique_gift and gift
coder2020official Apr 12, 2025
e3d7f96
Added gift_premium_subscription
coder2020official Apr 12, 2025
f76cac8
Added premium_subscription_duration to TransactionPartnerUser
coder2020official Apr 12, 2025
0bd9133
Added transaction_type to TransactionPartnerUser
coder2020official Apr 12, 2025
950d7c6
Added paid_message_price_changed
coder2020official Apr 12, 2025
9fb4fdd
Added paid_star_count
coder2020official Apr 12, 2025
0d1e515
Added set_business_account_profile_photo and remove_business_account_…
coder2020official Apr 12, 2025
d63b07a
Fix issues with posting stories
coder2020official Apr 13, 2025
49684b5
Fix stories for async
coder2020official Apr 13, 2025
533b52c
Fix issues related with Bot api 9.0
coder2020official Apr 19, 2025
d4f5ead
Fix typehints
coder2020official Apr 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added convert_gift_to_stars
  • Loading branch information
coder2020official committed Apr 12, 2025
commit 3d238a4a2a9eea85eed2d9f862d0ebcbe157c0fd
17 changes: 17 additions & 0 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6584,6 +6584,23 @@ def get_business_account_gifts(
)
)

def convert_gift_to_stars(self, business_connection_id: str, owned_gift_id: str) -> bool:
"""
Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success.

Telegram documentation: https://core.telegram.org/bots/api#convertgifttostars

:param business_connection_id: Unique identifier of the business connection
:type business_connection_id: :obj:`str`

:param owned_gift_id: Unique identifier of the regular gift that should be converted to Telegram Stars
:type owned_gift_id: :obj:`str`

:return: Returns True on success.
:rtype: :obj:`bool`
"""
return apihelper.convert_gift_to_stars(self.token, business_connection_id, owned_gift_id)

def get_available_gifts(self) -> types.Gifts:
"""
Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.
Expand Down
6 changes: 6 additions & 0 deletions telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,12 @@ def get_business_account_gifts(token, business_connection_id, exclude_unsaved=No
payload['limit'] = limit
return _make_request(token, method_url, params=payload)


def convert_gift_to_stars(token, business_connection_id, owned_gift_id):
method_url = 'convertGiftToStars'
payload = {'business_connection_id': business_connection_id, 'owned_gift_id': owned_gift_id}
return _make_request(token, method_url, params=payload, method='post')

def create_new_sticker_set(
token, user_id, name, title, stickers, sticker_type=None, needs_repainting=None):
method_url = 'createNewStickerSet'
Expand Down
17 changes: 17 additions & 0 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8039,6 +8039,23 @@ async def get_business_account_gifts(
limit=limit
)
)

async def convert_gift_to_stars(self, business_connection_id: str, owned_gift_id: str) -> bool:
"""
Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success.

Telegram documentation: https://core.telegram.org/bots/api#convertgifttostars

:param business_connection_id: Unique identifier of the business connection
:type business_connection_id: :obj:`str`

:param owned_gift_id: Unique identifier of the regular gift that should be converted to Telegram Stars
:type owned_gift_id: :obj:`str`

:return: Returns True on success.
:rtype: :obj:`bool`
"""
return await asyncio_helper.convert_gift_to_stars(self.token, business_connection_id, owned_gift_id)

async def get_available_gifts(self) -> types.Gifts:
"""
Expand Down
5 changes: 5 additions & 0 deletions telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,11 @@ async def get_business_account_gifts(token, business_connection_id, exclude_unsa
payload['limit'] = limit
return await _process_request(token, method_url, params=payload)

async def convert_gift_to_stars(token, business_connection_id, owned_gift_id):
method_url = 'convertGiftToStars'
payload = {'business_connection_id': business_connection_id, 'owned_gift_id': owned_gift_id}
return await _process_request(token, method_url, params=payload, method='post')

async def get_available_gifts(token):
method_url = 'getAvailableGifts'
return await _process_request(token, method_url)
Expand Down