Code Monkey home page Code Monkey logo

dingtalk-bot-sender's Introduction

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

SendLink

_ = 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

dingtalk-bot-sender's People

Contributors

fanwenlin avatar zouyapeng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.