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
+38
View File
@@ -0,0 +1,38 @@
package channels
import "github.com/engigu/baihu-panel/internal/sdk/message"
type WeChatOFAccountChannel struct{ *BaseChannel }
func NewWeChatOFAccountChannel() Channel {
return &WeChatOFAccountChannel{NewBaseChannel(ChannelWeChatOFAccount, []string{FormatTypeText})}
}
func (c *WeChatOFAccountChannel) Send(config ChannelConfig, msg *Message) (*Result, error) {
appID := config.GetString("appID")
appSecret := config.GetString("appsecret")
tempID := config.GetString("tempid")
toAccount := config.GetString("to_account")
if appID == "" || appSecret == "" {
return SendError("wechat config missing: appID, appsecret are required"), nil
}
if toAccount == "" {
return SendError("wechat config missing: to_account is required"), nil
}
_, formattedContent := c.FormatContent(msg)
cli := message.WeChatOFAccount{
AppID: appID,
AppSecret: appSecret,
TemplateID: tempID,
ToUser: toAccount,
URL: msg.URL,
}
res, err := cli.Send(msg.Title, formattedContent)
if err != nil {
return ErrorResult(res, err), nil
}
return SuccessResult(res), nil
}