DingTalk robot golang library, and command line
package main
import (
"github.com/gladmo/dingbot"
)
func main() {
token := "you ding talk access token"
secret := "you ding talk secret, skip if old robot"
text := "hello world"
msg := dingbot.TextMessage(text)
client := dingbot.New(token, secret)
err := client.Send(msg)
if err != nil {
panic(err)
}
}
send dingtalk message
Usage:
dingbot [command]
Available Commands:
feedcard send dingtalk feedcard message
help Help about any command
init init config
link send dingtalk link message
markdown send dingtalk markdown message
text send dingtalk text message
version Print the version number of Dingbot
Flags:
--config string config file (default is $HOME/dingbot.toml)
-h, --help help for dingbot
--secret string dingtalk robot secret
--token string dingtalk robot token (require)
Use "dingbot [command] --help" for more information about a command.
$ docker pull gladmo/dingbot
$ docker run --rm gladmo/dingbot dingbot --help
$ alias dingbot="docker run --rm gladmo/dingbot dingbot --token 'you token' --secret 'you secret'"
# then
$ dingbot text "hello world"
$ git clone https://github.com/gladmo/dingbot.git
$ cd dingbot
$ go mod vendor
$ go build -o dingbot cmd/main.go
$ ./dingbot version
$ ./dingbot --token "you token" --secret "you secret" text "hello world"
# or
$ echo "hello world" | ./dingbot --token "you token" --secret "you secret" text
$ ./dingbot markdown --title hello '## hello world'
# or
$ echo "hello world" | ./dingbot --token "you token" --secret "you secret" markdown --title hello
$ ./dingbot --token "you token" --secret "you secret" link --title hello --message-url 'https://6cm.co' 'hello world'
# or
$ echo "hello world" | ./dingbot --token "you token" --secret "you secret" link --title hello --message-url 'https://6cm.co'
$ ./dingbot --token "you token" --secret "you secret" feedcard --json-link '{"title":"时代的火车向前开","messageURL":"https://www.dingtalk.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI","picURL":"https://gw.alicdn.com/tfs/TB1ayl9mpYqK1RjSZLeXXbXppXa-170-62.png"}' --json-link '{"title":"时代的火车向前开","messageURL":"https://www.dingtalk.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI","picURL":"https://gw.alicdn.com/tfs/TB1ayl9mpYqK1RjSZLeXXbXppXa-170-62.png"}'
# replace path/to to you dingbot path
$ alias dingbot="path/to/dingbot --token 'you token' --secret 'you secret'"
# then
$ dingbot text "hello world"
$ ./dingbot --token "you token" --secret "you secret" init dintbot.toml
$ ./dingbot --config dintbot.toml text "hello world"