Help us shape the future of Go! Take the 2026 Go Developer Survey

dingbot

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: MIT Imports: 4 Imported by: 0

README

DingBot

logo

Bot for DingTalk (钉钉).

Features

Documentation

Index

Constants

View Source
const (
	MsgTypeText       = "text"
	MsgTypeLink       = "link"
	MsgTypeMd         = "markdown"
	MsgTypeActionCard = "actionCard"
	MsgTypeFeedCard   = "feedCard"
)

exported message types see https://open-doc.dingtalk.com/docs/doc.htm

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionCardMsg

type ActionCardMsg struct {
	Text           string `json:"text"`
	Title          string `json:"title"`
	HideAvatar     string `json:"hideAvatar"`     // "0" or "1"
	BtnOrientation string `json:"btnOrientation"` // "0" or "1"
	// single card
	SingleTitle string `json:"singleTitle"`
	SingleURL   string `json:"singleURL"`
	// independent cards
	Btns []struct {
		Title     string `json:"title"`
		ActionURL string `json:"actionURL"`
	} `json:"btns"`
}

ActionCardMsg represents a action card.

type AtOption

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

AtOption is the option for @someone.

type BotOption

type BotOption func(*dingBot)

BotOption follows the functional option pattern.

func WithClient

func WithClient(cl web.Client) BotOption

WithClient makes the bot use a custom http client.

type DingMessage

type DingMessage struct {
	Msgtype    string        `json:"msgtype"`
	Text       TextMsg       `json:"text,omitempty"`
	Link       LinkMsg       `json:"link,omitempty"`
	Markdown   MdMsg         `json:"markdown,omitempty"`
	ActionCard ActionCardMsg `json:"actionCard,omitempty"`
	FeedCard   FeedCardMsg   `json:"feedCard,omitempty"`
	At         AtOption      `json:"at,omitempty"`
}

DingMessage is the JSON-encoded message to send.

type DingResponse

type DingResponse struct {
	Errmsg  string `json:"errmsg"`
	Errcode int    `json:"errcode"`
}

DingResponse is the response for sending msg.

type FeedCardMsg

type FeedCardMsg struct {
	Links []FeedLink `json:"links"`
}

FeedCardMsg represents a feed card.

type FeedLink struct {
	Title      string `json:"title"`
	PicURL     string `json:"picUrl"`
	MessageURL string `json:"messageUrl"`
}

FeedLink represents a feed.

type LinkMsg

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

LinkMsg represents a link.

type MdMsg

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

MdMsg represents markdown formatted text.

type SenderBot

type SenderBot interface {
	Send(interface{}) error
}

SenderBot sends various message types to the Dingtalk webhook.

func NewDingBot

func NewDingBot(token string, ops ...BotOption) SenderBot

NewDingBot returns a functional SenderBot with the provided token.

type TextMsg

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

TextMsg represents text.

Jump to

Keyboard shortcuts

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