dingdingAlert

package
v0.0.0-...-10721fb Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeText       MessageType = "text"
	TypeLink       MessageType = "link"
	TypeMarkdown   MessageType = "markdown"
	TypeActionCard MessageType = "actionCard"
	TypeFeedCard   MessageType = "feedCard"

	OrientationVertical Orientation = "0"
	OrientationHorizon  Orientation = "1"

	ShowAvatar AvatarState = "0"
	HideAvatar AvatarState = "1"
)
View Source
const BaseSendURL = "https://oapi.dingtalk.com/robot/send?access_token={ACCESS_TOKEN}"
View Source
const JSONType = "application/json"

Variables

This section is empty.

Functions

func NewActionCardBuilder

func NewActionCardBuilder(title string, text string, buttonOrientation Orientation, avatarState AvatarState) *actionCardBuilder

func NewFeedCardBuilder

func NewFeedCardBuilder() *feedCardBuilder

Types

type ActionCardElement

type ActionCardElement struct {
	Title             string          `json:"title"`
	Text              string          `json:"text"`
	SingleTitle       string          `json:"singleTitle"`
	SingleURL         string          `json:"singleURL"`
	ButtonOrientation Orientation     `json:"btnOrientation"`
	Avatar            AvatarState     `json:"hideAvatar"`
	Buttons           []ButtonElement `json:"btns"`
}

ActionCardElement ActionCard元素

type AtElement

type AtElement struct {
	AtMobiles []string `json:"atMobiles"`
	IsAtAll   bool     `json:"isAtAll"`
}

type AvatarState

type AvatarState string

type ButtonElement

type ButtonElement struct {
	Title     string `json:"title"`
	ActionURL string `json:"actionURL"`
}

ButtonElement 按钮元素

type DingMessage

type DingMessage struct {
	Type       MessageType       `json:"msgtype"`
	Text       TextElement       `json:"text"`
	Link       LinkElement       `json:"link"`
	Markdown   MarkdownElement   `json:"markdown"`
	ActionCard ActionCardElement `json:"actionCard"`
	FeedCard   FeedCardElement   `json:"feedCard"`
	At         AtElement         `json:"at"`
}

DingMessage 钉钉机器人消息

type DingRobot

type DingRobot struct {
	AccessToken string
	SendURL     string
}

func NewRobot

func NewRobot(accessToken string) *DingRobot

func (DingRobot) SendMessage

func (dr DingRobot) SendMessage(msg DingMessage) error

type FeedCardElement

type FeedCardElement struct {
	Links []FeedLinkElement `json:"links"`
}

FeedCardElement 图文元素

type FeedLinkElement

type FeedLinkElement struct {
	Title      string `json:"title"`      // 消息标题
	Text       string `json:"text"`       // 消息内容。如果太长只会部分展示
	MessageURL string `json:"messageURL"` // 点击消息跳转的URL
	PictureURL string `json:"picURL"`     // 图片URL
}

LinkElement 链接元素

type LinkElement

type LinkElement struct {
	Title      string `json:"title"`      // 消息标题
	Text       string `json:"text"`       // 消息内容。如果太长只会部分展示
	MessageURL string `json:"messageUrl"` // 点击消息跳转的URL
	PictureURL string `json:"picUrl"`     // 图片URL
}

LinkElement 链接元素

type MarkdownElement

type MarkdownElement struct {
	Title string `json:"title"` // 首屏会话透出的展示内容
	Text  string `json:"text"`  // markdown格式的消息
}

MarkdownElement Markdown元素

type MessageBuilder

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

func NewMessageBuilder

func NewMessageBuilder(msgType MessageType) *MessageBuilder

func (*MessageBuilder) ActionCard

func (builder *MessageBuilder) ActionCard(element ActionCardElement) *MessageBuilder

func (*MessageBuilder) At

func (builder *MessageBuilder) At(mobiles []string, isAtAll bool) *MessageBuilder

func (*MessageBuilder) Build

func (builder *MessageBuilder) Build() DingMessage

func (*MessageBuilder) FeedCard

func (builder *MessageBuilder) FeedCard(element FeedCardElement) *MessageBuilder
func (builder *MessageBuilder) Link(title string, text string, messageURL string, pictureURL string) *MessageBuilder

func (*MessageBuilder) Markdown

func (builder *MessageBuilder) Markdown(title string, text string) *MessageBuilder

func (*MessageBuilder) Text

func (builder *MessageBuilder) Text(text string) *MessageBuilder

type MessageType

type MessageType string

type Orientation

type Orientation string

type TextElement

type TextElement struct {
	Content string `json:"content"`
}

TextElement 文本元素

Jump to

Keyboard shortcuts

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