diff --git a/auth.go b/auth.go index 4104243..1a1f545 100644 --- a/auth.go +++ b/auth.go @@ -85,8 +85,11 @@ func NotifyTelegram(msg string) { return } client := &http.Client{} - var data = strings.NewReader("chat_id=" + Cfg.TelegramChat + "&text=" + msg) - req, err := http.NewRequest("POST", "https://api.telegram.org/bot"+Cfg.TelegramToken+"/sendMessage", data) + data := "chat_id=" + Cfg.TelegramChat + "&text=" + msg + if Cfg.TelegramTopic != "" { + data += "&message_thread_id=" + Cfg.TelegramTopic + } + req, err := http.NewRequest("POST", "https://api.telegram.org/bot"+Cfg.TelegramToken+"/sendMessage", strings.NewReader(data)) if err != nil { slog.Error("failed telegram request", "error", err) return diff --git a/config.go b/config.go index 08b4871..d290c2d 100644 --- a/config.go +++ b/config.go @@ -30,6 +30,7 @@ type Config struct { TelegramToken string `config:"tg_token" type:"string"` TelegramChat string `config:"tg_chat" type:"string"` + TelegramTopic string `config:"tg_topic" type:"string"` } var DefaultConfig = Config{