Skip to content

Telegram: bold target name and status (HTML mode) - #21

Merged
rumkit merged 2 commits into
masterfrom
telegram-bold
Dec 2, 2026
Merged

rumkit merged 2 commits into
masterfrom
telegram-bold

Conversation

@rumkit

@rumkit rumkit commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Summary

Owner feedback #9: in Telegram the target name and status are now bold.

  • Telegram messages are sent with parse_mode: "HTML".
  • Alert texts are built once with invisible bold markers (new notify::markup). At Telegram send time everything is HTML-escaped (&, <, >) and the markers become <b>...</b>. For email and the dashboard queue list the markers are removed, so email stays plain text.
  • The queue stores the marked text (still plain-looking text, no HTML). Rows stored before this change have no markers and are sent escaped, not bold.
  • Truncation (4000 visible chars) runs on the marked text before the HTML is built, so it never splits a tag or entity, and an open bold part is closed. html() always produces balanced tags, even for hostile input.
  • Telegram error scrubbing is untouched.
  • Bold: target name, status words, the "Telegram restored / rate limit ended after X" headline, heartbeat title line and per-target lines, "pingwin test message". Regular: reasons, durations, times, notes, the "[delayed (originally ...)]" prefix.

Examples (rendered, then raw HTML sent)

  1. web-1: host RECOVERED after 12m (down since 14:02 UTC)
    🐧 <b>web-1: host RECOVERED</b> after 12m (down since 14:02 UTC)
  2. db-1: ssh OFFLINE (refused) since 14:02 UTC
    🐧 <b>db-1: ssh OFFLINE</b> (refused) since 14:02 UTC
  3. Telegram restored after 2m (unreachable since 2026-11-30 13:58 UTC)
    🐧 <b>Telegram restored after 2m</b> (unreachable since 2026-11-30 13:58 UTC)

Test plan

  • Alert: bold name+status, regular details, name a<b&c escaped; request has parse_mode=HTML.
  • Delayed flush of an old plain row and a new marked row; prefix once.
  • Restored / rate-limit-ended header, heartbeat, test message.
  • Email subject/body contain no HTML or markers (new alert and delayed row).
  • Truncation of a very long message keeps balanced <b> and no cut entity.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (479 pass) in WSL.

🤖 Generated with Claude Code

rumkit and others added 2 commits December 1, 2026 20:52
Telegram messages are sent with parse_mode HTML. Alert texts carry invisible
bold markers that are turned into <b> tags (with everything else escaped) at
send time, and removed for email and the dashboard queue view. Queue rows
stored before this change are sent escaped and not bold. Truncation happens
before the HTML is built.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The notifications.csv dump wrote stored messages with the invisible
private-use bold markers. Seed test notifications with markers so every
reader is checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rumkit
rumkit merged commit d22c209 into master Dec 2, 2026
5 checks passed
@rumkit
rumkit deleted the telegram-bold branch December 3, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant