ganiyevuz/telegram-richtext

telegram-rich-messages

Use when an aiogram Telegram bot should send a message that reads better with structure than as plain text — tables, inline images/video/audio, headings, lists, collapsible sections, block quotes, footnotes, math, or maps — or when tempted to fake a table w…

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/ganiyevuz/telegram-richtext --skill telegram-rich-messages

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

Telegram Rich Messages (aiogram)

Overview

Telegram Bot API 10.1 (June 2026) added rich messages: a single message can contain headings, tables, inline images/video/audio, lists, collapsible <details>, block quotes, footnotes, math, and maps — composed from one HTML or Markdown string. aiogram ≥ 3.29 supports it natively. If a message would read better structured, send a rich message — don't fake the structure.

Bust these outdated assumptions first

This feature postdates most training data, which is wrong about the following. If you catch yourself believing any of these, stop and use a rich message:

You might thinkReality (Bot API 10.1)
"Telegram has no tables; only b/i/code/pre/a"Full tag set: <table>, <h1>–<h6>, <ul>/<ol>, <details>, <blockquote>, <figure>, math, maps.
"You can't put an image inside a message"Media are blocks inside one rich message (photo/video/audio/voice + galleries).
"Pad columns in <pre> monospace to align them"Use a real <table>. Never fake tables.
"Set parse_mode=HTML / put it in a photo caption"Rich messages ignore `parse_mode`; you pass an html/markdown string to InputRichMessage.
"Captions cap at 1024 chars"Rich message limit is 32768 chars / 500 blocks.

Send it (aiogram)

python
from aiogram.types import InputRichMessage, Message

async def report(message: Message) -> None:
    html = (
        "<h1>🌐 Domain Status Report</h1>"
        "<table bordered striped>"
        "<tr><th>Domain</th><th>Status</th></tr>"
        "<tr><td>example.com</td><td><mark>Available</mark></td></tr>"
        "<tr><td>foo.io</td><td>Taken</td></tr>"
        "</table>"
        '<figure><img src="https://example.com/chart.png"/>'
        "<figcaption>Availability, last 30 days</figcaption></figure>"
    )
    await message.answer_rich(InputRichMessage(html=html))
  • Exactly one of html= / markdown=.
  • Reply in a handler: message.answer_rich(InputRichMessage(html=...)) or message.reply_rich(...). Send elsewhere: bot.send_rich_message(chat_id, InputRichMessage(...)).
  • Edit an existing message: bot.edit_message_text(chat_id=..., message_id=..., rich_message=InputRichMessage(html=...)).
  • Stream (AI "Thinking…", private chats only): bot.send_rich_message_draft(chat_id, draft_id, InputRichMessage(html="<tg-thinking>Analyzing…</tg-thinking>")) — ephemeral ~30 s, animates on the same non-zero draft_id; you must finalize with send_rich_message to persist.
  • Read inbound rich content: message.rich_message (a parsed RichMessage, or None if the message isn't rich).

Pick a language, then read its syntax reference

Before composing, open the syntax reference for your chosen language and build only from the tags/options listed there — don't work from memory or invent tags (only documented ones render). Escape dynamic/user text (& < > "). Default to HTML (most complete); use Markdown for simple messages.

Syntax and every available option live alongside this skill in `examples/` — read the relevant file whenever you need a tag, attribute, or option:

NeedRead
Every HTML tag + attribute (options to use)examples/rich-html-style.md
Full Markdown syntaxexamples/rich-markdown-style.md
Date/time format string (`r\w?[dD]?[tT]?`)examples/date-time-entity-formatting.md
Inbound parsed shape + round-trip lessonsexamples/parsed-notes.md
Index of the aboveexamples/README.md
Full type/method spec (all fields & methods)bot-api-10.1-rich-messages.md

Feature → HTML tag (quick map)

NeedTag
Heading<h1>…<h6>
Table<table [bordered] [striped]>, <tr>, <th>/<td align valign colspan rowspan>
Image / video / audio / voice<img> / <video> / <audio> (.ogg → voice) — each a separate block
Caption + credit<figure>…<figcaption>Caption<cite>Credit</cite></figcaption></figure>
Gallery<tg-collage> / <tg-slideshow>
List / tasks<ul>/<ol>/<li>; <li><input type="checkbox" [checked]>
Collapsible<details [open]><summary>…</summary>…</details>
Quote / pull-quote<blockquote>…<cite>…</cite></blockquote> / <aside>
Math<tg-math> inline, <tg-math-block> block (LaTeX)
Map<tg-map lat="" long="" zoom="">
Footnote / reference<tg-reference name="x">…</tg-reference> + <a href="#x">
Date / time<tg-time unix="" format="">

Media & limits

  • Media only as separate blocks, http(s) URLs only. You send a URL; the inbound

message returns a file_id (see examples/parsed-notes.md). Sending a media block requires the bot's right to send media in that chat.

  • Table cells hold inline formatting only — no nested blocks/paragraphs.
  • Limits: 32768 chars · 500 blocks · 16 nesting levels · 50 media · 20 table columns.

Common mistakes

  • Faking a table with <pre>/spaces → use <table>.
  • Splitting an image into its own answer_photo message → inline it as a media block.
  • parse_mode=HTML + rich content → rich messages ignore parse_mode; pass InputRichMessage.
  • Inventing tags not in the syntax file → only documented tags render.
  • Forgetting to escape dynamic text → escape & < > ".