Files
updater/lib/sender.discord.go

28 lines
443 B
Go

package lib
import (
"bytes"
"encoding/json"
"net/http"
)
func NewDiscordSender(webhook string, fake bool) DiscordSender {
return DiscordSender{
Webhook: webhook,
Fake: fake,
}
}
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))
}