go-wxhelper/config/wechat.go
李寻欢 63d50b815c
All checks were successful
BuildImage / build-image (push) Successful in 1m30s
🆕 支持转发消息到外部服务(暂时只支持socket)
2023-12-06 10:16:52 +08:00

35 lines
862 B
Go

package config
import "strings"
// wxHelper
// @description: 微信助手
type wechat struct {
Host string `json:"host" yaml:"host"` // 接口地址
AutoSetCallback bool `json:"autoSetCallback" yaml:"autoSetCallback"` // 是否自动设置回调地址
Callback string `json:"callback" yaml:"callback"` // 回调地址
Forward []string `json:"forward" yaml:"forward"` // 转发地址
}
// Check
// @description: 检查配置是否可用
// @receiver w
// @return bool
func (w wechat) Check() bool {
if w.Host == "" {
return false
}
if w.AutoSetCallback && w.Callback == "" {
return false
}
return true
}
func (w wechat) GetURL(uri string) string {
host := w.Host
if !strings.HasPrefix(w.Host, "http://") {
host = "http://" + w.Host
}
return host + uri
}