multiple discord senders
This commit is contained in:
@@ -3,10 +3,16 @@ package lib
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func NewDiscordSender(webhook string, fake bool) DiscordSender {
|
||||
return DiscordSender{
|
||||
Webhook: webhook,
|
||||
Fake: fake,
|
||||
}
|
||||
}
|
||||
|
||||
type DiscordSender struct {
|
||||
Webhook string
|
||||
Fake bool
|
||||
@@ -19,13 +25,3 @@ func (d DiscordSender) Send(msg string) {
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user