|
@@ -18,13 +18,17 @@ type WeixinMessage struct {
|
|
|
|
|
|
// SendWeixinNotification 发送企业微信机器人告警
|
|
// SendWeixinNotification 发送企业微信机器人告警
|
|
func SendWeixinNotification(message string) error {
|
|
func SendWeixinNotification(message string) error {
|
|
|
|
+ webhook_url := g.Config().MustGet(gctx.New(), "weixin.webhook_url").String()
|
|
|
|
+ if webhook_url == "" {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
msg := WeixinMessage{MsgType: "text"}
|
|
msg := WeixinMessage{MsgType: "text"}
|
|
msg.Text.Content = message
|
|
msg.Text.Content = message
|
|
data, err := json.Marshal(msg)
|
|
data, err := json.Marshal(msg)
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
- resp, err := http.Post(g.Config().MustGet(gctx.New(), "weixin.webhook_url").String(), "application/json", bytes.NewReader(data))
|
|
|
|
|
|
+ resp, err := http.Post(webhook_url, "application/json", bytes.NewReader(data))
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Println("SendWeixinNotification error", err)
|
|
log.Println("SendWeixinNotification error", err)
|
|
return err
|
|
return err
|