feat: add message push function call

This commit is contained in:
engigu
2026-03-04 21:45:43 +08:00
parent d4663cb492
commit 81b8d2a93d
53 changed files with 4161 additions and 33 deletions
+36
View File
@@ -0,0 +1,36 @@
package message
import (
"bytes"
"io"
"net/http"
"time"
)
type CustomWebhook struct {
Webhook string
Body string
}
var Client = &http.Client{
Timeout: 5 * time.Second,
}
func (cw *CustomWebhook) Request(url string, msg string) ([]byte, error) {
resp, err := Client.Post(url, "application/json", bytes.NewBuffer([]byte(msg)))
if err != nil {
return nil, err
}
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
}
}(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
return body, err
}