Skip to content

Conversation

@shellshock321
Copy link

@shellshock321 shellshock321 commented Jun 4, 2025

This commit introduces the ability to send notifications to specific message threads (topics) within Telegram groups.

The following changes were made:

  • Added a new optional telegram_thread_id field to the Telegram provider configuration in pkg/providers/telegram/telegram.go.
  • Modified the Send function in the Telegram provider to append the telegram_thread_id to the telegram_chat_id in the Shoutrrr URL if provided. The format used is chat_id:thread_id.
  • Updated README.md to include documentation for the new telegram_thread_id field and provided a link to the Shoutrrr documentation for instructions on obtaining the message_thread_id.
  • Added unit tests in pkg/providers/telegram/telegram_test.go to verify the correct construction of the Telegram URL with and without the telegram_thread_id. This involved refactoring pkg/providers/telegram/telegram.go to allow mocking of the shoutrrr.Send function for testing purposes.

This feature allows you to direct notifications to specific topics in your Telegram groups, providing more granular control over where notifications appear.

Summary by CodeRabbit

  • New Features
    • Added support for specifying a Telegram thread ID when sending messages, allowing messages to be sent to specific threads within a chat.
  • Documentation
    • Updated README to document the new optional Telegram thread ID field and provide a reference link for more details.
  • Tests
    • Introduced tests to verify correct behavior when using the Telegram thread ID option.

This commit introduces the ability to send notifications to specific message threads (topics) within Telegram groups.

The following changes were made:

- Added a new optional `telegram_thread_id` field to the Telegram provider configuration in `pkg/providers/telegram/telegram.go`.
- Modified the `Send` function in the Telegram provider to append the `telegram_thread_id` to the `telegram_chat_id` in the Shoutrrr URL if provided. The format used is `chat_id:thread_id`.
- Updated `README.md` to include documentation for the new `telegram_thread_id` field and provided a link to the Shoutrrr documentation for instructions on obtaining the `message_thread_id`.
- Added unit tests in `pkg/providers/telegram/telegram_test.go` to verify the correct construction of the Telegram URL with and without the `telegram_thread_id`. This involved refactoring `pkg/providers/telegram/telegram.go` to allow mocking of the `shoutrrr.Send` function for testing purposes.

This feature allows you to direct notifications to specific topics in your Telegram groups, providing more granular control over where notifications appear.
@coderabbitai
Copy link

coderabbitai bot commented Jun 4, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The updates introduce support for an optional telegram_thread_id in the Telegram provider, allowing messages to be sent to specific Telegram threads. The Options struct and URL construction logic are updated accordingly. Comprehensive tests are added to verify the correct handling of thread IDs. Dependencies are updated to support testing.

Changes

Files/Groups Change Summary
README.md Documented the optional telegram_thread_id field in Telegram provider configuration.
go.mod Added github.com/stretchr/testify (direct), github.com/davecgh/go-spew, and github.com/pmezard/go-difflib (indirect) as dependencies.
pkg/providers/telegram/telegram.go Added TelegramThreadID to Options, updated URL construction to include thread ID, introduced mockable send function.
pkg/providers/telegram/telegram_test.go Added tests for URL construction and behavior of Send with and without TelegramThreadID.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TelegramProvider
    participant shoutrrrSendFunc

    User->>TelegramProvider: Send(message, options)
    alt TelegramThreadID is set
        TelegramProvider->>TelegramProvider: Combine ChatID and ThreadID
    else TelegramThreadID is empty
        TelegramProvider->>TelegramProvider: Use ChatID only
    end
    TelegramProvider->>shoutrrrSendFunc: Send(serviceURL, message)
Loading

Poem

In the warren, code hops anew,
Now threads on Telegram come into view!
With tests that check each hop and bound,
Dependencies added, robust and sound.
A thread ID here, a message there—
Rabbits rejoice, for features we share!
🐇✨

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dogancanbakir dogancanbakir self-requested a review June 10, 2025 10:54
@dogancanbakir dogancanbakir requested review from Mzack9999 and dwisiswant0 and removed request for dogancanbakir and dwisiswant0 September 29, 2025 17:07
@Mzack9999 Mzack9999 changed the base branch from main to dev October 6, 2025 09:25
Copy link
Member

@dwisiswant0 dwisiswant0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

integration test fails & conflicts

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.

3 participants