Skip to content

Commit 533b52c

Browse files
Fix issues related with Bot api 9.0
1 parent 49684b5 commit 533b52c

File tree

5 files changed

+91
-62
lines changed

5 files changed

+91
-62
lines changed

telebot/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6364,7 +6364,7 @@ def remove_user_verification(self, user_id: int) -> bool:
63646364

63656365
return apihelper.remove_user_verification(self.token, user_id)
63666366

6367-
def remove_chat_verification(self, chat_id: Union[int, str]) -> bool:
6367+
def remove_chat_verification(self, chat_id: int) -> bool:
63686368
"""
63696369
Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success.
63706370
@@ -6433,7 +6433,7 @@ def set_business_account_name(self, business_connection_id: str, first_name: str
64336433
:return: Returns True on success.
64346434
:rtype: :obj:`bool`
64356435
"""
6436-
return apihelper.set_business_account_name(self.token, business_connection_id, first_name, last_name)
6436+
return apihelper.set_business_account_name(self.token, business_connection_id, first_name, last_name=last_name)
64376437

64386438
def set_business_account_username(self, business_connection_id: str, username: Optional[str]=None) -> bool:
64396439
"""
@@ -6451,7 +6451,7 @@ def set_business_account_username(self, business_connection_id: str, username: O
64516451
:rtype: :obj:`bool`
64526452
64536453
"""
6454-
return apihelper.set_business_account_username(self.token, business_connection_id, username)
6454+
return apihelper.set_business_account_username(self.token, business_connection_id, username=username)
64556455

64566456
def set_business_account_bio(self, business_connection_id: str, bio: Optional[str]=None) -> bool:
64576457
"""
@@ -6468,7 +6468,7 @@ def set_business_account_bio(self, business_connection_id: str, bio: Optional[st
64686468
:return: Returns True on success.
64696469
:rtype: :obj:`bool`
64706470
"""
6471-
return apihelper.set_business_account_bio(self.token, business_connection_id, bio)
6471+
return apihelper.set_business_account_bio(self.token, business_connection_id, bio=bio)
64726472

64736473
def set_business_account_gift_settings(
64746474
self, business_connection_id: str, show_gift_button: bool, accepted_gift_types: types.AcceptedGiftTypes) -> bool:
@@ -6635,7 +6635,7 @@ def upgrade_gift(
66356635

66366636
def transfer_gift(
66376637
self, business_connection_id: str, owned_gift_id: str,
6638-
new_owner_chat_id: Union[int, str],
6638+
new_owner_chat_id: int,
66396639
star_count: Optional[int]=None) -> bool:
66406640
"""
66416641
Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right.
@@ -6650,7 +6650,7 @@ def transfer_gift(
66506650
:type owned_gift_id: :obj:`str`
66516651
66526652
: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.
6653-
:type new_owner_chat_id: :obj:`int` | :obj:`str`
6653+
:type new_owner_chat_id: :obj:`int`
66546654
66556655
:param star_count: The amount of Telegram Stars that will be paid for the transfer from the business account balance.
66566656
If positive, then the can_transfer_stars business bot right is required.
@@ -6661,7 +6661,7 @@ def transfer_gift(
66616661
"""
66626662
return apihelper.transfer_gift(
66636663
self.token, business_connection_id, owned_gift_id,
6664-
new_owner_chat_id=new_owner_chat_id,
6664+
new_owner_chat_id,
66656665
star_count=star_count
66666666
)
66676667

telebot/apihelper.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,21 +2013,26 @@ def set_business_account_name(token, business_connection_id, first_name, last_na
20132013
return _make_request(token, method_url, params=payload, method='post')
20142014

20152015

2016-
def set_business_account_username(token, business_connection_id, username):
2016+
def set_business_account_username(token, business_connection_id, username=None):
20172017
method_url = 'setBusinessAccountUsername'
2018-
payload = {'business_connection_id': business_connection_id, 'username': username}
2018+
payload = {'business_connection_id': business_connection_id}
2019+
if username:
2020+
payload['username'] = username
20192021
return _make_request(token, method_url, params=payload, method='post')
20202022

20212023

2022-
def set_business_account_bio(token, business_connection_id, bio):
2024+
def set_business_account_bio(token, business_connection_id, bio=None):
20232025
method_url = 'setBusinessAccountBio'
2024-
payload = {'business_connection_id': business_connection_id, 'bio': bio}
2026+
payload = {'business_connection_id': business_connection_id}
2027+
if bio:
2028+
payload['bio'] = bio
20252029
return _make_request(token, method_url, params=payload, method='post')
20262030

20272031

20282032
def set_business_account_gift_settings(token, business_connection_id, show_gift_button, accepted_gift_types):
20292033
method_url = 'setBusinessAccountGiftSettings'
2030-
payload = {'business_connection_id': business_connection_id, 'show_gift_button': show_gift_button, 'accepted_gift_types': json.dumps(accepted_gift_types)}
2034+
payload = {'business_connection_id': business_connection_id, 'show_gift_button': show_gift_button,
2035+
'accepted_gift_types': accepted_gift_types.to_json()}
20312036
return _make_request(token, method_url, params=payload, method='post')
20322037

20332038
def set_sticker_emoji_list(token, sticker, emoji_list):

telebot/async_telebot.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7821,7 +7821,7 @@ async def remove_user_verification(self, user_id: int) -> bool:
78217821
"""
78227822
return await asyncio_helper.remove_user_verification(self.token, user_id)
78237823

7824-
async def remove_chat_verification(self, chat_id: Union[int, str]) -> bool:
7824+
async def remove_chat_verification(self, chat_id: int) -> bool:
78257825
"""
78267826
Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success.
78277827
@@ -7890,7 +7890,7 @@ async def set_business_account_name(self, business_connection_id: str, first_nam
78907890
:return: Returns True on success.
78917891
:rtype: :obj:`bool`
78927892
"""
7893-
return await asyncio_helper.set_business_account_name(self.token, business_connection_id, first_name, last_name)
7893+
return await asyncio_helper.set_business_account_name(self.token, business_connection_id, first_name, last_name=last_name)
78947894

78957895
async def set_business_account_username(self, business_connection_id: str, username: Optional[str]=None) -> bool:
78967896
"""
@@ -7908,7 +7908,7 @@ async def set_business_account_username(self, business_connection_id: str, usern
79087908
:rtype: :obj:`bool`
79097909
79107910
"""
7911-
return await asyncio_helper.set_business_account_username(self.token, business_connection_id, username)
7911+
return await asyncio_helper.set_business_account_username(self.token, business_connection_id, username=username)
79127912

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

79307930
async def set_business_account_gift_settings(
79317931
self, business_connection_id: str, show_gift_button: bool, accepted_gift_types: types.AcceptedGiftTypes) -> bool:
@@ -8091,7 +8091,7 @@ async def upgrade_gift(
80918091

80928092
async def transfer_gift(
80938093
self, business_connection_id: str, owned_gift_id: str,
8094-
new_owner_chat_id: Union[int, str],
8094+
new_owner_chat_id: int,
80958095
star_count: Optional[int]=None) -> bool:
80968096
"""
80978097
Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right.
@@ -8106,7 +8106,7 @@ async def transfer_gift(
81068106
:type owned_gift_id: :obj:`str`
81078107
81088108
: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.
8109-
:type new_owner_chat_id: :obj:`int` | :obj:`str`
8109+
:type new_owner_chat_id: :obj:`int`
81108110
81118111
:param star_count: The amount of Telegram Stars that will be paid for the transfer from the business account balance.
81128112
If positive, then the can_transfer_stars business bot right is required.
@@ -8117,7 +8117,7 @@ async def transfer_gift(
81178117
"""
81188118
return await asyncio_helper.transfer_gift(
81198119
self.token, business_connection_id, owned_gift_id,
8120-
new_owner_chat_id=new_owner_chat_id,
8120+
new_owner_chat_id,
81218121
star_count=star_count
81228122
)
81238123

telebot/asyncio_helper.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,20 +1993,24 @@ async def set_business_account_name(token, business_connection_id, first_name, l
19931993
return await _process_request(token, method_url, params=payload, method='post')
19941994

19951995

1996-
async def set_business_account_username(token, business_connection_id, username):
1996+
async def set_business_account_username(token, business_connection_id, username=None):
19971997
method_url = 'setBusinessAccountUsername'
1998-
payload = {'business_connection_id': business_connection_id, 'username': username}
1998+
payload = {'business_connection_id': business_connection_id}
1999+
if username is not None:
2000+
payload['username'] = username
19992001
return await _process_request(token, method_url, params=payload, method='post')
20002002

20012003

2002-
async def set_business_account_bio(token, business_connection_id, bio):
2004+
async def set_business_account_bio(token, business_connection_id, bio=None):
20032005
method_url = 'setBusinessAccountBio'
2004-
payload = {'business_connection_id': business_connection_id, 'bio': bio}
2006+
payload = {'business_connection_id': business_connection_id}
2007+
if bio:
2008+
payload['bio'] = bio
20052009
return await _process_request(token, method_url, params=payload, method='post')
20062010

20072011
async def set_business_account_gift_settings(token, business_connection_id, show_gift_button, accepted_gift_types):
20082012
method_url = 'setBusinessAccountGiftSettings'
2009-
payload = {'business_connection_id': business_connection_id, 'show_gift_button': show_gift_button, 'accepted_gift_types': json.dumps(accepted_gift_types)}
2013+
payload = {'business_connection_id': business_connection_id, 'show_gift_button': show_gift_button, 'accepted_gift_types': accepted_gift_types.to_json()}
20102014
return await _process_request(token, method_url, params=payload, method='post')
20112015

20122016
async def get_business_account_star_balance(token, business_connection_id):

0 commit comments

Comments
 (0)