dinghook

package
v0.0.0-...-e3ac1fa Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MsgTypeText "text"
	MsgTypeText = "text"
	// MsgTypeLink "link"
	MsgTypeLink = "link"
	// MsgTypeMarkdown "markdown"
	MsgTypeMarkdown = "markdown"
)
View Source
const (
	// DingAPIURL api 地址
	DingAPIURL = `https://oapi.dingtalk.com/robot/send?access_token=`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Ding

type Ding struct {
	AccessToken string // token
}

Ding 钉钉消息发送实体

func (Ding) Send

func (ding Ding) Send(message interface{}) Result

Send 发送消息

type DingQueue

type DingQueue struct {
	AccessToken string

	Interval uint   // 发送间隔s,最小为1
	Limit    uint   // 每次发送消息限制,0 无限制,到达时间则发送队列所有消息,大于1则到时间发送最大Limit数量的消息
	Title    string // 摘要
	// contains filtered or unexported fields
}

DingQueue 用queue 方式发送消息 会发送 markdown 类型消息

func (*DingQueue) Init

func (ding *DingQueue) Init()

Init 初始化 DingQueue

func (*DingQueue) Push

func (ding *DingQueue) Push(message string)

Push push 消息到队列

func (*DingQueue) PushMessage

func (ding *DingQueue) PushMessage(m SimpleMessage)

PushMessage push 消息到队列

func (*DingQueue) Start

func (ding *DingQueue) Start()

Start 开始工作

type Link struct {
	Content    string `json:"text" validate:"required"`       // 要发送的消息, 必填
	Title      string `json:"title" validate:"required"`      // 标题, 必填
	ContentURL string `json:"messageUrl" validate:"required"` // 点击消息跳转的URL 必填
	PictureURL string `json:"picUrl"`                         // 图片 url
}

Link 链接消息

type Markdown

type Markdown struct {
	Content string `json:"text" validate:"required"`  // 要发送的消息, 必填
	Title   string `json:"title" validate:"required"` // 标题, 必填
}

Markdown markdown 类型

type Message

type Message struct {
	Content   string `validate:"required"`
	AtPersion []string
	AtAll     bool
}

Message 普通消息

type Result

type Result struct {
	Success bool
	// ErrMsg 错误信息
	ErrMsg string `json:"errmsg"`
	// 错误码
	ErrCode int `json:"errcode"`
}

Result 发送结果 Success true 成功,否则失败 ErrMsg 错误信息,如果是钉钉接口错误,会返回钉钉的错误信息,否则返回内部err信息 ErrCode 钉钉返回的错误码

type SimpleMessage

type SimpleMessage struct {
	Content string
	Title   string
}

SimpleMessage push message

Jump to

Keyboard shortcuts

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