feat(telegram): bot support relay — per-user forum topics #130
Reference in New Issue
Block a user
Delete Branch "feature/telegram-support-relay"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Bot-local Telegram support relay: a user who DMs the bot anything but
/startis relayed into a private forum supergroup as a per-user topic; the chat's admins reply in the topic and the bot copies it back to the user. Each topic opens with an info card (name, @username, language, premium, id, profile link) carrying Block/Unblock + Clear buttons.Separate from the in-app Feedback (ARCHITECTURE §15) — no backend, no bot-link, no
feedback_messages.How
internal/support: concurrency-safe JSON store (topic map, block list, relayed ids), atomic save; field-targeted mutators so a topic recreate can't clobber a concurrent block.bot/support.go: relay viacopyMessageboth ways; short-TTL admin cache; callback buttons; per-user topic-create lock; loop guard (skip the bot's own posts +IsBot); reopen a deleted topic on the next message.TELEGRAM_SUPPORT_CHAT_ID(per contour) +TELEGRAM_SUPPORT_STATE_DIR=/data;bot-statenamed volume on both compose files;/datapre-owned by UID 65532 so a fresh volume is writable under distroless nonroot.Safety / rollout
Off by default (
TELEGRAM_SUPPORT_CHAT_ID=0) — deploying this changes nothing until activated. The only always-on change is the/datavolume.Activation (owner)
TEST_TELEGRAM_SUPPORT_CHAT_ID(laterPROD_TELEGRAM_SUPPORT_CHAT_ID) to that group's chat id.Tests
go test -race ./platform/telegram/...green (store + relay on an httptest fake Bot API: first-contact topic+card, topic reuse, block-drop, operator reply, loop guard, non-admin denial, clear, parse, escaping). gofmt/vet clean. Both compose filesconfig-validate; the bot image builds and/datais65532:65532.