feat: add pushplus
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -72,4 +72,5 @@ const (
|
||||
ChannelPushMe = "PushMe"
|
||||
ChannelNtfy = "Ntfy"
|
||||
ChannelGotify = "Gotify"
|
||||
ChannelPushPlus = "PushPlus"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user