dingtalk

package
v0.0.0-...-98ad1ef Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMessage

func NewMessage(content Content, opts ...MessageOption) reporter.Message

func NewReporter

func NewReporter(endpoint string, opts ...Option) reporter.Reporter
Example
reporter := NewReporter(
	"https://oapi.dingtalk.com/robot/send?access_token=xxx",
	Secret("xxx"),
)
if err := reporter.Report(context.Background(), NewMessage(
	NewText("我就是我, @XXX 是不一样的烟火"),
	AtAll(),
)); err != nil {
	log.Fatalf("report the message error: %s", err)
}
Output:

Types

type Content

type Content interface {
	Type() string
	Body() interface{}
}
func NewLink(title, text, MessageUrl string, picUrl ...string) Content

func NewMarkdown

func NewMarkdown(title string, text string) Content
Example
reporter := NewReporter(
	"https://oapi.dingtalk.com/robot/send?access_token=xxx",
	Secret("xxx"),
)
if err := reporter.Report(context.Background(), NewMessage(
	NewMarkdown("title", `# title
> references
`),
)); err != nil {
	log.Fatalf("report the message error: %s", err)
}
Output:

func NewText

func NewText(content string) Content

type MessageOption

type MessageOption func(o *MessageOptions)

func AtAll

func AtAll() MessageOption

func AtMobiles

func AtMobiles(mobiles ...string) MessageOption

func AtUserIds

func AtUserIds(userIds ...string) MessageOption

type MessageOptions

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

type Option

type Option func(o *Options)

func Client

func Client(c *http.Client) Option

func Secret

func Secret(s string) Option

type Options

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

type Response

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

func (*Response) Error

func (e *Response) Error() string

Jump to

Keyboard shortcuts

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