dingtalk

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 8 Imported by: 1

README

dingtalk

通过钉钉群组机器人发送消息。

Documentation

Index

Constants

View Source
const (
	MsgTypeText       = "text"
	MsgTypeMarkdown   = "markdown"
	MsgTypeLink       = "link"
	MsgTypeFeedCard   = "feedcard"
	MsgTypeActionCard = "actioncard"
)
View Source
const ChannelTypeDingtalk = "dingtalk"

Variables

View Source
var SupportedMsgtype = make(map[string]bool)

Functions

func SanitizeMarkdown

func SanitizeMarkdown(content string) string

func ValidMsgtype

func ValidMsgtype(msgtype string) bool

Types

type ActionCard

type ActionCard struct {
	Title          string `json:"title"`          // seems no meaning now
	Text           string `json:"text"`           // support markdown format
	Btnorientation string `json:"btnOrientation"` // 0:按钮竖直排列, 1:按钮横向排列
	Hideavatar     string `json:"hideAvatar,omitempty"`

	Singletitle string `json:"singleTitle,omitempty"`
	Singleurl   string `json:"singleURL,omitempty"`

	Btns []*Btn `json:"btns,omitempty"`
}

func NewActionCard

func NewActionCard(title string, text string, horizonBtn bool, btns []*Btn) *ActionCard

type At

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

type Btn

type Btn struct {
	Title     string `json:"title"`
	Actionurl string `json:"actionURL"`
}

func NewBtn

func NewBtn(title, url string) *Btn

type DingtalkGroupBot

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

DingtalkBot can send messages to dingtalk group ref: https://developers.dingtalk.com/document/app/custom-robot-access/title-72m-8ag-pqw

func NewDingtalkGroupBot

func NewDingtalkGroupBot(access_token string) *DingtalkGroupBot

func (*DingtalkGroupBot) Addr

func (bot *DingtalkGroupBot) Addr() string

func (*DingtalkGroupBot) AddrForUpload

func (bot *DingtalkGroupBot) AddrForUpload() string

func (*DingtalkGroupBot) SendAs

func (bot *DingtalkGroupBot) SendAs(m *models.Payload, msgType string) error

func (*DingtalkGroupBot) SendText

func (bot *DingtalkGroupBot) SendText(content string, atMobiles []string, atAll bool) error

func (*DingtalkGroupBot) UploadFile

func (bot *DingtalkGroupBot) UploadFile(filename string, fileReader io.Reader) (meidaID string, err error)

type FeedCard

type FeedCard struct {
	Links []*FeedCardLink `json:"links"`
}

func NewFeedCard

func NewFeedCard(links []*FeedCardLink) *FeedCard
type FeedCardLink struct {
	Title      string `json:"title"`
	MessageURL string `json:"messageURL"`
	PicURL     string `json:"picURL"`
}
func NewFeedCardLink(title, messageURl, picURL string) *FeedCardLink
type Link struct {
	Text       string `json:"text"`
	Title      string `json:"title"`
	PicURL     string `json:"picUrl"`
	MessageURL string `json:"messageUrl"`
}
func NewLink(title string, text string, messageURL string) *Link

func (*Link) WithPicURL

func (link *Link) WithPicURL(picURL string) *Link

type Markdown

type Markdown struct {
	Title string `json:"title"`
	Text  string `json:"text"`
}

func NewMarkdown

func NewMarkdown(title string, text string) *Markdown

func (*Markdown) Valid

func (md *Markdown) Valid() bool

type Msg

type Msg struct {
	MsgType    string      `json:"msgtype"`
	Text       *Text       `json:"text,omitempty"`
	Link       *Link       `json:"link,omitempty"`
	Markdown   *Markdown   `json:"markdown,omitempty"`
	ActionCard *ActionCard `json:"actionCard,omitempty"`
	FeedCard   *FeedCard   `json:"feedCard,omitempty"`
	At         *At         `json:"at,omitempty"` // only available for text and markdown type
}

func NewMsgActionCard

func NewMsgActionCard(actionCard *ActionCard) *Msg

func NewMsgActionCardFromPayload

func NewMsgActionCardFromPayload(p *models.Payload) *Msg

func NewMsgFeedCard

func NewMsgFeedCard(feedCard *FeedCard) *Msg

func NewMsgFeedCardFromPayload

func NewMsgFeedCardFromPayload(payload *models.Payload) *Msg
func NewMsgLink(link *Link) *Msg

func NewMsgLinkFromPayload

func NewMsgLinkFromPayload(payload *models.Payload) *Msg

func NewMsgMarkdown

func NewMsgMarkdown(md *Markdown) *Msg

func NewMsgMarkdownFromPayload

func NewMsgMarkdownFromPayload(payload *models.Payload) *Msg

func NewMsgText

func NewMsgText(text *Text) *Msg

func NewMsgTextFromPayload

func NewMsgTextFromPayload(payload *models.Payload) *Msg

func (*Msg) SupportAt

func (msg *Msg) SupportAt() bool

func (*Msg) WithAt

func (msg *Msg) WithAt(at *At) *Msg

func (*Msg) WithAtAll

func (msg *Msg) WithAtAll(atAll bool) *Msg

func (*Msg) WithAtMobiles

func (msg *Msg) WithAtMobiles(mobiles []string) *Msg

type Sender

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

func NewSender

func NewSender(token string, msgType string) *Sender

func (*Sender) Send

func (s *Sender) Send(payload *models.Payload) error

type Text

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

func NewText

func NewText(content string) *Text

Jump to

Keyboard shortcuts

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