dingtalk

package module
v0.0.0-...-e3534c8 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2017 License: MIT Imports: 6 Imported by: 43

README

非官方 Dingtalk webhook Golang SDK

此工程仅封装了 Dingtalk 的 webhook 部分的请求

使用

首先在dingtalk中创建一个机器人,将accessToken拷贝出来,然后执行下面方法即可

webhook := dingtalk.Webhook(accessToken)
webhook.SendTextMsg("这是一个没有AT的文本消息", false)

License

This project is licensed under the MIT License. See the LICENSE file for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionCard

type ActionCard struct {
	Text           string `json:"text"`
	Title          string `json:"title"`
	HideAvatar     string `json:"hideAvatar"`
	BtnOrientation string `json:"btnOrientation"`
	SingleTitle    string `json:"singleTitle"`
	SingleURL      string `json:"singleURL"`
	Buttons        []struct {
		Title     string `json:"title"`
		ActionURL string `json:"actionURL"`
	} `json:"btns"`
}

type LinkMsg

type LinkMsg struct {
	Title      string `json:"title"`
	MessageURL string `json:"messageURL"`
	PicURL     string `json:"picURL"`
}

type Payload

type Payload struct {
	MsgType string `json:"msgtype"`
	Text    struct {
		Content string `json:"content"`
	} `json:"text"`
	Link struct {
		Text       string `json:"text"`
		Title      string `json:"title"`
		PicURL     string `json:"picUrl"`
		MessageURL string `json:"messageUrl"`
	} `json:"link"`
	Markdown struct {
		Text  string `json:"text"`
		Title string `json:"title"`
	} `json:"markdown"`
	ActionCard ActionCard `json:"actionCard"`
	FeedCard   struct {
		Links []LinkMsg `json:"links"`
	} `json:"feedCard"`
	At struct {
		AtMobiles []string `json:"atMobiles"`
		IsAtAll   bool     `json:"isAtAll"`
	} `json:"at"`
}

Payload struct

type Response

type Response struct {
	ErrorCode    int    `json:"errcode"`
	ErrorMessage string `json:"errmsg"`
}

type Webhook

type Webhook struct {
	// contains filtered or unexported fields
}

func NewWebhook

func NewWebhook(accessToken string) *Webhook

func (*Webhook) SendActionCardMsg

func (w *Webhook) SendActionCardMsg(title, content string, linkTitles, linkURLs []string, hideAvatar, btnOrientation bool) error

SendActionCardMsg 独立跳转ActionCard类型

func (*Webhook) SendLinkCardMsg

func (w *Webhook) SendLinkCardMsg(msgs []LinkMsg) error

SendLinkCardMsg 发送链接消息

func (*Webhook) SendLinkMsg

func (w *Webhook) SendLinkMsg(title, content, picURL, msgURL string) error

SendLinkMsg 发送链接消息

func (*Webhook) SendMarkdownMsg

func (w *Webhook) SendMarkdownMsg(title, content string, isAtAll bool, mobiles ...string) error

SendMarkdownMsg 发送markdown消息,仅支持以下格式

标题 # 一级标题 ## 二级标题 ### 三级标题 #### 四级标题 ##### 五级标题 ###### 六级标题

引用 > A man who stands for nothing will fall for anything.

文字加粗、斜体 **bold** *italic*

链接 [this is a link](http://name.com)

图片 ![](http://name.com/pic.jpg)

无序列表 - item1 - item2

有序列表 1. item1 2. item2

func (*Webhook) SendPayload

func (w *Webhook) SendPayload(payload *Payload) error

SendPayload 发送消息

func (*Webhook) SendSingleActionCardMsg

func (w *Webhook) SendSingleActionCardMsg(title, content, linkTitle, linkURL string, hideAvatar, btnOrientation bool) error

SendSingleActionCardMsg 发送整体跳转ActionCard类型消息

func (*Webhook) SendTextMsg

func (w *Webhook) SendTextMsg(content string, isAtAll bool, mobiles ...string) error

SendTextMsg 发送文本消息

Jump to

Keyboard shortcuts

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