Documentation ¶
Index ¶
- Constants
- func IsWeworkError(err interface{}) bool
- func NewWeworkError(format string, a ...interface{}) weworkError
- func RobotPushFile(robotId string, mediaId string) error
- func RobotPushMarkdown(robotId string, content string) error
- func RobotPushText(robotId string, content string, atUser ...string) error
- func RobotUploadFile(robotId, filepath, filename string) (string, error)
- func SystemBusyHandler(wx *Client, api string, code int, data *[]byte) bool
- func TokenHandler(wx *Client, api string, code int, data *[]byte) bool
- type ChatInfo
- type ChatMarkdownMsg
- type ChatResponse
- type ChatTextMsg
- type Client
- func (wx *Client) AllDept() ([]Department, error)
- func (wx *Client) ChatMarkdownPush(ChatId, content string) error
- func (wx *Client) ChatTextPush(ChatId, content string) error
- func (wx *Client) CreateChat(name, chatId string, users []string) error
- func (wx *Client) DeptByID(departmentID string) ([]Department, error)
- func (wx *Client) Get(api string, params ...string) ([]byte, error)
- func (wx *Client) GetChat(chatId string) (ChatInfo, error)
- func (wx *Client) LoopUpdateToken()
- func (wx *Client) Post(api string, data []byte) ([]byte, error)
- func (wx *Client) SetHost(host string)
- func (wx *Client) SetHttpClient(client *http.Client)
- func (wx *Client) SetRetry(reTry int) *Client
- func (wx *Client) UpdateChat(name, chatId, owner string, addUsers, delUsers []string) error
- func (wx *Client) Use(handlerFunc ...HandlerFunc) *Client
- func (wx *Client) UserByID(userID string) (UserDetail, error)
- func (wx *Client) UserMarkdownPush(users, content string) (string, error)
- func (wx *Client) UserTextPush(users, content string) (string, error)
- func (wx *Client) UsersByDeptID(departmentID string) ([]UserDetail, error)
- type Department
- type DepartmentList
- type HandlerFunc
- type HandlersChan
- type Result
- type RobotFileMsg
- type RobotImageMsg
- type RobotMarkdownMsg
- type RobotTextMsg
- type RobotUploadResponse
- type UserDetail
- type UserListResponse
- type UserMarkdownMsg
- type UserPushResponse
- type UserTextMsg
Constants ¶
const ( ApiGetToken = "/cgi-bin/gettoken" // 获取token ApiGetUserByID = "/cgi-bin/user/get" // 获取用户信息 ApiGetUsersByDeptID = "/cgi-bin/user/list" // 获取用户列表 ApiGetDept = "/cgi-bin/department/list" // 获取部门列表 ApiUserSend = "/cgi-bin/message/send" // 私信推送 ApiChatSend = "/cgi-bin/appchat/send" // 群消息推送 ApiCreateChat = "/cgi-bin/appchat/create" // 创建群聊 ApiUpdateChat = "/cgi-bin/appchat/update" // 更新群聊 ApiGetChat = "/cgi-bin/appchat/get" // 获取群聊详情 ApiVerifyToken = "/cgi-bin/menu/get" // 获取应用菜单, 用来验证token有效性 )
非get即post
const ( DefaultHost = "https://qyapi.weixin.qq.com" ErrorTokenExpired = 42001 // 没有token ErrorTokenNotFound = 41001 // 没有token ErrorToken = 40014 // token不合法 ErrorSystemBusy = -1 // 系统繁忙 )
企业微信错误码
Variables ¶
This section is empty.
Functions ¶
func IsWeworkError ¶
func IsWeworkError(err interface{}) bool
func NewWeworkError ¶
func NewWeworkError(format string, a ...interface{}) weworkError
func RobotPushFile ¶ added in v1.0.2
RobotPushFile 推送文件消息 robotId 机器人id mediaId 文件id
func RobotPushMarkdown ¶
RobotPushMarkdown 推送markdown消息 robotId 机器人id content 消息内容 atUser 需要@的user_id
func RobotPushText ¶
RobotPushText 推送文本消息 robotId 机器人id content 消息内容 atUser 需要@的user_id
func RobotUploadFile ¶ added in v1.0.2
RobotUploadFile 上传文件至机器人空间, 返回media_id robotId 机器人id filename 文件路径
func SystemBusyHandler ¶
SystemBusyHandler 企业微信服务器繁忙重试
Types ¶
type ChatInfo ¶
type ChatInfo struct { ChatId string `json:"chatid"` Name string `json:"name"` Owner string `json:"owner"` UserList []string `json:"userlist"` }
ChatInfo 群聊详情
type ChatMarkdownMsg ¶
type ChatMarkdownMsg struct { Markdown struct { Content string `json:"content"` } `json:"markdown"` // contains filtered or unexported fields }
ChatMarkdownMsg 群聊Markdown消息推送参数
type ChatResponse ¶
type ChatResponse struct { Errcode int `json:"errcode"` Errmsg string `json:"errmsg"` ChatInfos ChatInfo `json:"chat_info"` }
ChatResponse chat api response
type ChatTextMsg ¶
type ChatTextMsg struct { Text struct { Content string `json:"content"` } `json:"text"` // contains filtered or unexported fields }
ChatTextMsg 群聊文本消息推送参数
type Client ¶
type Client struct { Token tokenInfo // 应用token // contains filtered or unexported fields }
Client 企业微信client
func (*Client) ChatMarkdownPush ¶
ChatMarkdownPush 群聊Markdown消息推送
func (*Client) ChatTextPush ¶
ChatTextPush 群聊文本消息推送
func (*Client) CreateChat ¶
CreateChat 创建群聊
func (*Client) DeptByID ¶
func (wx *Client) DeptByID(departmentID string) ([]Department, error)
DeptByID 通过部门id获取部门详情
func (*Client) SetHttpClient ¶
SetHttpClient 设置自定义的http client以支持更高级的姿势或兼容企业内部框架
func (*Client) UpdateChat ¶
UpdateChat 更新群聊
func (*Client) UserByID ¶
func (wx *Client) UserByID(userID string) (UserDetail, error)
UserByID 通过user_id获取用户详情
func (*Client) UserMarkdownPush ¶
UserMarkdownPush 私信Markdown消息推送
func (*Client) UserTextPush ¶
UserTextPush 私信文本消息推送
func (*Client) UsersByDeptID ¶
func (wx *Client) UsersByDeptID(departmentID string) ([]UserDetail, error)
UsersByDeptID 通过部门id获取用户详情
type Department ¶
type Department struct { Id int `json:"id"` Name string `json:"name"` NameEn string `json:"name_en"` ParentID int `json:"parentid"` Order int `json:"order"` }
Department 部门详情
type DepartmentList ¶
type DepartmentList struct { Errcode int `json:"errcode"` Errmsg string `json:"errmsg"` Department []Department `json:"department"` }
DepartmentList 部门详情列表
type HandlerFunc ¶
HandlerFunc api response 钩子函数
type Result ¶
type Result struct { ErrCode int `json:"errcode"` ErrMsg string `json:"errmsg"` Error error `json:"-"` }
Result 函数错误返回结构
type RobotFileMsg ¶
type RobotFileMsg struct { MsgType string `json:"msgtype"` File struct { MediaId string `json:"media_id"` } `json:"file"` }
RobotFileMsg 推送文件
type RobotImageMsg ¶
type RobotImageMsg struct { MsgType string `json:"msgtype"` Image struct { Base64 string `json:"base64"` // 图片base64 不超过2M Md5 string `json:"md5"` } `json:"image"` }
RobotImageMsg 推送图片消息
type RobotMarkdownMsg ¶
type RobotMarkdownMsg struct { MsgType string `json:"msgtype"` Markdown struct { Content string `json:"content"` } `json:"markdown"` }
RobotMarkdownMsg 推送markdown消息
type RobotTextMsg ¶
type RobotTextMsg struct { MsgType string `json:"msgtype"` Text struct { Content string `json:"content"` MentionedList []string `json:"mentioned_list"` MentionedMobileList []string `json:"mentioned_mobile_list"` } `json:"text"` }
RobotTextMsg 推送文本消息
type RobotUploadResponse ¶
type RobotUploadResponse struct { ErrCode int `json:"errcode"` ErrMsg string `json:"errmsg"` Type string `json:"type"` MediaId string `json:"media_id"` CreatedAt string `json:"created_at"` }
RobotUploadResponse 文件上传
type UserDetail ¶
type UserDetail struct { ErrCode int `json:"errcode"` ErrMsg string `json:"errmsg"` Userid string `json:"userid" ` Name string `json:"name"` Department []int `json:"department"` Order []int `json:"order"` Position string `json:"position"` Mobile string `json:"mobile"` Gender string `json:"gender"` Email string `json:"email"` IsLeaderInDept []int `json:"is_leader_in_dept"` Avatar string `json:"avatar"` ThumbAvatar string `json:"thumb_avatar"` Telephone string `json:"telephone"` Alias string `json:"alias"` Address string `json:"address"` OpenUserid string `json:"open_userid"` MainDepartment int `json:"main_department"` ExtAttr struct { Attrs []struct { Type int `json:"type"` Name string `json:"name"` Text struct { Value string `json:"value"` } `json:"text,omitempty"` Web struct { Url string `json:"url"` Title string `json:"title"` } `json:"web,omitempty"` } `json:"attrs"` } `json:"extattr"` Status int `json:"status"` QrCode string `json:"qr_code"` ExternalPosition string `json:"external_position"` ExternalProfile struct { ExternalCorpName string `json:"external_corp_name"` WechatChannels struct { Nickname string `json:"nickname"` Status int `json:"status"` } `json:"wechat_channels"` ExternalAttr []struct { Type int `json:"type"` Name string `json:"name"` Text struct { Value string `json:"value"` } `json:"text,omitempty"` Web struct { Url string `json:"url"` Title string `json:"title"` } `json:"web,omitempty"` MiniProgram struct { Appid string `json:"appid"` Pagepath string `json:"pagepath"` Title string `json:"title"` } `json:"miniprogram,omitempty"` } `json:"external_attr"` } `json:"external_profile"` }
UserDetail 用户详情
type UserListResponse ¶
type UserListResponse struct { ErrCode int `json:"errcode"` ErrMsg string `json:"errmsg"` UserList []UserDetail `json:"userlist"` }
UserListResponse 用户详情列表
type UserMarkdownMsg ¶
type UserMarkdownMsg struct { Markdown struct { Content string `json:"content"` } `json:"markdown"` // contains filtered or unexported fields }
UserMarkdownMsg 用户私信Markdown消息参数
type UserPushResponse ¶
type UserTextMsg ¶
type UserTextMsg struct { Text struct { Content string `json:"content"` } `json:"text"` // contains filtered or unexported fields }
UserTextMsg 用户私信文本消息参数