Skip to content

Commit 48c7dce

Browse files
author
yisu
committed
added robot api
1 parent 58c2253 commit 48c7dce

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

demo/ding_alert/ding_alert.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ var link string
2020
var file string
2121
var title string
2222
var text string
23+
var robot bool
24+
var token string
2325

2426
func init() {
27+
flag.BoolVar(&robot,"robot", false,"use robot api?")
28+
flag.StringVar(&token,"token", "" ,"robot access token or token to override env setting")
2529
flag.StringVar(&msgType, "type", "app", "message type (app, text, image, voice, link, oa)")
2630
flag.StringVar(&agentID, "agent", "22194403", "agent Id")
2731
flag.StringVar(&senderID, "sender", "011217462940", "sender id")
@@ -56,7 +60,11 @@ func main() {
5660
case "app":
5761
err = c.SendAppMessage(agentID, toUser, content)
5862
case "text":
59-
err = c.SendTextMessage(senderID, chatID, content)
63+
if (robot) {
64+
err = c.SendRobotTextMessage(token, content)
65+
} else {
66+
err = c.SendTextMessage(senderID, chatID, content)
67+
}
6068
case "image":
6169
if file == "" {
6270
panic("Image path is empty")

0 commit comments

Comments
 (0)