Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
36 lignes
675 B
36 lignes
675 B
il y a 4 ans
|
package service
|
||
|
|
||
|
import (
|
||
|
"github.com/blinkbean/dingtalk"
|
||
|
"github.com/unknwon/goconfig"
|
||
|
"log"
|
||
|
)
|
||
|
|
||
|
type Dingtalk struct {
|
||
|
conf *goconfig.ConfigFile
|
||
|
}
|
||
|
|
||
|
func NewDingtalk(conf *goconfig.ConfigFile) *Dingtalk {
|
||
|
return &Dingtalk{conf: conf}
|
||
|
}
|
||
|
|
||
|
func (this *Dingtalk) Send(title, msg string) error {
|
||
|
cli := dingtalk.InitDingTalkWithSecret(
|
||
|
this.conf.MustValue("dingtalk", "access_token", ""),
|
||
|
this.conf.MustValue("dingtalk", "secret", ""),
|
||
|
)
|
||
|
markdown := []string{
|
||
|
"### " + title,
|
||
|
"---------",
|
||
|
msg,
|
||
|
}
|
||
|
err := cli.SendMarkDownMessageBySlice(title, markdown)
|
||
|
if err != nil {
|
||
|
log.Println(err)
|
||
|
} else {
|
||
|
log.Println("钉钉机器人推送成功")
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|