Added RichBlock (half) and RichText stuff#2602
Conversation
|
Added RichText stuff and half of RichBlock classes This could've been more simplified (e.g. by having text in the init of the base class), but I chose not to display and confuse people for some classes that don't have the text attribute, for example. Long way to go, I hope I'm on the right way |
|
@Badiboy I think I'm done, but I will double-check & test things tomorrow; you can, however, start reviewing the code |
Thank you for your work!! I do not think I can do it before weekend, but I'll do my best. |
|
@coder2020official Tried the 1. Async
await asyncio_helper.send_rich_message(
self.token, chat_id, rich_message,
business_connection_id=..., message_thread_id=message_thread_id,
direct_messages_topic_id=..., ...)but (The sync 2. Parsing the response crashes on plain-string rich text After working around (1), Per the docs, Minimal repro (async): |
|
Hi! Thanks for noting that--I have fixed your issue exactly; however, I am yet to address RichText being an array of RichText. I will have to test and see how it will look like. And I'm not sure my current implementation is safe. It seems to work, though. |
|
This should hypothetically work for arrays. Not really having the time to test--would be amazing if you could play around |
|
@coder2020official — your fix works. Confirmed on One thing worth flagging separately, because I don't think it was obvious from how I first framed it (my original report was only about the send path): the same When a
In effect it's a remotely-triggerable poller stall: anyone can send/forward rich content to any polling bot and freeze it — even if the bot never sends rich messages itself. That's actually how I hit it: an inbound forward, not a send. # no server needed to reproduce the crash Update.de_json would hit:
from telebot.types import RichText
RichText.de_json({"type": "bold", "text": "Detail"}) # pre-fix: JSONDecodeError
So it may be worth making the receive/parse path fail-safe while the block classes are being finished: if |
|
@coder2020official — one more of the same family (like the earlier
return await asyncio_helper.send_rich_message_draft(
self.token, chat_id, draft_id, rich_message,
message_thread_id=message_thread_id, business_connection_id=business_connection_id)but async def send_rich_message_draft(token, chat_id, draft_id, rich_message, message_thread_id=None):so every call fails with: Minimal repro (async): await bot.send_rich_message_draft(chat_id, 1, types.InputRichMessage(html="<tg-thinking>hi</tg-thinking>"))The sync Suggested fix: add I worked around it by calling the helper directly, and the draft itself streams fine once that's bypassed. |
|
sendrichmessagedraft shouldn't even have business connection id |
|
I tried forwarding a rich message to the bot and there were no issues |
It was fixed in dee734d |
|
@coder2020official Sorry for been so long. Hope to review today. |
There was a problem hiding this comment.
Pull request overview
This PR updates the library to align with Telegram Bot API 10.1 by adding rich message types (RichText/RichBlock/RichMessage + InputRichMessage), new join request query fields/methods, and poll option link media support, plus updating the README’s supported API version.
Changes:
- Added rich message object model +
sendRichMessage/sendRichMessageDraftsupport, andrich_messagehandling inMessageandeditMessageText. - Added join request query support (
query_id,guard_bot,supports_join_request_queries) and related API methods. - Added poll option
Link/InputMediaLinksupport and bumped README Bot API version to 10.1.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| telebot/types.py | Adds new Bot API 10.1 types (RichText/RichBlock/RichMessage, Link/InputMediaLink) and extends existing models (User/Message/PollMedia/etc.). |
| telebot/asyncio_helper.py | Adds async endpoints for rich messages and join request queries; extends edit_message_text with rich_message. |
| telebot/async_telebot.py | Exposes async bot methods for rich messages and join request query APIs; extends edit_message_text signature/docs. |
| telebot/apihelper.py | Adds sync endpoints for rich messages and join request queries; extends edit_message_text with rich_message. |
| telebot/init.py | Exposes sync bot methods for rich messages and join request query APIs; extends edit_message_text signature/docs. |
| README.md | Updates “Supported Bot API version” to 10.1 (June 11, 2026). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@Badiboy done |
Rich Messages
Join Request Queries
Polls