dingbot

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MediaTypeImage string = "image"
	MediaTypeVoice string = "voice"
	MediaTypeVideo string = "video"
	MediaTypeFile  string = "file"
)

OpenAPI doc: https://open.dingtalk.com/document/isvapp/upload-media-files

View Source
const (
	MimeTypeImagePng string = "image/png"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type At

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

at 内容

type DingTalkClient added in v1.0.20

type DingTalkClient struct {
	Credential  config.Credential
	AccessToken string
	// contains filtered or unexported fields
}

func NewDingTalkClient added in v1.0.20

func NewDingTalkClient(credential config.Credential) *DingTalkClient

func (*DingTalkClient) GetAccessToken added in v1.0.20

func (c *DingTalkClient) GetAccessToken() (string, error)

func (*DingTalkClient) UploadMedia added in v1.0.20

func (c *DingTalkClient) UploadMedia(content []byte, filename, mediaType, mimeType string) (*MediaUploadResult, error)

type DingTalkClientInterface added in v1.0.20

type DingTalkClientInterface interface {
	GetAccessToken() (string, error)
	UploadMedia(content []byte, filename, mediaType, mimeType string) (*MediaUploadResult, error)
}

type DingTalkClientManager added in v1.0.20

type DingTalkClientManager struct {
	Credentials []config.Credential
	Clients     map[string]*DingTalkClient
	// contains filtered or unexported fields
}

func NewDingTalkClientManager added in v1.0.20

func NewDingTalkClientManager(conf *config.Configuration) *DingTalkClientManager

func (*DingTalkClientManager) GetClientByOAuthClientID added in v1.0.20

func (m *DingTalkClientManager) GetClientByOAuthClientID(clientId string) DingTalkClientInterface

type DingTalkClientManagerInterface added in v1.0.20

type DingTalkClientManagerInterface interface {
	GetClientByOAuthClientID(clientId string) DingTalkClientInterface
}

type MarkDown

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

MarkDown 消息内容

type MarkDownMessage

type MarkDownMessage struct {
	MsgType  MsgType   `json:"msgtype"`
	At       *At       `json:"at"`
	MarkDown *MarkDown `json:"markdown"`
}

MarkDown 消息

type MediaUploadResult added in v1.0.20

type MediaUploadResult struct {
	ErrorCode    int64  `json:"errcode"`
	ErrorMessage string `json:"errmsg"`
	MediaID      string `json:"media_id"`
	CreatedAt    int64  `json:"created_at"`
	Type         string `json:"type"`
}

type MsgType

type MsgType string

消息类型

const MARKDOWN MsgType = "markdown"
const TEXT MsgType = "text"

type OAuthTokenResult added in v1.0.20

type OAuthTokenResult struct {
	ErrorCode    int    `json:"errcode"`
	ErrorMessage string `json:"errmsg"`
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
}

type ReceiveMsg

type ReceiveMsg struct {
	ConversationID string `json:"conversationId"`
	AtUsers        []struct {
		DingtalkID string `json:"dingtalkId"`
	} `json:"atUsers"`
	ChatbotUserID             string  `json:"chatbotUserId"`
	MsgID                     string  `json:"msgId"`
	SenderNick                string  `json:"senderNick"`
	IsAdmin                   bool    `json:"isAdmin"`
	SenderStaffId             string  `json:"senderStaffId"`
	SessionWebhookExpiredTime int64   `json:"sessionWebhookExpiredTime"`
	CreateAt                  int64   `json:"createAt"`
	ConversationType          string  `json:"conversationType"`
	SenderID                  string  `json:"senderId"`
	ConversationTitle         string  `json:"conversationTitle"`
	IsInAtList                bool    `json:"isInAtList"`
	SessionWebhook            string  `json:"sessionWebhook"`
	Text                      Text    `json:"text"`
	RobotCode                 string  `json:"robotCode"`
	Msgtype                   MsgType `json:"msgtype"`
}

接收的消息体

func (ReceiveMsg) GetChatTitle added in v1.0.7

func (r ReceiveMsg) GetChatTitle() (chatType string)

GetChatTitle 获取聊天的群名字,如果是私聊,则命名为 昵称_私聊

func (ReceiveMsg) GetSenderIdentifier added in v1.0.7

func (r ReceiveMsg) GetSenderIdentifier() (uid string)

获取用户标识,兼容当 SenderStaffId 字段为空的场景,此处提供给发送消息是艾特使用

func (ReceiveMsg) ReplyToDingtalk

func (r ReceiveMsg) ReplyToDingtalk(msgType, msg string) (statuscode int, err error)

发消息给钉钉

type Text

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

Text 消息内容

type TextMessage

type TextMessage struct {
	MsgType MsgType `json:"msgtype"`
	At      *At     `json:"at"`
	Text    *Text   `json:"text"`
}

Text 消息

Jump to

Keyboard shortcuts

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