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
+34
View File
@@ -0,0 +1,34 @@
package channels
import (
"github.com/engigu/baihu-panel/internal/sdk/message"
"strconv"
)
type GotifyChannel struct{ *BaseChannel }
func NewGotifyChannel() Channel {
return &GotifyChannel{NewBaseChannel(ChannelGotify, []string{FormatTypeText})}
}
func (c *GotifyChannel) Send(config ChannelConfig, msg *Message) (*Result, error) {
url := config.GetString("url")
token := config.GetString("token")
if url == "" || token == "" {
return SendError("gotify config missing: url and token are required"), nil
}
priority, _ := strconv.Atoi(config.GetString("priority"))
cli := message.Gotify{
Url: url,
Token: token,
Priority: priority,
}
res, err := cli.Request(msg.Title, msg.Text)
if err != nil {
return ErrorResult(string(res), err), nil
}
return SuccessResult(string(res)), nil
}