-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bot API 10.1 #2600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bot API 10.1 #2600
Changes from all commits
6a9cc22
30395b6
917068b
6763a71
f8bf0a5
5e319fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5659,7 +5659,8 @@ def edit_message_text( | |
| reply_markup: Optional[types.InlineKeyboardMarkup]=None, | ||
| link_preview_options : Optional[types.LinkPreviewOptions]=None, | ||
| business_connection_id: Optional[str]=None, | ||
| timeout: Optional[int]=None) -> Union[types.Message, bool]: | ||
| timeout: Optional[int]=None, | ||
| rich_message: Optional[types.InputRichMessage]=None) -> Union[types.Message, bool]: | ||
| """ | ||
| Use this method to edit text and game messages. | ||
|
|
||
|
|
@@ -5725,7 +5726,7 @@ def edit_message_text( | |
| result = apihelper.edit_message_text( | ||
| self.token, text, chat_id=chat_id, message_id=message_id, inline_message_id=inline_message_id, | ||
| parse_mode=parse_mode, entities=entities, reply_markup=reply_markup, link_preview_options=link_preview_options, | ||
| business_connection_id=business_connection_id, timeout=timeout) | ||
| business_connection_id=business_connection_id, timeout=timeout, rich_message=rich_message) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer to have valuable fields before timeout. |
||
|
|
||
| if isinstance(result, bool): # if edit inline message return is bool not Message. | ||
| return result | ||
|
|
@@ -6909,7 +6910,7 @@ def answer_guest_query(self, guest_query_id: str, result: types.InlineQueryResul | |
|
|
||
| :param result: A JSON-serialized object describing the message to be sent | ||
| :type result: :obj:`types.InlineQueryResult` | ||
|
|
||
| :return: On success, a SentGuestMessage object is returned. | ||
| :rtype: :obj:`types.SentGuestMessage` | ||
| """ | ||
|
|
@@ -6918,6 +6919,128 @@ def answer_guest_query(self, guest_query_id: str, result: types.InlineQueryResul | |
| ) | ||
|
|
||
|
|
||
| def send_rich_message( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed lot of parameters from API. |
||
| self, chat_id: Union[int, str], | ||
| rich_message: types.InputRichMessage, | ||
| message_thread_id: Optional[int]=None, | ||
| reply_markup: Optional[types.InlineKeyboardMarkup]=None, | ||
| disable_notification: Optional[bool]=None, | ||
| protect_content: Optional[bool]=None, | ||
| reply_parameters: Optional[types.ReplyParameters]=None, | ||
| business_connection_id: Optional[str]=None) -> types.Message: | ||
| """ | ||
| Use this method to send a rich formatted message. On success, the sent Message is returned. | ||
|
|
||
| Telegram documentation: https://core.telegram.org/bots/api#sendrichmessage | ||
|
|
||
| :param chat_id: Unique identifier for the target chat or username of the target channel | ||
| :type chat_id: :obj:`int` or :obj:`str` | ||
|
|
||
| :param rich_message: A JSON-serialized object for the rich message content | ||
| :type rich_message: :class:`telebot.types.InputRichMessage` | ||
|
|
||
| :param message_thread_id: Unique identifier for the target message thread | ||
| :type message_thread_id: :obj:`int` | ||
|
|
||
| :param reply_markup: Additional interface options | ||
| :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` | ||
|
|
||
| :param disable_notification: Sends the message silently | ||
| :type disable_notification: :obj:`bool` | ||
|
|
||
| :param protect_content: Protects the contents of the sent message from forwarding and saving | ||
| :type protect_content: :obj:`bool` | ||
|
|
||
| :param reply_parameters: Description of the message to reply to | ||
| :type reply_parameters: :class:`telebot.types.ReplyParameters` | ||
|
|
||
| :param business_connection_id: Unique identifier of the business connection | ||
| :type business_connection_id: :obj:`str` | ||
|
|
||
| :return: On success, the sent Message is returned. | ||
| :rtype: :class:`telebot.types.Message` | ||
| """ | ||
| return types.Message.de_json( | ||
| apihelper.send_rich_message( | ||
| self.token, chat_id, rich_message, | ||
| message_thread_id=message_thread_id, | ||
| reply_markup=reply_markup, | ||
| disable_notification=disable_notification, | ||
| protect_content=protect_content, | ||
| reply_parameters=reply_parameters, | ||
| business_connection_id=business_connection_id)) | ||
|
|
||
|
|
||
| def send_rich_message_draft( | ||
| self, chat_id: int, | ||
| draft_id: int, | ||
| rich_message: types.InputRichMessage, | ||
| message_thread_id: Optional[int]=None) -> bool: | ||
| """ | ||
| Use this method to stream a partial rich message to a user while the message is being generated. | ||
| Returns True on success. | ||
|
|
||
| Telegram documentation: https://core.telegram.org/bots/api#sendrichmessagedraft | ||
|
|
||
| :param chat_id: Unique identifier for the target private chat | ||
| :type chat_id: :obj:`int` | ||
|
|
||
| :param draft_id: Unique identifier of the message draft; must be non-zero | ||
| :type draft_id: :obj:`int` | ||
|
|
||
| :param rich_message: A JSON-serialized object for the rich message draft content | ||
| :type rich_message: :class:`telebot.types.InputRichMessage` | ||
|
|
||
| :param message_thread_id: Unique identifier for the target message thread | ||
| :type message_thread_id: :obj:`int` | ||
|
|
||
| :return: Returns True on success. | ||
| :rtype: :obj:`bool` | ||
| """ | ||
| return apihelper.send_rich_message_draft( | ||
| self.token, chat_id, draft_id, rich_message, message_thread_id=message_thread_id) | ||
|
|
||
|
|
||
| def answer_chat_join_request_query( | ||
| self, query_id: str, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. chat_join_request_query_id, not query_id |
||
| result: types.InlineQueryResultBase) -> bool: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. result is string |
||
| """ | ||
| Use this method to handle a join request query with a custom response. Returns True on success. | ||
|
|
||
| Telegram documentation: https://core.telegram.org/bots/api#answerchatjoinrequestquery | ||
|
|
||
| :param query_id: Unique identifier of the join request query | ||
| :type query_id: :obj:`str` | ||
|
|
||
| :param result: A JSON-serialized object describing the response to send | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. result is string |
||
| :type result: :class:`telebot.types.InlineQueryResultBase` | ||
|
|
||
| :return: Returns True on success. | ||
| :rtype: :obj:`bool` | ||
| """ | ||
| return apihelper.answer_chat_join_request_query(self.token, query_id, result) | ||
|
|
||
|
|
||
| def send_chat_join_request_web_app( | ||
| self, query_id: str, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. chat_join_request_query_id, not query_id |
||
| web_app_url: str) -> bool: | ||
| """ | ||
| Use this method to trigger a Web App in response to a join request query. Returns True on success. | ||
|
|
||
| Telegram documentation: https://core.telegram.org/bots/api#sendchatjoinrequestwebapp | ||
|
|
||
| :param query_id: Unique identifier of the join request query | ||
| :type query_id: :obj:`str` | ||
|
|
||
| :param web_app_url: URL of the Web App to be opened | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The URL... |
||
| :type web_app_url: :obj:`str` | ||
|
|
||
| :return: Returns True on success. | ||
| :rtype: :obj:`bool` | ||
| """ | ||
| return apihelper.send_chat_join_request_web_app(self.token, query_id, web_app_url) | ||
|
|
||
|
|
||
| def get_user_chat_boosts(self, chat_id: Union[int, str], user_id: int) -> types.UserChatBoosts: | ||
| """ | ||
| Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1737,7 +1737,7 @@ def unpin_all_chat_messages(token, chat_id): | |
|
|
||
| def edit_message_text( | ||
| token, text, chat_id=None, message_id=None, inline_message_id=None, parse_mode=None, entities = None, | ||
| reply_markup=None, link_preview_options=None, business_connection_id=None, timeout=None): | ||
| reply_markup=None, link_preview_options=None, business_connection_id=None, timeout=None, rich_message=None): | ||
| method_url = r'editMessageText' | ||
| payload = {'text': text} | ||
| if chat_id: | ||
|
|
@@ -1758,6 +1758,8 @@ def edit_message_text( | |
| payload['business_connection_id'] = business_connection_id | ||
| if timeout: | ||
| payload['timeout'] = timeout | ||
| if rich_message is not None: | ||
| payload['rich_message'] = rich_message.to_json() | ||
| return _make_request(token, method_url, params=payload, method='post') | ||
|
|
||
|
|
||
|
|
@@ -2136,6 +2138,47 @@ def answer_guest_query(token, guest_query_id, result): | |
| payload = {'guest_query_id': guest_query_id, 'result': result.to_json()} | ||
| return _make_request(token, method_url, params=payload, method='post') | ||
|
|
||
|
|
||
| def send_rich_message(token, chat_id, rich_message, message_thread_id=None, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed lot of parameters. |
||
| reply_markup=None, disable_notification=None, protect_content=None, | ||
| reply_parameters=None, business_connection_id=None): | ||
| method_url = 'sendRichMessage' | ||
| payload = {'chat_id': chat_id, 'rich_message': rich_message.to_json()} | ||
| if message_thread_id is not None: | ||
| payload['message_thread_id'] = message_thread_id | ||
| if reply_markup: | ||
| payload['reply_markup'] = _convert_markup(reply_markup) | ||
| if disable_notification is not None: | ||
| payload['disable_notification'] = disable_notification | ||
| if protect_content is not None: | ||
| payload['protect_content'] = protect_content | ||
| if reply_parameters is not None: | ||
| payload['reply_parameters'] = reply_parameters.to_json() | ||
| if business_connection_id: | ||
| payload['business_connection_id'] = business_connection_id | ||
| return _make_request(token, method_url, params=payload, method='post') | ||
|
|
||
|
|
||
| def send_rich_message_draft(token, chat_id, draft_id, rich_message, message_thread_id=None): | ||
| method_url = 'sendRichMessageDraft' | ||
| payload = {'chat_id': chat_id, 'draft_id': draft_id, 'rich_message': rich_message.to_json()} | ||
| if message_thread_id is not None: | ||
| payload['message_thread_id'] = message_thread_id | ||
| return _make_request(token, method_url, params=payload, method='post') | ||
|
|
||
|
|
||
| def answer_chat_join_request_query(token, query_id, result): | ||
| method_url = 'answerChatJoinRequestQuery' | ||
| payload = {'query_id': query_id, 'result': result.to_json()} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. chat_join_request_query_id, not query_id result is string, no to_json |
||
| return _make_request(token, method_url, params=payload, method='post') | ||
|
|
||
|
|
||
| def send_chat_join_request_web_app(token, query_id, web_app_url): | ||
| method_url = 'sendChatJoinRequestWebApp' | ||
| payload = {'query_id': query_id, 'web_app_url': web_app_url} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. chat_join_request_query_id, not query_id |
||
| return _make_request(token, method_url, params=payload, method='post') | ||
|
|
||
|
|
||
| def get_user_chat_boosts(token, chat_id, user_id): | ||
| method_url = 'getUserChatBoosts' | ||
| payload = {'chat_id': chat_id, 'user_id': user_id} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer to have valuable fields before timeout.