Bot API 10.1#2600
Conversation
…inks) New types: RichText (25 inline subtypes), RichBlock (24 block subtypes), RichMessage, InputRichMessage, InputRichMessageContent, Link, InputMediaLink. New methods: sendRichMessage, sendRichMessageDraft, answerChatJoinRequestQuery, sendChatJoinRequestWebApp. All methods added to sync/async TeleBot and helpers. Field additions: User.supports_join_request_queries, ChatFullInfo.guard_bot, ChatJoinRequest.query_id, Message.rich_message, PollMedia.link. Bumps version to 4.35.0.
check_json only shallow-copies, so nested Subclass._from_dict(shared_dict) calls mutated the caller's dict in place (RichBlockList, RichBlockTable, and all media/collage/slideshow/map blocks with nested captions/items/cells). Route nested conversions through RichBlock.de_json, which copies first and dispatches correctly via the type map. Also allow InputMediaLink as InputPollOptionMedia per the Bot API 10.1 spec.
InputRichMessage takes html/markdown/is_rtl/skip_entity_detection strings, not page_blocks. RichMessage uses 'blocks' (not 'page_blocks') and adds is_rtl.
Receive-side block classes were off-spec: - Type strings: block_quotation->blockquote, pull_quotation->pullquote, preformatted->pre, section_heading->heading (de_json dispatch + TYPE_MAP) - Field renames: page_blocks->blocks (ListItem, Collage, Slideshow, Details) - RichBlockListItem: label is a String (not RichText); add has_checkbox, is_checked, value - RichBlockSectionHeading: level->size - RichBlockBlockQuotation: text->blocks (Array of RichBlock), caption->credit - RichBlockDetails: header->summary - RichBlockList: drop is_ordered (not in spec)
Addresses review feedback on PR #2600: the 25 RichText* and 24 RichBlock* subclasses used condensed one-line docstrings, unlike the rest of the library. Rewrite them in the project's reStructuredText format with a description, Telegram documentation link, per-parameter :param:/:type:, and :return:/:rtype:, matching the base classes. Docs-only; no logic changes.
| 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, |
There was a problem hiding this comment.
Prefer to have valuable fields before timeout.
| 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) |
There was a problem hiding this comment.
Prefer to have valuable fields before timeout.
| ) | ||
|
|
||
|
|
||
| def send_rich_message( |
There was a problem hiding this comment.
Missed lot of parameters from API.
| return _make_request(token, method_url, params=payload, method='post') | ||
|
|
||
|
|
||
| def send_rich_message(token, chat_id, rich_message, message_thread_id=None, |
There was a problem hiding this comment.
Missed lot of parameters.
|
|
||
|
|
||
| def answer_chat_join_request_query( | ||
| self, query_id: str, |
There was a problem hiding this comment.
chat_join_request_query_id, not query_id
|
|
||
| def answer_chat_join_request_query( | ||
| self, query_id: str, | ||
| result: types.InlineQueryResultBase) -> bool: |
| :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 |
| :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 |
|
|
||
| def answer_chat_join_request_query(token, query_id, result): | ||
| method_url = 'answerChatJoinRequestQuery' | ||
| payload = {'query_id': query_id, 'result': result.to_json()} |
There was a problem hiding this comment.
chat_join_request_query_id, not query_id
result is string, no to_json
|
|
||
| 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} |
There was a problem hiding this comment.
chat_join_request_query_id, not query_id
|
@coder2020official Poor quality, not sure it's reasonable to porceed with this PR. There are 50 classes added, it's hard to review every field there... |
|
Understood, I will work on a PR tomorrow |
Bot API 10.1
Rich Messages
RichTextBold,RichTextItalic,RichTextUnderline,RichTextStrikethrough,RichTextSpoiler,RichTextDateTime,RichTextTextMention,RichTextSubscript,RichTextSuperscript,RichTextMarked,RichTextCode,RichTextCustomEmoji,RichTextMathematicalExpression,RichTextUrl,RichTextEmailAddress,RichTextPhoneNumber,RichTextBankCardNumber,RichTextMention,RichTextHashtag,RichTextCashtag,RichTextBotCommand,RichTextAnchor,RichTextAnchorLink,RichTextReferenceandRichTextReferenceLink, which represent different types of rich formatted text.RichText, which represents rich formatted text.RichBlockCaption, which represents the caption of a rich formatted text.RichBlockTableCell, which represents a cell in a table.RichBlockListItem, which represents an item in a list.RichBlockParagraph,RichBlockSectionHeading,RichBlockPreformatted,RichBlockFooter,RichBlockDivider,RichBlockMathematicalExpression,RichBlockAnchor,RichBlockList,RichBlockBlockQuotation,RichBlockPullQuotation,RichBlockCollage,RichBlockSlideshow,RichBlockTable,RichBlockDetails,RichBlockMap,RichBlockAnimation,RichBlockAudio,RichBlockPhoto,RichBlockVideo,RichBlockVoiceNoteandRichBlockThinking, which represent different types of blocks in a rich formatted message.RichBlock, which represents a block in a rich formatted message.RichMessage, which represents a rich formatted message.rich_messageto the classMessage.InputRichMessage, describing a rich message to send.InputRichMessageContentand allowed it to be used asInputMessageContentin results of inline, guest, and Web App queries.sendRichMessage, allowing bots to send rich messages.sendRichMessageDraft, allowing bots to stream partial rich messages.rich_messageto the methodeditMessageText, allowing bots to edit rich messages.Join Request Queries
supports_join_request_queriesto the classUser.guard_botto the classChatFullInfo.query_idto the classChatJoinRequest.answerChatJoinRequestQuery.sendChatJoinRequestWebApp.Polls
Linkand the fieldlinkto the classPollMedia.InputMediaLinkand allowed it to be used asInputPollOptionMedia.