Compare commits
2 commits
7cb1ec1bba
...
3fabf4381e
Author | SHA1 | Date | |
---|---|---|---|
|
3fabf4381e | ||
|
4910d2ca55 |
2 changed files with 6 additions and 2 deletions
7
auth.go
7
auth.go
|
@ -85,8 +85,11 @@ func NotifyTelegram(msg string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
var data = strings.NewReader("chat_id=" + Cfg.TelegramChat + "&text=" + msg)
|
data := "chat_id=" + Cfg.TelegramChat + "&text=" + msg
|
||||||
req, err := http.NewRequest("POST", "https://api.telegram.org/bot"+Cfg.TelegramToken+"/sendMessage", data)
|
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 {
|
if err != nil {
|
||||||
slog.Error("failed telegram request", "error", err)
|
slog.Error("failed telegram request", "error", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -30,6 +30,7 @@ type Config struct {
|
||||||
|
|
||||||
TelegramToken string `config:"tg_token" type:"string"`
|
TelegramToken string `config:"tg_token" type:"string"`
|
||||||
TelegramChat string `config:"tg_chat" type:"string"`
|
TelegramChat string `config:"tg_chat" type:"string"`
|
||||||
|
TelegramTopic string `config:"tg_topic" type:"string"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var DefaultConfig = Config{
|
var DefaultConfig = Config{
|
||||||
|
|
Loading…
Reference in a new issue