feat: render replies as Bot API 10.1 rich messages - #19
Merged
Conversation
AaronCQL
force-pushed
the
feat/rich-messages
branch
from
June 16, 2026 03:57
65ea65f to
2dbaaf9
Compare
Telegram Bot API 10.1 adds "rich messages" (sendRichMessage), which parse an HTML or Markdown string into native blocks server-side - tables, headings, LaTeX formulas, real lists, block quotes and horizontal rules - with a 32768-character limit instead of 4096. This adds a second formatter, FormatTelegramRichHTML, that emits the structural Rich HTML tags instead of downgrading them the way the legacy FormatTelegramHTML does (headings to bold, tables to key/value lists, hr to em-dashes). ```math fences become <tg-math-block> formulas; inline $...$ is deliberately not auto-detected so currency in prose stays literal. Transport uses gotgbot's generic Request escape hatch (sendRich / EditRichMessage) since the typed method isn't generated yet; swap to the typed call once it lands upstream. Both the final reply (sendResult / editResult) and the live status bubble now send as rich messages with a graceful fallback to the legacy chunked-HTML path, so a disabled flag, an over-length reply, or a Telegram rejection degrades cleanly rather than breaking. The status bubble joins lines with <br> (rich HTML collapses literal newlines) and renders streamed intermediate text as escaped inline so partial mid-stream markdown can't break the parse. Gated by MINICLAW_RICH_MESSAGES (default on), honoured for both the reply and status paths.
AaronCQL
force-pushed
the
feat/rich-messages
branch
from
June 16, 2026 04:02
2dbaaf9 to
1c8ac3a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adopts Telegram Bot API 10.1 rich messages (
sendRichMessage) so agent replies render with native tables, headings, LaTeX formulas, real lists, block quotes and horizontal rules, and gain the larger 32768-character limit (vs 4096).Rich messages take an HTML (or Markdown) string that Telegram parses into blocks server-side - there's no block-tree JSON to build. We send via the
htmlfield to keep full escaping control (so the agent's stray</&and dollar amounts in prose stay literal).How
FormatTelegramRichHTML(internal/formatter_rich.go) - a second goldmark renderer that emits the structural Rich HTML tags instead of downgrading them the way legacyFormatTelegramHTMLdoes (headings→bold, tables→key/value lists,---→em-dashes).```mathfences become<tg-math-block>formulas. Inline$...$is deliberately not auto-detected, so currency in prose ($15K,$1.2M) stays literal.internal/telegram.go) -sendRich/SendRichMessage/EditRichMessagevia gotgbot's genericRequestescape hatch, since the typed method isn't generated yet (one-line swap once it lands upstream).sendResult/editResultand the live status bubble (SendStatusMessage/EditStatusMessage) send as rich with a graceful fallback to the legacy chunked-HTML path. A disabled flag, over-length reply, or Telegram rejection degrades cleanly rather than breaking.<br>(rich HTML collapses literal newlines) and renders streamed intermediate text as escaped inline, so partial mid-stream markdown can't break the parse.MINICLAW_RICH_MESSAGES(default on), honoured for both the reply and status paths.agent/CLAUDE.mdupdated to tell the agent it can use tables/headings/math freely.Testing
go build ./...,go vet ./...,go test ./...all green.formatter_rich_test.go(16 cases) covers headings, aligned tables, math fences, lists/task lists, HTML escaping, and the dollar-amount safety case; status tests updated for the<br>separators.Notes
Requestescape hatch deliberately; the typedSendRichMessagewill replace it whengotgbotships 10.1 support.