dingtalkalerter

package module
v0.0.0-...-c8ffe2f Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

dingtalkalerter

A dingtalk robot alerter

Documentation

Index

Constants

View Source
const (
	DefaultDingHost   = "https://oapi.dingtalk.com"
	DefaultDingUrl    = "/robot/send"
	DefaultDingToken  = "76f509430610108713fc835cf6e4cd460856c2e8d49f75e9e31bd04796be5f21"
	DefaultDingSecret = "SECed7b62be679450c4484799ea52d8cea2304e0b3b94b0618c0d587d45dd1f2c24"
	DefaultLevel      = 0
)

Variables

View Source
var Client *client

Functions

func New

func New() alerter.Alerter

func NewClient

func NewClient(opts *Options)

func NewWithOptions

func NewWithOptions(opts *Options) alerter.Alerter

Types

type ActionCard

type ActionCard struct {
	Title          string                `json:"title,omitempty"`
	Text           string                `json:"text,omitempty"`
	BtnOrientation ButtonOrientationType `json:"btnOrientation,omitempty"`
	SingleTitle    string                `json:"singleTitle,omitempty"`
	SingleURL      string                `json:"singleURL,omitempty"`
	Buttons        []Button              `json:"btns,omitempty"`
}

type At

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

type AtOption

type AtOption interface {
	// contains filtered or unexported methods
}

func WithAtAll

func WithAtAll() AtOption

func WithAtMobiles

func WithAtMobiles(mobiles []string) AtOption

func WithAtUsers

func WithAtUsers(users []string) AtOption

type Button

type Button struct {
	Title     string `json:"title,omitempty"`
	ActionURL string `json:"actionURL,omitempty"`
}

type ButtonOrientationType

type ButtonOrientationType string
const (
	HORIZONTAL ButtonOrientationType = "0" // 横向
	VERTICAL   ButtonOrientationType = "1" // 竖向
)

type Content

type Content struct {
	Type       MsgType     `json:"msgtype"`
	Text       *Text       `json:"text,omitempty"`
	Markdown   *Markdown   `json:"markdown,omitempty"`
	Link       *Link       `json:"link,omitempty"`
	ActionCard *ActionCard `json:"actionCard,omitempty"`
	FeedCard   *FeedCard   `json:"feedCard,omitempty"`
	At         *At         `json:"at,omitempty"`
}
func NewLink(title, text, picUrl, msgUrl string) *Content

func NewMarkDown

func NewMarkDown(title, text string, opts ...AtOption) *Content

func NewText

func NewText(data string, opts ...AtOption) *Content

type FeedCard

type FeedCard struct {
	Links []FeedCardLink `json:"links,omitempty"`
}
type FeedCardLink struct {
	Title      string `json:"title,omitempty"`
	MessageURL string `json:"messageURL,omitempty"`
	PicURL     string `json:"picURL,omitempty"`
}
type Link struct {
	Text       string `json:"text,omitempty"`
	Title      string `json:"title,omitempty"`
	PicUrl     string `json:"picUrl,omitempty"`
	MessageUrl string `json:"messageUrl,omitempty"`
}

type Markdown

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

type MsgType

type MsgType string
const (
	TEXT        MsgType = "text"
	LINK        MsgType = "link"
	MARKDOWN    MsgType = "markdown"
	ACTION_CARD MsgType = "actionCard"
	FEED_CARD   MsgType = "feedCard"
)

type Options

type Options struct {
	Host   string `json:"host,omitempty"`
	Url    string `json:"url,omitempty"`
	Token  string `json:"token,omitempty"`
	Secret string `json:"secret,omitempty"`
	Level  int    `json:"level,omitempty"`
}

func NewOptions

func NewOptions() *Options

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

type ResponseMsg

type ResponseMsg struct {
	ErrCode int    `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

type Text

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

Jump to

Keyboard shortcuts

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