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

feat: add message thread id in telegramPayload #1008

Merged
merged 3 commits into from
Sep 25, 2024
Merged
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
2 changes: 2 additions & 0 deletions docs/outputs/telegram.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
| -------------------------- | -------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `telegram.chatid` | `TELEGRAM_CHATID` | | Telegram Identifier of the shared chat, if not empty, Telegram is **enabled** |
| `telegram.token` | `TELEGRAM_TOKEN` | | Telegram bot authentication token |
`telegram.message_thread_id` | `TELEGRAM_MESSAGE_THREAD_ID` | | Telegram individual chats within the group
| `telegram.minimumpriority` | `TELEGRAM_MINIMUMPRIORITY` | `""` (= `debug`) | Minimum priority of event for using this output, order is `emergency,alert,critical,error,warning,notice,informational,debug or ""` |

> [!NOTE]
Expand All @@ -29,6 +30,7 @@ The Env var values override the settings from yaml file.
telegram:
chatid: "" # Telegram Identifier of the shared chat, if not empty, Telegram is enabled
token: "" # Telegram bot authentication token
# message_thread_id: "" # Telegram individual chats within the group
# minimumpriority: "" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default)
```

Expand Down
6 changes: 6 additions & 0 deletions outputs/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type telegramPayload struct {
ParseMode string `json:"parse_mode,omitempty"`
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
ChatID string `json:"chat_id,omitempty"`
MessageThreadID string `json:"message_thread_id,omitempty"`
}

func newTelegramPayload(falcopayload types.FalcoPayload, config *types.Configuration) telegramPayload {
Expand All @@ -55,6 +56,11 @@ func newTelegramPayload(falcopayload types.FalcoPayload, config *types.Configura
ChatID: config.Telegram.ChatID,
}

// Check if message_thread_id is present in falcopayload
if config.Telegram.MessageThreadID != "" {
payload.MessageThreadID = config.Telegram.MessageThreadID
}

// template engine
var textBuffer bytes.Buffer
funcs := textTemplate.FuncMap{
Expand Down
1 change: 1 addition & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ type TelegramConfig struct {
ChatID string
MinimumPriority string
CheckCert bool
MessageThreadID string
}

// N8NConfig represents config parameters for N8N
Expand Down