wechat

package
v0.0.0-...-9e28022 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WxWorkAppMessageTypeText     = "text"
	WxWorkAppMessageTypeImage    = "image"
	WxWorkAppMessageTypeVoice    = "voice"
	WxWorkAppMessageTypeVideo    = "video"
	WxWorkAppMessageTypeFile     = "file"
	WxWorkAppMessageTypeTextCard = "textcard"
	WxWorkAppMessageTypeNews     = "news"
	WxWorkAppMessageTypeMpNews   = "mpnews"
	WxWorkAppMessageTypeMarkdown = "markdown"
	// The following two message type are only supported by simple message
	WxWorkAppMessageTypeMiniProgramNotice = "miniprogram_notice"
	WxWorkAppMessageTypeTaskCard          = "taskcard"
)
View Source
const (
	WxWorkAppMediaTypeImage = "image"
	WxWorkAppMediaTypeVoice = "voice"
	WxWorkAppMediaTypeVideo = "video"
	WxWorkAppMediaTypeFile  = "file"
)
View Source
const (
	WxWorkRobotMessageTypeText     = "text"
	WxWorkRobotMessageTypeMarkdown = "markdown"
	WxWorkRobotMessageTypeImage    = "image"
	WxWorkRobotMessageTypeNews     = "news"
	WxWorkRobotMessageTypeFile     = "file"
)
View Source
const WxWorkAppCreateGroupAPI = "https://qyapi.weixin.qq.com/cgi-bin/appchat/create"

WxWorkAppCreateGroupAPI is the api to create the wxwork group

View Source
const WxWorkAppGetGroupAPI = "https://qyapi.weixin.qq.com/cgi-bin/appchat/get"

WxWorkAppGetGroupAPI is the api to get the wxwork group

View Source
const WxWorkAppGroupMessageAPI = "https://qyapi.weixin.qq.com/cgi-bin/appchat/send"

WxWorkAppGroupMessageAPI is the api to send messages to wxwork group

View Source
const WxWorkAppMessageAPI = "https://qyapi.weixin.qq.com/cgi-bin/message/send"

WxWorkAppMessageAPI is the api to send messages to wxwork user/party/tag

View Source
const WxWorkAppStatusOK = 0

WxWorkAppStatusOK is the ok status of api call

View Source
const WxWorkAppTimeout = time.Second * 10

WxWorkAppTimeout is the wxwork app default timeout

View Source
const WxWorkAppTokenAPI = "https://qyapi.weixin.qq.com/cgi-bin/gettoken"

WxWorkAppGroupMessageAPI is the api to get the app access token

View Source
const WxWorkAppUpdateGroupAPI = "https://qyapi.weixin.qq.com/cgi-bin/appchat/update"

WxWorkAppUpdateGroupAPI is the api to update the wxwork group

View Source
const WxWorkAppUploadImageAPI = "https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg"

WxWorkAppUploadImageAPI is the api to upload the wxwork app image

View Source
const WxWorkAppUploadMediaAPI = "https://qyapi.weixin.qq.com/cgi-bin/media/upload"

WxWorkAppUploadMediaAPI is the api to upload the wxwork app media

View Source
const WxWorkCodeAccessTokenExpired = 42001

See doc https://work.weixin.qq.com/api/doc/90000/90139/90313

View Source
const WxWorkRobotMessageAPI = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send"

WxWorkRobotMessageAPI is the api to send the robot messages

View Source
const WxWorkRobotStatusOK = 0
View Source
const WxWorkRobotTimeout = time.Second * 10

WxWorkRobotTimeout is the wxwork robot default timeout

View Source
const WxWorkRobotUploadFileAPI = "https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media"

WxWorkRobotUploadFileAPI is the api to upload file

Variables

This section is empty.

Functions

This section is empty.

Types

type WxWorkApp

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

func NewWxWorkApp

func NewWxWorkApp(corpID, corpSecret, agentID string) *WxWorkApp

NewWxWorkApp create a new wxwork app

func NewWxWorkAppWithClient

func NewWxWorkAppWithClient(corpID, corpSecret, agentID string, client *http.Client) *WxWorkApp

NewWxWorkAppWithClient create a new wxwork app with http.Client

func NewWxWorkAppWithTimeout

func NewWxWorkAppWithTimeout(corpID, corpSecret, agentID string, timeout time.Duration) *WxWorkApp

NewWxWorkAppWithTimeout create a new wxwork app with timeout

func (*WxWorkApp) CreateGroupChat

func (r *WxWorkApp) CreateGroupChat(name, ownerID string, userIDList []string, options *WxWorkAppCreateGroupOptions) (newChatID string, err error)

CreateGroupChat create a new group chat

func (*WxWorkApp) GetGroupChat

func (r *WxWorkApp) GetGroupChat(chatID string) (group WxWorkAppGroup, err error)

func (*WxWorkApp) IsAccessTokenExpired

func (r *WxWorkApp) IsAccessTokenExpired() bool

func (*WxWorkApp) SendFileMessage

func (r *WxWorkApp) SendFileMessage(userIDList []string, partyIDList []string, tagIDList []string, mediaID string,
	options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) SendGroupFileMessage

func (r *WxWorkApp) SendGroupFileMessage(chatID, mediaID string, options *WxWorkAppMessageSendOptions) (err error)

func (*WxWorkApp) SendGroupImageMessage

func (r *WxWorkApp) SendGroupImageMessage(chatID, mediaID string, options *WxWorkAppMessageSendOptions) (err error)

func (*WxWorkApp) SendGroupMarkdownMessage

func (r *WxWorkApp) SendGroupMarkdownMessage(chatID, content string, options *WxWorkAppMessageSendOptions) (err error)

func (*WxWorkApp) SendGroupMpNewsMessage

func (r *WxWorkApp) SendGroupMpNewsMessage(chatID string, articles []WxWorkAppMpNewsMessageArticle, options *WxWorkAppMessageSendOptions) (err error)

func (*WxWorkApp) SendGroupNewsMessage

func (r *WxWorkApp) SendGroupNewsMessage(chatID string, articles []WxWorkAppNewsMessageArticle, options *WxWorkAppMessageSendOptions) (err error)

func (*WxWorkApp) SendGroupTextCardMessage

func (r *WxWorkApp) SendGroupTextCardMessage(chatID, title, description, url, btnText string, options *WxWorkAppMessageSendOptions) (err error)

func (*WxWorkApp) SendGroupTextMessage

func (r *WxWorkApp) SendGroupTextMessage(chatID, content string, options *WxWorkAppMessageSendOptions) (err error)

func (*WxWorkApp) SendGroupVideoMessage

func (r *WxWorkApp) SendGroupVideoMessage(chatID, mediaID, mediaTitle, mediaDescription string, options *WxWorkAppMessageSendOptions) (err error)

func (*WxWorkApp) SendGroupVoiceMessage

func (r *WxWorkApp) SendGroupVoiceMessage(chatID, mediaID string, options *WxWorkAppMessageSendOptions) (err error)

func (*WxWorkApp) SendImageMessage

func (r *WxWorkApp) SendImageMessage(userIDList []string, partyIDList []string, tagIDList []string, mediaID string,
	options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) SendMarkdownMessage

func (r *WxWorkApp) SendMarkdownMessage(userIDList []string, partyIDList []string, tagIDList []string, content string,
	options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) SendMiniProgramNoticeMessage

func (r *WxWorkApp) SendMiniProgramNoticeMessage(userIDList []string, partyIDList []string, tagIDList []string, appID, page, title, description string,
	emphisFirstItem bool, contentItems []WxWorkAppMiniProgramNoticeMessageItem, options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) SendMpNewsMessage

func (r *WxWorkApp) SendMpNewsMessage(userIDList []string, partyIDList []string, tagIDList []string, articles []WxWorkAppMpNewsMessageArticle,
	options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) SendNewsMessage

func (r *WxWorkApp) SendNewsMessage(userIDList []string, partyIDList []string, tagIDList []string, articles []WxWorkAppNewsMessageArticle,
	options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) SendTaskCardMessage

func (r *WxWorkApp) SendTaskCardMessage(userIDList []string, partyIDList []string, tagIDList []string, taskID, title, description, url string,
	buttons []WxWorkAppTaskCardMessageButton, options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) SendTextCardMessage

func (r *WxWorkApp) SendTextCardMessage(userIDList []string, partyIDList []string, tagIDList []string, title, description, url, btnText string,
	options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) SendTextMessage

func (r *WxWorkApp) SendTextMessage(userIDList []string, partyIDList []string, tagIDList []string, content string,
	options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) SendVideoMessage

func (r *WxWorkApp) SendVideoMessage(userIDList []string, partyIDList []string, tagIDList []string, mediaID, mediaTitle, mediaDescription string,
	options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) SendVoiceMessage

func (r *WxWorkApp) SendVoiceMessage(userIDList []string, partyIDList []string, tagIDList []string, mediaID string,
	options *WxWorkAppMessageSendOptions) (resp WxWorkAppMessageResp, err error)

func (*WxWorkApp) UpdateGroupChat

func (r *WxWorkApp) UpdateGroupChat(chatID string, options *WxWorkAppUpdateGroupOptions) (err error)

func (*WxWorkApp) UploadImage

func (r *WxWorkApp) UploadImage(fileBody []byte, fileName string) (imageURL string, err error)

func (*WxWorkApp) UploadMedia

func (r *WxWorkApp) UploadMedia(fileBody []byte, fileName, fileType string) (mediaID string, createdAt int64, err error)

type WxWorkAppCreateGroupOptions

type WxWorkAppCreateGroupOptions struct {
	ChatID string
}

type WxWorkAppCreateGroupResp

type WxWorkAppCreateGroupResp struct {
	ErrCode    int    `json:"errcode"`
	ErrMessage string `json:"errmsg"`
	ChatID     string `json:"chatid"`
}

type WxWorkAppGetGroupResp

type WxWorkAppGetGroupResp struct {
	ErrCode    int            `json:"errcode"`
	ErrMessage string         `json:"errmsg"`
	ChatInfo   WxWorkAppGroup `json:"chat_info"`
}

type WxWorkAppGroup

type WxWorkAppGroup struct {
	ChatID   string   `json:"chatid"`
	Name     string   `json:"name"`
	Owner    string   `json:"owner"`
	UserList []string `json:"userlist"`
}

type WxWorkAppGroupMessageResp

type WxWorkAppGroupMessageResp struct {
	ErrCode    int    `json:"errcode"`
	ErrMessage string `json:"errmsg"`
}

type WxWorkAppMessageResp

type WxWorkAppMessageResp struct {
	ErrCode      int    `json:"errcode"`
	ErrMessage   string `json:"errmsg"`
	InvalidUser  string `json:"invaliduser"`
	InvalidParty string `json:"invalidparty"`
	InvalidTag   string `json:"invalidtag"`
}

type WxWorkAppMessageSendOptions

type WxWorkAppMessageSendOptions struct {
	Safe                   bool
	EnableIDTrans          bool
	EnableDuplicateCheck   bool
	DuplicateCheckInterval int
}

type WxWorkAppMiniProgramNoticeMessageItem

type WxWorkAppMiniProgramNoticeMessageItem struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type WxWorkAppMpNewsMessageArticle

type WxWorkAppMpNewsMessageArticle struct {
	Title            string `json:"title"`
	ThumbMediaID     string `json:"thumb_media_id"`
	Author           string `json:"author"`
	ContentSourceURL string `json:"content_source_url"`
	Content          string `json:"content"`
	Digest           string `json:"digest"`
}

type WxWorkAppNewsMessageArticle

type WxWorkAppNewsMessageArticle struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	PictureURL  string `json:"picurl"`
}

type WxWorkAppTaskCardMessageButton

type WxWorkAppTaskCardMessageButton struct {
	Key         string `json:"key"`
	Name        string `json:"name"`
	ReplaceName string `json:"replace_name"`
	Color       string `json:"color,omitempty"`
	IsBold      bool   `json:"is_bold,omitempty"`
}

type WxWorkAppTokenResp

type WxWorkAppTokenResp struct {
	ErrCode     int    `json:"errcode"`
	ErrMessage  string `json:"errmsg"`
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

type WxWorkAppUpdateGroupOptions

type WxWorkAppUpdateGroupOptions struct {
	Name        string
	Owner       string
	AddUserList []string
	DelUserList []string
}

type WxWorkAppUpdateGroupResp

type WxWorkAppUpdateGroupResp struct {
	ErrCode    int    `json:"errcode"`
	ErrMessage string `json:"errmsg"`
}

type WxWorkAppUploadImageResp

type WxWorkAppUploadImageResp struct {
	ErrCode    int    `json:"errcode"`
	ErrMessage string `json:"errmsg"`
	URL        string `json:"url"`
}

type WxWorkAppUploadMediaResp

type WxWorkAppUploadMediaResp struct {
	ErrCode    int    `json:"errcode"`
	ErrMessage string `json:"errmsg"`
	Type       string `json:"type"`
	MediaID    string `json:"media_id"`
	CreatedAt  string `json:"created_at"`
}

type WxWorkRobot

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

WxWorkRobot is a robot to send wxwork messages

func NewWxWorkRobot

func NewWxWorkRobot() *WxWorkRobot

NewWxWorkRobot create a new wxwork robot

func NewWxWorkRobotWithClient

func NewWxWorkRobotWithClient(client *http.Client) *WxWorkRobot

NewWxWorkRobotWithClient create a new wxwork robot with http.Client

func NewWxWorkRobotWithTimeout

func NewWxWorkRobotWithTimeout(timeout time.Duration) *WxWorkRobot

NewWxWorkRobotWithTimeout create a new wxwork robot with timeout

func (*WxWorkRobot) SendFileMessage

func (r *WxWorkRobot) SendFileMessage(key, mediaID string) (err error)

SendFileMessage send the file message

func (*WxWorkRobot) SendImageMessage

func (r *WxWorkRobot) SendImageMessage(key string, imageData []byte) (err error)

SendImageMessage send the markdown message

func (*WxWorkRobot) SendMarkdownMessage

func (r *WxWorkRobot) SendMarkdownMessage(key, content string) (err error)

SendMarkdownMessage send the markdown message

func (*WxWorkRobot) SendMarkdownMessageWithMention

func (r *WxWorkRobot) SendMarkdownMessageWithMention(key, content string, mentionedList []string, mentionedMobileList []string) (err error)

SendMarkdownMessageWithMention send the markdown message with specified mentioned users

func (*WxWorkRobot) SendNewsMessage

func (r *WxWorkRobot) SendNewsMessage(key string, articles []WxWorkRobotNewsMessageArticle) (err error)

SendNewsMessage send the news message

func (*WxWorkRobot) SendTextMessage

func (r *WxWorkRobot) SendTextMessage(key, text string) (err error)

SendTextMessage send the text message

func (*WxWorkRobot) SendTextMessageWithMention

func (r *WxWorkRobot) SendTextMessageWithMention(key, content string, mentionedList []string, mentionedMobileList []string) (err error)

SendTextMessage send the text message with specified mentioned users

func (*WxWorkRobot) UploadFile

func (r *WxWorkRobot) UploadFile(key string, fileBody []byte, fileName string) (mediaID string, createdAt int64, err error)

UploadFile upload the media file

type WxWorkRobotFileMessage

type WxWorkRobotFileMessage struct {
	MessageType string                     `json:"msgtype"`
	MessageBody WxWorkRobotFileMessageBody `json:"file"`
}

type WxWorkRobotFileMessageBody

type WxWorkRobotFileMessageBody struct {
	MediaID string `json:"media_id"`
}

type WxWorkRobotImagMessage

type WxWorkRobotImagMessage struct {
	MessageType string                     `json:"msgtype"`
	MessageBody WxWorkRobotImagMessageBody `json:"image"`
}

type WxWorkRobotImagMessageBody

type WxWorkRobotImagMessageBody struct {
	Base64 string `json:"base64"`
	MD5    string `json:"md5"`
}

type WxWorkRobotMarkdownMessage

type WxWorkRobotMarkdownMessage struct {
	MessageType string                         `json:"msgtype"`
	MessageBody WxWorkRobotMarkdownMessageBody `json:"markdown"`
}

type WxWorkRobotMarkdownMessageBody

type WxWorkRobotMarkdownMessageBody WxWorkRobotTextMessageBody

type WxWorkRobotMessageResp

type WxWorkRobotMessageResp struct {
	ErrCode    int    `json:"errcode"`
	ErrMessage string `json:"errmsg"`
}

type WxWorkRobotNewsMessage

type WxWorkRobotNewsMessage struct {
	MessageType string                     `json:"msgtype"`
	MessageBody WxWorkRobotNewsMessageBody `json:"news"`
}

type WxWorkRobotNewsMessageArticle

type WxWorkRobotNewsMessageArticle struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	PictureURL  string `json:"picurl"`
}

type WxWorkRobotNewsMessageBody

type WxWorkRobotNewsMessageBody struct {
	Articles []WxWorkRobotNewsMessageArticle `json:"articles"`
}

type WxWorkRobotTextMessage

type WxWorkRobotTextMessage struct {
	MessageType string                     `json:"msgtype"`
	MessageBody WxWorkRobotTextMessageBody `json:"text"`
}

type WxWorkRobotTextMessageBody

type WxWorkRobotTextMessageBody struct {
	Content             string   `json:"content"`
	MentionedList       []string `json:"mentioned_list,omitempty"`
	MentionedMobileList []string `json:"mentioned_mobile_list,omitempty"`
}

type WxWorkRobotUploadFileResp

type WxWorkRobotUploadFileResp struct {
	ErrCode    int    `json:"errcode"`
	ErrMessage string `json:"errmsg"`
	Type       string `json:"type"`
	MediaID    string `json:"media_id"`
	CreatedAt  string `json:"created_at"`
}

Jump to

Keyboard shortcuts

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