dingtalk-bot-sender

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2021 License: MIT

README

dingtalk-bot-sender

GoDoc

It's a simple golang sdk for dingtalk webhook bot

Overview

Installation

go get github.com/bob-zou/dingtalk-bot-sender

Usage

InitBot
package main
import "github.com/bob-zou/dingtalk-bot-sender/sender"

func main() {
	bot := sender.NewBot("access_token of your bot", "secret of your bot")
}
SendMessage
SendTextMessage
_ = bot.SendMessage(sender.TextMessage{
    Content:   "This is a text message",
    AtAll:     true,
})

example

_ = bot.SendMessage(sender.LinkMessage{
    Title:      "This is a link title",
    Content:    "This is a link message",
    PicURL:     "https://cdn.jsdelivr.net/gh/bob-zou/dingtalk-bot-sender/assets/pic-2.png",
    MessageURL: "https://github.com/bob-zou",
})

example

SendMarkDown
var markDownContent = `### MarkDown Title
> This is a markdown message

![screenshot](https://cdn.jsdelivr.net/gh/bob-zou/dingtalk-bot-sender/assets/pic-1.png)

 - list 1
 - list 2

[link](https://github.com/bob-zou)
`
// markdown message
_ = bot.SendMessage(sender.MarkDownMessage{
    Title:     "This is a markdown title",
    Content:   markDownContent,
    AtMobiles: []string{"13888888888"},
})

example

SendActionCard
_ = bot.SendMessage(sender.ActionCardMessage{
    Title:      "This is a action card title",
    Content:    "This is a action card title",
    Horizontal: true,
    Buttons:    []sender.ActionCardButton{
        {
            Title: "Action-1",
            URL:   "https://github.com/bob-zou",
        },
        {
            Title: "Action-2",
            URL:   "https://github.com/bob-zou",
        },
    },
})

example

SendFeedCard
_ = bot.SendMessage(sender.FeedCardMessage{
    Links: []sender.FeedCardLink{
        {
            Title:      "FeedCard-1",
            PicURL:     "https://cdn.jsdelivr.net/gh/bob-zou/dingtalk-bot-sender/assets/pic-2.png",
            MessageURL: "https://github.com/bob-zou",
        },
        {
            Title:      "FeedCard-2",
            PicURL:     "https://cdn.jsdelivr.net/gh/bob-zou/dingtalk-bot-sender/assets/pic-1.png",
            MessageURL: "https://github.com/bob-zou",
        },
    },
})

example

Reference

https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq

License

MIT

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL