dingtalk

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

README

dingtalk

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

Documentation

Index

Constants

View Source
const (
	ChannelTypeDingtalk string = "dingtalk"

	MsgTypeActionCard string = "actioncard"
	MsgTypeFeedCard   string = "feedcard"
	MsgTypeLink       string = "link"
	MsgTypeMarkdown   string = "markdown"
	MsgTypeText       string = "text"
)

Variables

View Source
var Payload2MsgFnMap = make(map[string]Payload2MsgFn)

Functions

func NewSender

func NewSender(token string, msgType string) models.Sender

func SanitizeMarkdown

func SanitizeMarkdown(content string) string

func ValidMsg added in v0.1.0

func ValidMsg(msgType string, msg *Msg) error

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/message-types-and-data-format

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) Send added in v0.1.0

func (bot *DingtalkGroupBot) Send(msg *Msg) 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 Payload2MsgFn added in v0.1.0

type Payload2MsgFn func(payload *models.Payload) *Msg

type Sender

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

func (*Sender) Send

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

func (*Sender) SendMsg added in v0.1.0

func (s *Sender) SendMsg(msgSource interface{}) error

func (*Sender) SendMsgT added in v0.1.0

func (s *Sender) SendMsgT(msgType string, msgSource interface{}) 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