GithubHelp home page GithubHelp logo

heelie / dingtalk-notify-go-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jetblink/dingtalk-notify-go-sdk

0.0 0.0 0.0 8 KB

钉钉机器人通知(支持加签,带签名 秘钥). dingtalk robot notification golang sdk.

Go 100.00%

dingtalk-notify-go-sdk's Introduction

DingTalk Notify

钉钉机器人通知(支持加签)。dingtalk robot notification sdk.

Overview

Installation

go get github.com/JetBlink/dingtalk-notify-go-sdk

Run Test

  • 不带签名机器人
ROBOT_TOKEN=your_robot_token go test
  • 带签名的机器人
ROBOT_TOKEN=your_robot_token ROBOT_SECRET=your_robot_secret go test

Usage

获取实例

import (
  dingtalk_robot "github.com/JetBlink/dingtalk-notify-go-sdk"
)

func main() {
  robot := dingtalk_robot.NewRobot("your robot token", "your robot secret")
}

发送消息

发送原始消息

msg := map[string]interface{}{
	"msgtype": "text",
	"text": map[string]string{
		"content": "这是一条golang钉钉消息测试.",
	},
	"at": map[string]interface{}{
		"atMobiles": []string{},
		"isAtAll":   false,
	},
}

robot := dingtalk_robot.NewRobot(os.Getenv("ROBOT_TOKEN"), os.Getenv("ROBOT_SECRET"))
if err := robot.SendMessage(msg); err != nil {
	t.Error(err)
}

发送文本消息

robot.SendTextMessage("普通文本消息", []string{}, false)

发送Markdown消息

robot.SendMarkdownMessage(
	"Markdown Test Title",
	"### Markdown 测试消息\n* 谷歌: [Google](https://www.google.com/)\n* 一张图片\n ![](https://avatars0.githubusercontent.com/u/40748346)",
	[]string{},
	false,
)

发送链接消息

robot.SendLinkMessage(
	"Link Test Title",
	"这是一条链接测试消息",
	"https://github.com/JetBlink",
	"https://avatars0.githubusercontent.com/u/40748346",
)

Tips

文本消息和Markdown消息都支持**@指定手机号@所有人**,参数位置见具体方法

官方文档

每个机器人每分钟最多发送20条

License

MIT

dingtalk-notify-go-sdk's People

Contributors

sh7ning 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.