golang 发送钉钉

package dingding

import (
	"github.com/royeo/dingrobot"
	"yangmengyao/dataChecksum/initlog"
)

func SendDingMsg(title string,dict []map[string]string,flag string) {
	//webhook := "https://oapi.dingtalt/send?accesaf3a00fd59fd815baa6e02837802da8bc515f9542cd33e56"
	webhook := "httpsngtalk.com/robot/send?access_tod6820bd0aa99f67853b00acf8fa57d228989391e"
	robot := dingrobot.NewRobot(webhook)
	atMobiles := []string{"17600584473"}
	str:="@17600584473 : " + flag

	for _,j:=range dict{
		for key,val:=range j{
			if key == "masterIp"{              //个别加色
				str += ">"+ "<font color=#FF0000>"+ key + "</font>"+"   |   "+ "<font color=#FF0000>"+ val+"</font>" +"\n\n"+"*****"+"\n\n"
				continue
			}
			if key == "SlaveIp"{
				str += ">"+ "<font color=#FF0000>"+ key + "</font>"+"   |   "+ "<font color=#FF0000>"+ val+"</font>" +"\n\n"+"*****"+"\n\n"
				continue
			}
			str += ">"+ "<font color=#FF0000>"+ key + "</font>"+"   |   "+ val +"\n\n"+"*****"+"\n\n"
		}
		str += "\n\n"+"**===========================**"+"\n\n"
	}
	isAtAll := false
	err := robot.SendMarkdown(title, str, atMobiles, isAtAll)
	if err != nil {
		initlog.Error.Println(err)
	}
}
发布了70 篇原创文章 · 获赞 11 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/YMY_mine/article/details/105050147