技术解析
钉钉机器人 go 库
github 地址: https://github.com/greycodee/dingbot
钉钉官方文档
go get github.com/greycodee/dingbot
示例程序:
package main
import (
"fmt"
"github.com/greycodee/dingbot"
"github.com/greycodee/dingbot/message"
"time"
)
func main() {
bot:= dingbot.DingBot{
Secret: "你的加签秘钥",
AccessToken: "你的 AccessToken [从钉钉机器人的 url 上获取] ",
}
msg := message.Message{
MsgType: message.TextStr,
Text: message.Text_{
Content: "go-钉钉机器人测试",
},
}
bot.Send(msg)
}
func send() {
bot:= dingbot.DingBot{
Secret: "你的加签秘钥",
AccessToken: "你的 AccessToken [从钉钉机器人的 url 上获取] ",
}
msg := message.Message{
MsgType: message.TextStr,
Text: message.Text_{
Content: "go-钉钉机器人测试",
At: message.At_{
AtMobiles: []string{"188xxxxxxxx"},
IsAtAll: false,
},
},
}
bot.Send(msg)
}
func send() {
bot:= dingbot.DingBot{
Secret: "你的加签秘钥",
AccessToken: "你的 AccessToken [从钉钉机器人的 url 上获取] ",
}
msg := message.Message{
MsgType: message.LinkStr,
Link: message.Link_{
Text: "link 测试 123123",
Title: "go 钉钉机器人",
PicUrl: "",
MessageUrl: "https://developers.dingtalk.com/document/app/custom-robot-access/title-72m-8ag-pqw",
},
}
bot.Send(msg)
}
func send() {
bot:= dingbot.DingBot{
Secret: "你的加签秘钥",
AccessToken: "你的 AccessToken [从钉钉机器人的 url 上获取] ",
}
msg := message.Message{
MsgType: message.MarkdownStr,
Markdown: message.Markdown_{
Title: "go 钉钉",
Text: "## go 钉钉测试 @188xxxxxxxx \n>文本 123",
At: message.At_{
AtMobiles: []string{"188xxxxxxxx"},
IsAtAll: false,
},
},
}
bot.Send(msg)
}
func send() {
bot:= dingbot.DingBot{
Secret: "你的加签秘钥",
AccessToken: "你的 AccessToken [从钉钉机器人的 url 上获取] ",
}
msg := message.Message{
MsgType: message.ActionCardStr,
ActionCard: message.ActionCard_{
Title: "ActionCard 整体跳转 11",
Text: "ActionCardt 整体跳转 1223",
SingleTitle: "阅读全文",
SingleURL: "https://de美国服务器velopers.dingtalk.com/document/app/custom-robot-access/title-72m-8ag-pqw",
},
}
bot.Send(msg)
}
func send() {
bot:= dingbot.DingBot{
Secret: "你的加签秘钥",
AccessToken: "你的 AccessToken [从钉钉机器人的 url 上获取] ",
}
msg := message.Message{
MsgType: message.ActionCardStr,
ActionCard: message.ActionCard_{
Title: "ActionCard 跳转 11",
Text: "ActionCardt 跳转 1223",
BtnOrientation: "1",
HideAvatar: "0",
BtnS: []message.Btn_{
{
Title: "按钮 1",
ActionURL: "https://developers.dingtalk.com/",
},
{
Title: "按钮 2",
ActionURL: "https://developers.dingtalk.com/",
},
},
},
}
bot.Send(msg)
}
func send() {
bot:= dingbot.DingBot{
Secret: "你的加签秘钥",
AccessToken: "你的 AccessToken [从钉钉机器人的 url 上获取] ",
}
msg := message.Message{
MsgType: message.FeedCardStr,
FeedCard: message.FeedCard_{[]message.Link_{
{
Title: "标题 1",
PicUrl: "",
MessageUrl: "https://developers.dingtalk.com/",
},
{
Title: "标题 2",
PicUrl: "",
MessageUrl: "https://developers.dingtalk.com/",
},
}},
}
bot.Send(msg)
}
原文地址: [ go 库] 钉钉机器人