Files
updater/lib/sender.discord.go
2026-01-20 01:00:09 +01:00

32 lines
489 B
Go

package lib
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
type DiscordSender struct {
Webhook string
Fake bool
}
func (d DiscordSender) Send(msg string) {
b, _ := json.Marshal(map[string]string{"content": msg})
if d.Fake {
return
}
http.Post(d.Webhook, "application/json", bytes.NewBuffer(b))
}
func (d DiscordSender) SendBatch(msgs []string) {
for _, msg := range msgs {
log.Println("Sending to Discord:", msg)
if d.Fake {
continue
}
d.Send(msg)
}
}