1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Added the parameter message_thread_id to the method sendChatAction for sending chat actions to a specific message thread or a forum topic.

Added the parameter message_thread_id to the method sendChatAction for sending chat actions to a specific message thread or a forum topic.
This commit is contained in:
coder2020official 2022-12-30 20:23:53 +04:00
parent f297ad23c7
commit 9f8256607a
4 changed files with 16 additions and 6 deletions

View File

@ -2806,7 +2806,7 @@ class TeleBot:
allow_sending_without_reply, protect_content, message_thread_id)) allow_sending_without_reply, protect_content, message_thread_id))
def send_chat_action( def send_chat_action(
self, chat_id: Union[int, str], action: str, timeout: Optional[int]=None) -> bool: self, chat_id: Union[int, str], action: str, timeout: Optional[int]=None, message_thread_id: Optional[int]=None) -> bool:
""" """
Use this method when you need to tell the user that something is happening on the bot's side. Use this method when you need to tell the user that something is happening on the bot's side.
The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
@ -2829,10 +2829,13 @@ class TeleBot:
:param timeout: Timeout in seconds for the request. :param timeout: Timeout in seconds for the request.
:type timeout: :obj:`int` :type timeout: :obj:`int`
:param message_thread_id: The thread identifier of a message from which the reply will be sent(supergroups only)
:type message_thread_id: :obj:`int`
:return: Returns True on success. :return: Returns True on success.
:rtype: :obj:`bool` :rtype: :obj:`bool`
""" """
return apihelper.send_chat_action(self.token, chat_id, action, timeout) return apihelper.send_chat_action(self.token, chat_id, action, timeout, message_thread_id)
@util.deprecated(deprecation_text="Use ban_chat_member instead") @util.deprecated(deprecation_text="Use ban_chat_member instead")
def kick_chat_member( def kick_chat_member(

View File

@ -657,11 +657,13 @@ def send_contact(
return _make_request(token, method_url, params=payload) return _make_request(token, method_url, params=payload)
def send_chat_action(token, chat_id, action, timeout=None): def send_chat_action(token, chat_id, action, timeout=None, message_thread_id=None):
method_url = r'sendChatAction' method_url = r'sendChatAction'
payload = {'chat_id': chat_id, 'action': action} payload = {'chat_id': chat_id, 'action': action}
if timeout: if timeout:
payload['timeout'] = timeout payload['timeout'] = timeout
if message_thread_id is not None:
payload['message_thread_id'] = message_thread_id
return _make_request(token, method_url, params=payload) return _make_request(token, method_url, params=payload)

View File

@ -3664,7 +3664,7 @@ class AsyncTeleBot:
) )
async def send_chat_action( async def send_chat_action(
self, chat_id: Union[int, str], action: str, timeout: Optional[int]=None) -> bool: self, chat_id: Union[int, str], action: str, timeout: Optional[int]=None, message_thread_id: Optional[int]=None) -> bool:
""" """
Use this method when you need to tell the user that something is happening on the bot's side. Use this method when you need to tell the user that something is happening on the bot's side.
The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
@ -3687,10 +3687,13 @@ class AsyncTeleBot:
:param timeout: Timeout in seconds for the request. :param timeout: Timeout in seconds for the request.
:type timeout: :obj:`int` :type timeout: :obj:`int`
:param message_thread_id: The thread to which the message will be sent(supergroups only)
:type message_thread_id: :obj:`int`
:return: Returns True on success. :return: Returns True on success.
:rtype: :obj:`bool` :rtype: :obj:`bool`
""" """
return await asyncio_helper.send_chat_action(self.token, chat_id, action, timeout) return await asyncio_helper.send_chat_action(self.token, chat_id, action, timeout, message_thread_id)
async def kick_chat_member( async def kick_chat_member(
self, chat_id: Union[int, str], user_id: int, self, chat_id: Union[int, str], user_id: int,

View File

@ -649,11 +649,13 @@ async def send_contact(
return await _process_request(token, method_url, params=payload) return await _process_request(token, method_url, params=payload)
async def send_chat_action(token, chat_id, action, timeout=None): async def send_chat_action(token, chat_id, action, timeout=None, message_thread_id=None):
method_url = r'sendChatAction' method_url = r'sendChatAction'
payload = {'chat_id': chat_id, 'action': action} payload = {'chat_id': chat_id, 'action': action}
if timeout: if timeout:
payload['timeout'] = timeout payload['timeout'] = timeout
if message_thread_id:
payload['message_thread_id'] = message_thread_id
return await _process_request(token, method_url, params=payload) return await _process_request(token, method_url, params=payload)