feat: add pushplus

This commit is contained in:
engigu
2026-03-06 09:23:53 +08:00
parent e7324729c4
commit 7061cabd82
6 changed files with 118 additions and 0 deletions
@@ -0,0 +1,32 @@
package channels
import "github.com/engigu/baihu-panel/internal/sdk/message"
type PushPlusChannel struct{ *BaseChannel }
func NewPushPlusChannel() Channel {
return &PushPlusChannel{NewBaseChannel(ChannelPushPlus, []string{FormatTypeText, FormatTypeHTML, FormatTypeMarkdown})}
}
func (c *PushPlusChannel) Send(config ChannelConfig, msg *Message) (*Result, error) {
token := config.GetString("token")
if token == "" {
return SendError("pushplus config missing: token is required"), nil
}
cli := message.PushPlus{
Token: token,
Topic: config.GetString("topic"),
Template: config.GetString("template"),
Channel: config.GetString("channel"),
Webhook: config.GetString("webhook"),
CallbackUrl: config.GetString("callback_url"),
To: config.GetString("to"),
}
res, err := cli.Request(msg.Title, msg.Text)
if err != nil {
return ErrorResult(string(res), err), nil
}
return SuccessResult(string(res)), nil
}
+1
View File
@@ -72,4 +72,5 @@ const (
ChannelPushMe = "PushMe"
ChannelNtfy = "Ntfy"
ChannelGotify = "Gotify"
ChannelPushPlus = "PushPlus"
)