feat(telegram): support forum topic via native message_thread_id - #142
Merged
Conversation
* migrate from go-telegram-bot-api v4.6.4+incompatible to the maintained OvyFlash/telegram-bot-api fork (recommended by the archived upstream) * add message_thread_id setting (PLUGIN_MESSAGE_THREAD_ID) and set the native BaseChat.MessageThreadID field on every outgoing message type * replace deprecated constructors: New*Upload -> New* with FilePath, NewBotAPIWithClient -> NewBotAPIWithOptions, and DisableWebPagePreview -> LinkPreviewOptions.IsDisabled * document message_thread_id in DOCS.md Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds Telegram forum-topic support by introducing a message_thread_id setting and migrating the plugin from the archived go-telegram-bot-api dependency to the maintained OvyFlash/telegram-bot-api fork so the native message_thread_id parameter can be sent without HTTP transport hacks.
Changes:
- Swaps Telegram Bot API Go dependency to
github.com/OvyFlash/telegram-bot-apiand updates message-send call sites accordingly. - Adds a new
message_thread_idconfiguration/flag/env var and applies it across all outbound message types. - Updates documentation to include the new setting and an example for forum topics.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| plugin.go | Migrates Bot API usage, wires MessageThreadID and link preview options into all send paths. |
| main.go | Adds CLI flag/env var wiring for message.thread.id → Config.MessageThreadID. |
| go.mod | Replaces archived Telegram Bot API library with OvyFlash/telegram-bot-api. |
| go.sum | Updates dependency checksums for the new Telegram library and removed transitive deps. |
| DOCS.md | Documents message_thread_id and adds a forum-topic example. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| for _, user := range ids { | ||
| for _, txt := range renderedMessages { | ||
| msg := tgbotapi.NewMessage(user, txt) | ||
| msg.MessageThreadID = p.Config.MessageThreadID |
| for _, user := range ids { | ||
| for _, txt := range renderedMessages { | ||
| msg := tgbotapi.NewMessage(user, txt) | ||
| msg.MessageThreadID = p.Config.MessageThreadID |
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.
Summary
Adds Telegram forum topic support (
message_thread_id) using the Bot API's native parameter instead of the HTTP-transport query-injection workaround proposed in #141.The old
go-telegram-bot-api v4.6.4+incompatible(2018, upstream archived) has nomessage_thread_idsupport, which is why #141 had to patch it in at thehttp.RoundTripperlevel. This PR migrates to the community-maintained OvyFlash/telegram-bot-api fork (the one recommended by the archived upstream), where every chat config embedsBaseChat.MessageThreadID— the parameter is only sent when non-zero, and only on actual send requests.Changes:
go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible→OvyFlash/telegram-bot-api(tracks current Bot API).message_thread_id(PLUGIN_MESSAGE_THREAD_ID/TELEGRAM_MESSAGE_THREAD_ID/INPUT_MESSAGE_THREAD_ID), applied to all message types: text, photo, document, sticker, audio, voice, video, location, venue.New*Upload(user, path)→New*(user, tgbotapi.FilePath(path)),DisableWebPagePreview→LinkPreviewOptions.IsDisabled,NewBotAPIWithClient→NewBotAPIWithOptions(token, WithHTTPClient(...))(non-deprecated form; SOCKS5 proxy path preserved).DOCS.mdgains a forum-topic example and amessage_thread_idparameter reference entry.Related issues
Architecture / flow
flowchart LR subgraph main.go F["--message.thread.id flag<br/>PLUGIN_MESSAGE_THREAD_ID"] end subgraph plugin.go C["Config.MessageThreadID"] E["Exec: per-recipient send loops<br/>(text/photo/document/sticker/<br/>audio/voice/video/location/venue)"] end subgraph "OvyFlash/telegram-bot-api" B["BaseChat.MessageThreadID<br/>AddNonZero(message_thread_id)"] end T["Telegram Bot API"] F --> C --> E --> B --> T style F fill:#d4edda,stroke:#28a745 style C fill:#d4edda,stroke:#28a745 style E fill:#fff3cd,stroke:#ffc107 style B fill:#d4edda,stroke:#28a745Green = new, yellow = modified (library migration).
AI authorship
plugin.go,main.go,DOCS.md,go.mod,go.sumChange classification
Plan reference
Replace the
http.RoundTripperquery-injection approach of #141 with the library's nativeMessageThreadIDfield, taking the opportunity to move off the archived v4 dependency.Verification
go build ./...✅,go vet ./...✅,go test ./...(13 tests) ✅,golangci-lint run ./...✅ (all local)TELEGRAM_TOKENrun in CI)Security check
Sendunchanged)Risk and rollback
message_thread_idis set andtoincludes non-forum chats, Telegram rejects those sends with "message thread not found" — inherent to a global thread id setting.Reviewer guide
plugin.go— bot construction (SOCKS5 path) and the nine send loops; confirm each setsMessageThreadIDand the constructor migration is faithful.main.goflag wiring,DOCS.mdwording,go.mod/go.sum(dependency swap dropstechnoweenie/multipartstreamer).🤖 Generated with Claude Code