ddsender

package module
v0.0.0-...-32d94ec Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeFormat    = errors.New("格式不正确,例: 2021-11-16T16:20:49+08:00 ~ 2021-11-16T16:20:49+08:00")
	ErrIgnoreMessage = errors.New("message are ignored")
)

Functions

This section is empty.

Types

type ActionCardType

type ActionCardType struct {
	Title          string `json:"title"`
	Text           string `json:"text"`
	SingleTitle    string `json:"singleTitle"`
	SingleURL      string `json:"singleURL"`
	BtnOrientation string `json:"btnOrientation"`
	Btns           `json:"btns"`
	HideAvatar     string `json:"hideAvatar"`
}

type AtType

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

type Btns

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

type FeedCardType

type FeedCardType struct {
	Links []LinkType `json:"links"`
}

type IgnoreMessageType

type IgnoreMessageType struct {
	MessageHash []string
	Time        string
}

type LimitSenderType

type LimitSenderType struct {
	SenderType
	// 发送钉钉的间隔时间
	Interval time.Duration
	// 在 Interval 内总共发送多少次
	Limit int
	// 忽略的消息列表
	Ignore []IgnoreMessageType
}

func NewLimitSender

func NewLimitSender(token, secret string, limit int, duration time.Duration, ignores []IgnoreMessageType) *LimitSenderType

func (*LimitSenderType) LimitSender

func (c *LimitSenderType) LimitSender(Title, Msg string) error

type LinkType

type LinkType struct {
	Title      string `json:"title"`
	Text       string `json:"text"`
	PicURL     string `json:"picUrl"`
	MessageURL string `json:"messageUrl"`
}

type MarkdownType

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

type Message

type Message struct {
	MsgType    MessageType    `json:"msgtype"`
	Markdown   MarkdownType   `json:"markdown,omitempty"`
	Text       TextType       `json:"text,omitempty"`
	At         AtType         `json:"at,omitempty"`
	ActionCard ActionCardType `json:"actionCard,omitempty"`
	Link       LinkType       `json:"link,omitempty"`
	FeedCard   FeedCardType   `json:"feedCard,omitempty"`
}

type MessageType

type MessageType string
const (
	Text       MessageType = "text"
	Link       MessageType = "link"
	Markdown   MessageType = "markdown"
	ActionCard MessageType = "actionCard"
	FeedCard   MessageType = "feedCard"
)

type Response

type Response struct {
	Errcode int32  `json:"errcode"`
	Errmsg  string `json:"errmsg"`
}

type SenderType

type SenderType struct {
	// dingTalk 群机器人token
	Token string
	// dingTalk 群机器人secret
	Secret string
}

func NewSender

func NewSender(token, secret string) *SenderType

func (*SenderType) MarkdownSender

func (c *SenderType) MarkdownSender(Title, Msg string, atUser []string, atAll bool) error

func (*SenderType) Sender

func (c *SenderType) Sender(Msg *Message) error

type TextType

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

Jump to

Keyboard shortcuts

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