1 Star 0 Fork 0

magicianlyx / GoLog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dding.go 575 Bytes
一键复制 编辑 原始数据 按行查看 历史
magicianlyx 提交于 2019-12-31 21:58 . first
package alarm
import (
"bytes"
"fmt"
"net/http"
"time"
)
type DDingAlarm struct {
AccessToken string
lastSendTime time.Time
}
func (alarm *DDingAlarm) GetLastSendTime() time.Time {
return alarm.lastSendTime
}
func (alarm *DDingAlarm) Send(msg string) error {
data := fmt.Sprintf(`{"msgtype": "text","text": {"content": "%s"}}`, msg)
c := http.Client{}
urlFormat := "https://oapi.dingtalk.com/robot/send?access_token=%s"
url := fmt.Sprintf(urlFormat, alarm.AccessToken)
_, err := c.Post(url, "application/json", bytes.NewReader([]byte(data)))
return err
}
Go
1
https://gitee.com/magicianlyx/GoLog.git
git@gitee.com:magicianlyx/GoLog.git
magicianlyx
GoLog
GoLog
20c45f9b998d

搜索帮助