webhook

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: MIT Imports: 12 Imported by: 0

README

DingTalk WebHook Golang SDK (Unofficial)

Build Status codecov

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionCard

type ActionCard struct {
	Title          string `json:"title"`          // 首屏会话透出的展示内容
	Test           string `json:"test"`           // markdown格式的消息
	BtnOrientation string `json:"btnOrientation"` // 0-按钮竖直排列,1-按钮横向排列
	SingleTitle    string `json:"singleTitle"`    // 单个按钮的方案。(设置此项和singleURL后btns无效)
	SingleURL      string `json:"singleURL"`      // 点击singleTitle按钮触发的URL
	Btns           []struct {
		Title     string `json:"title"`
		ActionURL string `json:"actionURL"`
	} `json:"btns"`
}
type Links struct {
	Title      string `json:"title"`      // 单条信息文本
	MessageURL string `json:"messageURL"` // 点击单条信息到跳转链接
	PicURL     string `json:"picURL"`     // 单条信息后面图片的URL
}

type Payload

type Payload struct {
	MsgType string `json:"msgtype"` // 消息类型: test, markdown, link, actionCard, freeCard
	Test    struct {
		Content string `json:"content"` // 消息内容
	} `json:"test"`
	Makrdown struct {
		Title string `json:"title"` // 首屏会话透出的展示内容
		Test  string `json:"test"`  // markdown格式的消息
	} `json:"makrdown"`
	Link struct {
		Title      string `json:"title"`      // 消息标题
		Test       string `json:"test"`       // 消息内容。如果太长只会部分展示
		MessageURL string `json:"messageUrl"` // 点击消息跳转的URL
		PicURL     string `json:"picUrl"`     // 图片URL
	} `json:"link"`
	ActionCard ActionCard `json:"actionCard"`
	FreeCard   struct {
		Links []Links `json:"links"`
	} `json:"freeCard"`
	At struct {
		AtMobiles []string `json:"atMobiles"` // 被@人的手机号(在text内容里要有@手机号)
		IsAtAll   bool     `json:"isAtAll"`   // @所有人时:true,否则为:false
	} `json:"at"`
}

type Response

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

type Webhook

type Webhook struct {
	AccessToken string `json:"accessToken"`
	APIURL      string `json:"apiurl"`
	Secret      string `json:"secret"`
}

func NewWebhook

func NewWebhook(accessToken string) *Webhook

func (*Webhook) AddSign

func (w *Webhook) AddSign(params map[string](string), originURL string) string

AddSign 添加 params 中的参数到 URL 中

func (*Webhook) Getsign

func (w *Webhook) Getsign() (timestamp, sha string)

GetUrlparameter 把timestamp+"\n"+密钥当做签名字符串, 使用HmacSHA256算法计算签名,然后进行Base64 encode, 最后再把签名参数再进行urlEncode,得到最终的签名(需要使用UTF-8字符集)

func (*Webhook) SendActionCard

func (w *Webhook) SendActionCard(title, content string, linksTitles, linksUrls []string, btnOrienrarion bool) error

SendActionCard 发送独立跳转的消息

func (*Webhook) SendCompleteActionCard

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

SendCompleteActionCard 发送整体跳转的消息

func (*Webhook) SendFreeCardMsg

func (w *Webhook) SendFreeCardMsg(links []Links) error

SendFreeCardMsg 发送链接格式的文本

func (*Webhook) SendLinkMsg

func (w *Webhook) SendLinkMsg(title, content, picurl, messageurl string) error

SendLinkMsg 发送带有文本和链接图片类型的消息

func (*Webhook) SendMakrdownMsg

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

SendMakrdownMsg 发送 Markdown 格式的消息

func (*Webhook) SendPayload

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

func (*Webhook) SendTestMsg

func (w *Webhook) SendTestMsg(content string, isAtlAll bool, mobiles ...string) error

SendTestMsg 发送文本格式的消息

Jump to

Keyboard shortcuts

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