Skip to content

Commit af858de

Browse files
Added transfer_business_account_stars
1 parent 3e0f06a commit af858de

5 files changed

Lines changed: 45 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
1111
<p align="center">Both synchronous and asynchronous.</p>
1212

13-
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#february-12-2025"><img src="https://img.shields.io/badge/Bot%20API-8.3-blue?logo=telegram" alt="Supported Bot API version"></a>
13+
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#april-11-2025"><img src="https://img.shields.io/badge/Bot%20API-9.0-blue?logo=telegram" alt="Supported Bot API version"></a>
1414

1515
<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
1616
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>

telebot/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6507,6 +6507,23 @@ def get_business_account_star_balance(self, business_connection_id: str) -> type
65076507
return types.StarAmount.de_json(
65086508
apihelper.get_business_account_star_balance(self.token, business_connection_id)
65096509
)
6510+
6511+
def transfer_business_account_stars(self, business_connection_id: str, star_count: int) -> bool:
6512+
"""
6513+
Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success.
6514+
6515+
Telegram documentation: https://core.telegram.org/bots/api#transferbusinessaccountstars
6516+
6517+
:param business_connection_id: Unique identifier of the business connection
6518+
:type business_connection_id: :obj:`str`
6519+
6520+
:param star_count: Number of Telegram Stars to transfer; 1-10000
6521+
:type star_count: :obj:`int`
6522+
6523+
:return: Returns True on success.
6524+
:rtype: :obj:`bool`
6525+
"""
6526+
return apihelper.transfer_business_account_stars(self.token, business_connection_id, star_count)
65106527

65116528
def get_available_gifts(self) -> types.Gifts:
65126529
"""

telebot/apihelper.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,6 +2040,11 @@ def get_business_account_star_balance(token, business_connection_id):
20402040
payload = {'business_connection_id': business_connection_id}
20412041
return _make_request(token, method_url, params=payload)
20422042

2043+
def transfer_business_account_stars(token, business_connection_id, star_count):
2044+
method_url = 'transferBusinessAccountStars'
2045+
payload = {'business_connection_id': business_connection_id, 'star_count': star_count}
2046+
return _make_request(token, method_url, params=payload, method='post')
2047+
20432048
def create_new_sticker_set(
20442049
token, user_id, name, title, stickers, sticker_type=None, needs_repainting=None):
20452050
method_url = 'createNewStickerSet'

telebot/async_telebot.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7963,6 +7963,24 @@ async def get_business_account_star_balance(self, business_connection_id: str) -
79637963
return types.StarAmount.de_json(
79647964
await asyncio_helper.get_business_account_star_balance(self.token, business_connection_id)
79657965
)
7966+
7967+
async def transfer_business_account_stars(self, business_connection_id: str, star_count: int) -> bool:
7968+
"""
7969+
Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success.
7970+
7971+
Telegram documentation: https://core.telegram.org/bots/api#transferbusinessaccountstars
7972+
7973+
:param business_connection_id: Unique identifier of the business connection
7974+
:type business_connection_id: :obj:`str`
7975+
7976+
:param star_count: Number of Telegram Stars to transfer; 1-10000
7977+
:type star_count: :obj:`int`
7978+
7979+
:return: Returns True on success.
7980+
:rtype: :obj:`bool`
7981+
"""
7982+
return await asyncio_helper.transfer_business_account_stars(self.token, business_connection_id, star_count)
7983+
79667984

79677985
async def get_available_gifts(self) -> types.Gifts:
79687986
"""

telebot/asyncio_helper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,10 @@ async def get_business_account_star_balance(token, business_connection_id):
20142014
payload = {'business_connection_id': business_connection_id}
20152015
return _process_request(token, method_url, params=payload)
20162016

2017+
async def transfer_business_account_stars(token, business_connection_id, star_count):
2018+
method_url = 'transferBusinessAccountStars'
2019+
payload = {'business_connection_id': business_connection_id, 'star_count': star_count}
2020+
return await _process_request(token, method_url, params=payload, method='post')
20172021

20182022
async def get_available_gifts(token):
20192023
method_url = 'getAvailableGifts'

0 commit comments

Comments
 (0)