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
14 changes: 7 additions & 7 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6364,7 +6364,7 @@ def remove_user_verification(self, user_id: int) -> bool:

return apihelper.remove_user_verification(self.token, user_id)

def remove_chat_verification(self, chat_id: Union[int, str]) -> bool:
def remove_chat_verification(self, chat_id: int) -> bool:
"""
Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success.

Expand Down Expand Up @@ -6433,7 +6433,7 @@ def set_business_account_name(self, business_connection_id: str, first_name: str
:return: Returns True on success.
:rtype: :obj:`bool`
"""
return apihelper.set_business_account_name(self.token, business_connection_id, first_name, last_name)
return apihelper.set_business_account_name(self.token, business_connection_id, first_name, last_name=last_name)

def set_business_account_username(self, business_connection_id: str, username: Optional[str]=None) -> bool:
"""
Expand All @@ -6451,7 +6451,7 @@ def set_business_account_username(self, business_connection_id: str, username: O
:rtype: :obj:`bool`

"""
return apihelper.set_business_account_username(self.token, business_connection_id, username)
return apihelper.set_business_account_username(self.token, business_connection_id, username=username)

def set_business_account_bio(self, business_connection_id: str, bio: Optional[str]=None) -> bool:
"""
Expand All @@ -6468,7 +6468,7 @@ def set_business_account_bio(self, business_connection_id: str, bio: Optional[st
:return: Returns True on success.
:rtype: :obj:`bool`
"""
return apihelper.set_business_account_bio(self.token, business_connection_id, bio)
return apihelper.set_business_account_bio(self.token, business_connection_id, bio=bio)

def set_business_account_gift_settings(
self, business_connection_id: str, show_gift_button: bool, accepted_gift_types: types.AcceptedGiftTypes) -> bool:
Expand Down Expand Up @@ -6635,7 +6635,7 @@ def upgrade_gift(

def transfer_gift(
self, business_connection_id: str, owned_gift_id: str,
new_owner_chat_id: Union[int, str],
new_owner_chat_id: int,
star_count: Optional[int]=None) -> bool:
"""
Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right.
Expand All @@ -6650,7 +6650,7 @@ def transfer_gift(
:type owned_gift_id: :obj:`str`

:param new_owner_chat_id: Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours.
:type new_owner_chat_id: :obj:`int` | :obj:`str`
:type new_owner_chat_id: :obj:`int`

:param star_count: The amount of Telegram Stars that will be paid for the transfer from the business account balance.
If positive, then the can_transfer_stars business bot right is required.
Expand All @@ -6661,7 +6661,7 @@ def transfer_gift(
"""
return apihelper.transfer_gift(
self.token, business_connection_id, owned_gift_id,
new_owner_chat_id=new_owner_chat_id,
new_owner_chat_id,
star_count=star_count
)

Expand Down
15 changes: 10 additions & 5 deletions telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2013,21 +2013,26 @@ def set_business_account_name(token, business_connection_id, first_name, last_na
return _make_request(token, method_url, params=payload, method='post')


def set_business_account_username(token, business_connection_id, username):
def set_business_account_username(token, business_connection_id, username=None):
method_url = 'setBusinessAccountUsername'
payload = {'business_connection_id': business_connection_id, 'username': username}
payload = {'business_connection_id': business_connection_id}
if username:
payload['username'] = username
return _make_request(token, method_url, params=payload, method='post')


def set_business_account_bio(token, business_connection_id, bio):
def set_business_account_bio(token, business_connection_id, bio=None):
method_url = 'setBusinessAccountBio'
payload = {'business_connection_id': business_connection_id, 'bio': bio}
payload = {'business_connection_id': business_connection_id}
if bio:
payload['bio'] = bio
return _make_request(token, method_url, params=payload, method='post')


def set_business_account_gift_settings(token, business_connection_id, show_gift_button, accepted_gift_types):
method_url = 'setBusinessAccountGiftSettings'
payload = {'business_connection_id': business_connection_id, 'show_gift_button': show_gift_button, 'accepted_gift_types': json.dumps(accepted_gift_types)}
payload = {'business_connection_id': business_connection_id, 'show_gift_button': show_gift_button,
'accepted_gift_types': accepted_gift_types.to_json()}
return _make_request(token, method_url, params=payload, method='post')

def set_sticker_emoji_list(token, sticker, emoji_list):
Expand Down
14 changes: 7 additions & 7 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7821,7 +7821,7 @@ async def remove_user_verification(self, user_id: int) -> bool:
"""
return await asyncio_helper.remove_user_verification(self.token, user_id)

async def remove_chat_verification(self, chat_id: Union[int, str]) -> bool:
async def remove_chat_verification(self, chat_id: int) -> bool:
"""
Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success.

Expand Down Expand Up @@ -7890,7 +7890,7 @@ async def set_business_account_name(self, business_connection_id: str, first_nam
:return: Returns True on success.
:rtype: :obj:`bool`
"""
return await asyncio_helper.set_business_account_name(self.token, business_connection_id, first_name, last_name)
return await asyncio_helper.set_business_account_name(self.token, business_connection_id, first_name, last_name=last_name)

async def set_business_account_username(self, business_connection_id: str, username: Optional[str]=None) -> bool:
"""
Expand All @@ -7908,7 +7908,7 @@ async def set_business_account_username(self, business_connection_id: str, usern
:rtype: :obj:`bool`

"""
return await asyncio_helper.set_business_account_username(self.token, business_connection_id, username)
return await asyncio_helper.set_business_account_username(self.token, business_connection_id, username=username)

async def set_business_account_bio(self, business_connection_id: str, bio: Optional[str]=None) -> bool:
"""
Expand All @@ -7925,7 +7925,7 @@ async def set_business_account_bio(self, business_connection_id: str, bio: Optio
:return: Returns True on success.
:rtype: :obj:`bool`
"""
return await asyncio_helper.set_business_account_bio(self.token, business_connection_id, bio)
return await asyncio_helper.set_business_account_bio(self.token, business_connection_id, bio=bio)

async def set_business_account_gift_settings(
self, business_connection_id: str, show_gift_button: bool, accepted_gift_types: types.AcceptedGiftTypes) -> bool:
Expand Down Expand Up @@ -8091,7 +8091,7 @@ async def upgrade_gift(

async def transfer_gift(
self, business_connection_id: str, owned_gift_id: str,
new_owner_chat_id: Union[int, str],
new_owner_chat_id: int,
star_count: Optional[int]=None) -> bool:
"""
Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right.
Expand All @@ -8106,7 +8106,7 @@ async def transfer_gift(
:type owned_gift_id: :obj:`str`

:param new_owner_chat_id: Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours.
:type new_owner_chat_id: :obj:`int` | :obj:`str`
:type new_owner_chat_id: :obj:`int`

:param star_count: The amount of Telegram Stars that will be paid for the transfer from the business account balance.
If positive, then the can_transfer_stars business bot right is required.
Expand All @@ -8117,7 +8117,7 @@ async def transfer_gift(
"""
return await asyncio_helper.transfer_gift(
self.token, business_connection_id, owned_gift_id,
new_owner_chat_id=new_owner_chat_id,
new_owner_chat_id,
star_count=star_count
)

Expand Down
14 changes: 9 additions & 5 deletions telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1993,20 +1993,24 @@ async def set_business_account_name(token, business_connection_id, first_name, l
return await _process_request(token, method_url, params=payload, method='post')


async def set_business_account_username(token, business_connection_id, username):
async def set_business_account_username(token, business_connection_id, username=None):
method_url = 'setBusinessAccountUsername'
payload = {'business_connection_id': business_connection_id, 'username': username}
payload = {'business_connection_id': business_connection_id}
if username is not None:
payload['username'] = username
return await _process_request(token, method_url, params=payload, method='post')


async def set_business_account_bio(token, business_connection_id, bio):
async def set_business_account_bio(token, business_connection_id, bio=None):
method_url = 'setBusinessAccountBio'
payload = {'business_connection_id': business_connection_id, 'bio': bio}
payload = {'business_connection_id': business_connection_id}
if bio:
payload['bio'] = bio
return await _process_request(token, method_url, params=payload, method='post')

async def set_business_account_gift_settings(token, business_connection_id, show_gift_button, accepted_gift_types):
method_url = 'setBusinessAccountGiftSettings'
payload = {'business_connection_id': business_connection_id, 'show_gift_button': show_gift_button, 'accepted_gift_types': json.dumps(accepted_gift_types)}
payload = {'business_connection_id': business_connection_id, 'show_gift_button': show_gift_button, 'accepted_gift_types': accepted_gift_types.to_json()}
return await _process_request(token, method_url, params=payload, method='post')

async def get_business_account_star_balance(token, business_connection_id):
Expand Down
Loading