Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supported reply_to_message_id for Telegram topics. #3560

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/notifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ type TelegramConfig struct {
Message string `yaml:"message,omitempty" json:"message,omitempty"`
DisableNotifications bool `yaml:"disable_notifications,omitempty" json:"disable_notifications,omitempty"`
ParseMode string `yaml:"parse_mode,omitempty" json:"parse_mode,omitempty"`
MessageThreadID int64 `yaml:"message_thread_id,omitempty" json:"message_thread_id,omitempty"`
}

// UnmarshalYAML implements the yaml.Unmarshaler interface.
Expand Down
12 changes: 12 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,18 @@ attributes:
# ID of the chat where to send the messages.
[ chat_id: <int> ]

# id of the Telegram group topic.
# Primarily intended for sending notifications to a specific Telegram topic.
# see https://telegram.org/blog/topics-in-groups-collectible-usernames
# To do this, you need to pass the id of the topic by this parameter.
# In order to find out the id of the topic, in the Telegram desktop client,
# right-click on the first message in the topic, select "Copy Message Link".
# Get a link like:
# https://t.me/c/1234567890/1234/1235
# The second part of the link is the id of the topic:
# 1234
[ message_thread_id: <int> ]

# Message template.
[ message: <tmpl_string> default = '{{ template "telegram.default.message" .}}' ]

Expand Down
1 change: 1 addition & 0 deletions notify/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err
}

message, err := n.client.Send(telebot.ChatID(n.conf.ChatID), messageText, &telebot.SendOptions{
ReplyTo: &telebot.Message{ID: int(n.conf.MessageThreadID)},
DisableNotification: n.conf.DisableNotifications,
DisableWebPagePreview: true,
})
Expand Down