fix(telegram): support relay — text_mention card + reopen deleted topic #132

Merged
developer merged 2 commits from feature/telegram-support-card-mention into development 2026-06-23 16:51:04 +00:00
Owner

Two info-card nuances and a topic-deletion bug, all found in live prod use.

1. Card — name & profile link

  • "Открыть профиль" was a tg://user?id= link → renders as dead text for a client that doesn't already know the user (the test-vs-prod difference).
  • A name starting with / was auto-detected by Telegram as a tappable bot command.

Fix: build the card with message entities; the display name is a text_mention (the reliable mention for a username-less user the bot has already seen) → it links the profile and, being inside an entity, suppresses /command / @mention auto-detection on the name. HTML parse mode and the tg:// link are gone; offsets are UTF-16.

2. Deleted topic silently lost to General

Deleting a user's whole topic made the next message land in General with no card. Root cause (confirmed against the prod bot logs — neither a relay error nor a reopen was logged): Telegram routes a copyMessage aimed at a deleted topic into General with no error, so the error-based recreate never fired.

Fix: probe topic liveness before reuse — re-applying the info card's reply markup is a no-op that errors only when the card (hence the topic) is gone — and reopen the topic + card on that signal. The post-copy recreate stays as a race backstop.

Tests: go test -race ./platform/telegram/... green; new cases for the /-name entity, the UTF-16 offset, and reopen-on-delete. gofmt/vet clean.

Ship target: v1.5.1 to prod after approve.

Two info-card nuances **and** a topic-deletion bug, all found in live prod use. ### 1. Card — name & profile link - "Открыть профиль" was a `tg://user?id=` link → renders as **dead text** for a client that doesn't already know the user (the test-vs-prod difference). - A name starting with `/` was auto-detected by Telegram as a **tappable bot command**. **Fix:** build the card with **message entities**; the display name is a `text_mention` (the reliable mention for a username-less user the bot has already seen) → it links the profile *and*, being inside an entity, suppresses `/command` / `@mention` auto-detection on the name. HTML parse mode and the `tg://` link are gone; offsets are UTF-16. ### 2. Deleted topic silently lost to General Deleting a user's whole topic made the next message land in **General** with no card. Root cause (confirmed against the prod bot logs — neither a relay error nor a reopen was logged): Telegram routes a `copyMessage` aimed at a deleted topic into **General with no error**, so the error-based recreate never fired. **Fix:** probe topic liveness before reuse — re-applying the info card's reply markup is a no-op that errors only when the card (hence the topic) is gone — and reopen the topic + card on that signal. The post-copy recreate stays as a race backstop. Tests: `go test -race ./platform/telegram/...` green; new cases for the `/`-name entity, the UTF-16 offset, and reopen-on-delete. gofmt/vet clean. **Ship target: v1.5.1** to prod after approve.
developer added 1 commit 2026-06-23 16:33:36 +00:00
fix(telegram): support card — text_mention name, no command/dead link
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 17s
CI / ui (pull_request) Has been skipped
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m19s
bb18dc362b
The topic info card built the profile link as `tg://user?id=`, which
clients render as dead text for a user they don't already know (the
test-vs-prod difference an operator saw), and it put the raw display
name through HTML — so a name starting with "/" was auto-detected as a
tappable bot command that fired when tapped.

Render the card with message entities instead: the display name is
covered by a `text_mention` entity (the reliable way to mention a
username-less user the bot has already seen — it messaged the bot),
which links the profile AND, because the name sits inside an entity,
suppresses the "/command" and "@mention" auto-detection on it. Drop the
HTML parse mode and the tg:// link. Entity offsets are UTF-16.
developer added 1 commit 2026-06-23 16:45:40 +00:00
fix(telegram): reopen a deleted support topic instead of losing it to General
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 16s
CI / ui (pull_request) Has been skipped
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m18s
fc1715128e
Telegram silently routes a copyMessage aimed at a deleted forum topic
into the chat's General topic with NO error, so the bot's error-based
recreate never fired — the user's next message landed in General with no
card. Confirmed against the prod bot logs: a relay after a topic deletion
logged neither "relay to topic failed" nor "topic gone, reopening".

Probe topic liveness before reusing it: re-applying the info card's reply
markup is a no-op that errors only when the card (hence the topic) is
gone, so the bot detects the deletion and reopens the topic + card rather
than relying on the (absent) copy error. The post-copy recreate stays as
a race backstop.
developer changed title from fix(telegram): support card — text_mention name, no command/dead link to fix(telegram): support relay — text_mention card + reopen deleted topic 2026-06-23 16:46:07 +00:00
owner approved these changes 2026-06-23 16:50:07 +00:00
developer merged commit 10264e10c8 into development 2026-06-23 16:51:04 +00:00
developer deleted branch feature/telegram-support-card-mention 2026-06-23 16:51:04 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: developer/scrabble-game#132