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
92 changes: 92 additions & 0 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6377,6 +6377,98 @@ def remove_chat_verification(self, chat_id: Union[int, str]) -> bool:
:rtype: :obj:`bool`
"""
return apihelper.remove_chat_verification(self.token, chat_id)

def read_business_message(self, business_connection_id: str, chat_id: Union[int, str], message_id: int) -> bool:
"""
Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success.

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

:param business_connection_id: Unique identifier of the business connection on behalf of which to read the message
:type business_connection_id: :obj:`str`

:param chat_id: Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours.
:type chat_id: :obj:`int` | :obj:`str`

:param message_id: Unique identifier of the message to mark as read
:type message_id: :obj:`int`

:return: Returns True on success.
:rtype: :obj:`bool`
"""
return apihelper.read_business_message(self.token, business_connection_id, chat_id, message_id)

def delete_business_messages(self, business_connection_id: str, message_ids: List[int]) -> bool:
"""
Delete messages on behalf of a business account. Requires the can_delete_outgoing_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success.

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

:param business_connection_id: Unique identifier of the business connection on behalf of which to delete the messages
:type business_connection_id: :obj:`str`

:param message_ids: A JSON-serialized list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted
:type message_ids: :obj:`list` of :obj:`int`

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

def set_business_account_name(self, business_connection_id: str, first_name: str, last_name: Optional[str]=None) -> bool:
"""
Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success.

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

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

:param first_name: The new value of the first name for the business account; 1-64 characters
:type first_name: :obj:`str`

:param last_name: The new value of the last name for the business account; 0-64 characters
:type last_name: :obj:`str`

:return: Returns True on success.
:rtype: :obj:`bool`
"""
return apihelper.set_business_account_name(self.token, business_connection_id, first_name, last_name)

def set_business_account_username(self, business_connection_id: str, username: Optional[str]=None) -> bool:
"""
Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success.

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

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

:param username: The new value of the username for the business account; 0-32 characters
:type username: :obj:`str`

:return: Returns True on success.
:rtype: :obj:`bool`

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

def set_business_account_bio(self, business_connection_id: str, bio: Optional[str]=None) -> bool:
"""
Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success.

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

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

:param bio: The new value of the bio for the business account; 0-140 characters
:type bio: :obj:`str`

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

def get_available_gifts(self) -> types.Gifts:
"""
Expand Down
33 changes: 33 additions & 0 deletions telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,39 @@ def remove_chat_verification(token, chat_id):
payload = {'chat_id': chat_id}
return _make_request(token, method_url, params=payload, method='post')


def read_business_message(token, business_connection_id, chat_id, message_id):
method_url = 'readBusinessMessage'
payload = {'business_connection_id': business_connection_id, 'chat_id': chat_id, 'message_id': message_id}
return _make_request(token, method_url, params=payload, method='post')


def delete_business_messages(token, business_connection_id, message_ids):
method_url = 'deleteBusinessMessages'
payload = {'business_connection_id': business_connection_id, 'message_ids': json.dumps(message_ids)}
return _make_request(token, method_url, params=payload, method='post')


def set_business_account_name(token, business_connection_id, first_name, last_name=None):
method_url = 'setBusinessAccountName'
payload = {'business_connection_id': business_connection_id, 'first_name': first_name}
if last_name:
payload['last_name'] = last_name
return _make_request(token, method_url, params=payload, method='post')


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


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


def set_sticker_emoji_list(token, sticker, emoji_list):
method_url = 'setStickerEmojiList'
payload = {'sticker': sticker, 'emoji_list': json.dumps(emoji_list)}
Expand Down
92 changes: 92 additions & 0 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7835,6 +7835,98 @@ async def remove_chat_verification(self, chat_id: Union[int, str]) -> bool:
"""
return await asyncio_helper.remove_chat_verification(self.token, chat_id)

async def read_business_message(self, business_connection_id: str, chat_id: Union[int, str], message_id: int) -> bool:
"""
Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success.

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

:param business_connection_id: Unique identifier of the business connection on behalf of which to read the message
:type business_connection_id: :obj:`str`

:param chat_id: Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours.
:type chat_id: :obj:`int` | :obj:`str`

:param message_id: Unique identifier of the message to mark as read
:type message_id: :obj:`int`

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

async def delete_business_messages(self, business_connection_id: str, message_ids: List[int]) -> bool:
"""
Delete messages on behalf of a business account. Requires the can_delete_outgoing_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success.

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

:param business_connection_id: Unique identifier of the business connection on behalf of which to delete the messages
:type business_connection_id: :obj:`str`

:param message_ids: A JSON-serialized list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted
:type message_ids: :obj:`list` of :obj:`int`

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

async def set_business_account_name(self, business_connection_id: str, first_name: str, last_name: Optional[str]=None) -> bool:
"""
Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success.

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

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

:param first_name: The new value of the first name for the business account; 1-64 characters
:type first_name: :obj:`str`

:param last_name: The new value of the last name for the business account; 0-64 characters
:type last_name: :obj:`str`

: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)

async def set_business_account_username(self, business_connection_id: str, username: Optional[str]=None) -> bool:
"""
Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success.

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

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

:param username: The new value of the username for the business account; 0-32 characters
:type username: :obj:`str`

:return: Returns True on success.
:rtype: :obj:`bool`

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

async def set_business_account_bio(self, business_connection_id: str, bio: Optional[str]=None) -> bool:
"""
Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success.

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

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

:param bio: The new value of the bio for the business account; 0-140 characters
:type bio: :obj:`str`

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

async 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
33 changes: 33 additions & 0 deletions telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,39 @@ async def remove_chat_verification(token, chat_id):
payload = {'chat_id': chat_id}
return await _process_request(token, method_url, params=payload, method='post')


async def read_business_message(token, business_connection_id, chat_id, message_id):
method_url = 'readBusinessMessage'
payload = {'business_connection_id': business_connection_id, 'chat_id': chat_id, 'message_id': message_id}
return await _process_request(token, method_url, params=payload, method='post')


async def delete_business_messages(token, business_connection_id, message_ids):
method_url = 'deleteBusinessMessages'
payload = {'business_connection_id': business_connection_id, 'message_ids': json.dumps(message_ids)}
return await _process_request(token, method_url, params=payload, method='post')


async def set_business_account_name(token, business_connection_id, first_name, last_name=None):
method_url = 'setBusinessAccountName'
payload = {'business_connection_id': business_connection_id, 'first_name': first_name}
if last_name:
payload['last_name'] = last_name
return await _process_request(token, method_url, params=payload, method='post')


async def set_business_account_username(token, business_connection_id, username):
method_url = 'setBusinessAccountUsername'
payload = {'business_connection_id': business_connection_id, 'username': username}
return await _process_request(token, method_url, params=payload, method='post')


async def set_business_account_bio(token, business_connection_id, bio):
method_url = 'setBusinessAccountBio'
payload = {'business_connection_id': business_connection_id, 'bio': bio}
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