Documentation
¶
Index ¶
- Constants
- func GetQrcodeUrl(uuid string) string
- func GetRandomDeviceId() string
- func PrintlnQrcodeUrl(uuid string)
- func ToBuffer(v interface{}) (*bytes.Buffer, error)
- type BaseRequest
- type BaseResponse
- type Bot
- type Caller
- func (c *Caller) CheckLogin(uuid string) (*CheckLoginResponse, error)
- func (c *Caller) GetLoginInfo(body []byte) (*LoginInfo, error)
- func (c *Caller) GetLoginUUID() (string, error)
- func (c *Caller) SyncCheck(info LoginInfo, response WebInitResponse) (*SyncCheckResponse, error)
- func (c *Caller) WebInit(request BaseRequest) (*WebInitResponse, error)
- func (c *Caller) WebWxBatchGetContact(members Members, request BaseRequest) (Members, error)
- func (c *Caller) WebWxGetContact(info LoginInfo) (Members, error)
- func (c *Caller) WebWxOplog(request BaseRequest, remarkName, toUserName string) error
- func (c *Caller) WebWxSendImageMsg(file *os.File, request BaseRequest, info LoginInfo, ...) error
- func (c *Caller) WebWxSendMsg(msg *SendMessage, info LoginInfo, request BaseRequest) error
- func (c *Caller) WebWxStatusNotify(request BaseRequest, response WebInitResponse, info LoginInfo) error
- func (c *Caller) WebWxSync(request BaseRequest, response WebInitResponse, info LoginInfo) (*WebWxSyncResponse, error)
- type CheckLoginResponse
- type Client
- func (c *Client) CheckLogin(uuid string) (*http.Response, error)
- func (c *Client) GetLoginInfo(path string) (*http.Response, error)
- func (c *Client) GetLoginQrcode(uuid string) (*http.Response, error)
- func (c *Client) GetLoginUUID() (*http.Response, error)
- func (c *Client) SyncCheck(info LoginInfo, response WebInitResponse) (*http.Response, error)
- func (c *Client) WebInit(request BaseRequest) (*http.Response, error)
- func (c *Client) WebWxBatchGetContact(members Members, request BaseRequest) (*http.Response, error)
- func (c *Client) WebWxGetContact(info LoginInfo) (*http.Response, error)
- func (c *Client) WebWxGetHeadImg(headImageUrl string) (*http.Response, error)
- func (c *Client) WebWxOplog(request BaseRequest, remarkName, userName string) (*http.Response, error)
- func (c *Client) WebWxSendAppMsg(msg *SendMessage, request BaseRequest) (*http.Response, error)
- func (c *Client) WebWxSendMsg(msg *SendMessage, info LoginInfo, request BaseRequest) (*http.Response, error)
- func (c *Client) WebWxSendMsgImg(msg *SendMessage, request BaseRequest, info LoginInfo) (*http.Response, error)
- func (c *Client) WebWxStatusNotify(request BaseRequest, response WebInitResponse, info LoginInfo) (*http.Response, error)
- func (c *Client) WebWxSync(request BaseRequest, response WebInitResponse, info LoginInfo) (*http.Response, error)
- func (c *Client) WebWxUploadMedia(file *os.File, request BaseRequest, info LoginInfo, ...) (*http.Response, error)
- func (c *Client) WebWxVerifyUser(storage WechatStorage, info RecommendInfo, verifyContent string) (*http.Response, error)
- type Friend
- type Friends
- type Group
- type Groups
- type LoginInfo
- type MPSubscribeMsg
- type Members
- type Message
- func (m *Message) Get(key string) (value interface{}, exist bool)
- func (m *Message) IsCard() bool
- func (m *Message) IsFriendAdd() bool
- func (m *Message) IsMap() bool
- func (m *Message) IsPicture() bool
- func (m *Message) IsRecalled() bool
- func (m *Message) IsSendByFriend() bool
- func (m *Message) IsSendByGroup() bool
- func (m *Message) IsSendBySelf() bool
- func (m *Message) IsSharing() bool
- func (m *Message) IsSystem() bool
- func (m *Message) IsText() bool
- func (m *Message) IsVideo() bool
- func (m *Message) IsVoice() bool
- func (m *Message) Reply(msgType int, content, mediaId string) error
- func (m *Message) ReplyImage(file *os.File) error
- func (m *Message) ReplyText(content string) error
- func (m *Message) Sender() (*User, error)
- func (m *Message) SenderInGroup() (*User, error)
- func (m *Message) Set(key string, value interface{})
- type MessageHandler
- type MessageHandlerGroup
- type RecommendInfo
- type ReturnResponse
- type Self
- type SendMessage
- type SimpleWechatStorage
- func (s *SimpleWechatStorage) GetBaseRequest() BaseRequest
- func (s *SimpleWechatStorage) GetLoginInfo() LoginInfo
- func (s *SimpleWechatStorage) GetWebInitResponse() WebInitResponse
- func (s *SimpleWechatStorage) SetBaseRequest(baseRequest BaseRequest)
- func (s *SimpleWechatStorage) SetLoginInfo(loginInfo LoginInfo)
- func (s *SimpleWechatStorage) SetWebInitResponse(webInitResponse WebInitResponse)
- type SyncCheckResponse
- type SyncKey
- type User
- type UserDetailItem
- type UserDetailItemList
- type WebInitResponse
- type WebWxBatchContactResponse
- type WebWxContactResponse
- type WebWxSyncResponse
- type WechatStorage
Constants ¶
View Source
const ( TextMessage = 1 ImageMessage = 3 AppMessage = 6 )
消息类型
Variables ¶
This section is empty.
Functions ¶
func GetQrcodeUrl ¶
func GetRandomDeviceId ¶
func GetRandomDeviceId() string
func PrintlnQrcodeUrl ¶
func PrintlnQrcodeUrl(uuid string)
Types ¶
type BaseRequest ¶
初始的请求信息 几乎所有的请求都要携带该参数
type BaseResponse ¶
大部分返回对象都携带该信息
func (BaseResponse) Error ¶
func (b BaseResponse) Error() string
func (BaseResponse) Ok ¶
func (b BaseResponse) Ok() bool
type Bot ¶
type Bot struct { Caller *Caller ScanCallBack func(body []byte) LoginCallBack func(body []byte) UUIDCallback func(uuid string) // contains filtered or unexported fields }
func DefaultBot ¶
func DefaultBot() *Bot
func NewBot ¶
func NewBot(caller *Caller, storage WechatStorage) *Bot
func (*Bot) RegisterMessageHandler ¶
func (b *Bot) RegisterMessageHandler(handler MessageHandler)
注册消息处理的函数
type Caller ¶
type Caller struct {
Client *Client
}
调用请求和解析请求 上层模块可以直接获取封装后的请求结果
func (*Caller) CheckLogin ¶
func (c *Caller) CheckLogin(uuid string) (*CheckLoginResponse, error)
检查是否登录成功
func (*Caller) SyncCheck ¶
func (c *Caller) SyncCheck(info LoginInfo, response WebInitResponse) (*SyncCheckResponse, error)
异步获取是否有新的消息
func (*Caller) WebInit ¶
func (c *Caller) WebInit(request BaseRequest) (*WebInitResponse, error)
获取初始化信息
func (*Caller) WebWxBatchGetContact ¶
func (c *Caller) WebWxBatchGetContact(members Members, request BaseRequest) (Members, error)
获取联系人的详情 注: Members参数的长度不要大于50
func (*Caller) WebWxGetContact ¶
获取所有的联系人
func (*Caller) WebWxOplog ¶
func (c *Caller) WebWxOplog(request BaseRequest, remarkName, toUserName string) error
修改用户备注接口
func (*Caller) WebWxSendImageMsg ¶
func (c *Caller) WebWxSendImageMsg(file *os.File, request BaseRequest, info LoginInfo, fromUserName, toUserName string) error
发送图片消息接口
func (*Caller) WebWxSendMsg ¶
func (c *Caller) WebWxSendMsg(msg *SendMessage, info LoginInfo, request BaseRequest) error
发送消息接口
func (*Caller) WebWxStatusNotify ¶
func (c *Caller) WebWxStatusNotify(request BaseRequest, response WebInitResponse, info LoginInfo) error
通知手机已登录
func (*Caller) WebWxSync ¶
func (c *Caller) WebWxSync(request BaseRequest, response WebInitResponse, info LoginInfo) (*WebWxSyncResponse, error)
获取新的消息接口
type CheckLoginResponse ¶
type Client ¶
http请求客户端 客户端需要维持Session会话 并且客户端不允许跳转
func (*Client) GetLoginInfo ¶
请求获取LoginInfo
func (*Client) GetLoginQrcode ¶
获取登录的二维吗
func (*Client) WebInit ¶
func (c *Client) WebInit(request BaseRequest) (*http.Response, error)
请求获取初始化信息
func (*Client) WebWxBatchGetContact ¶
获取联系人详情
func (*Client) WebWxGetContact ¶
获取联系人信息
func (*Client) WebWxGetHeadImg ¶
获取用户的头像
func (*Client) WebWxOplog ¶
func (c *Client) WebWxOplog(request BaseRequest, remarkName, userName string) (*http.Response, error)
用户重命名接口
func (*Client) WebWxSendAppMsg ¶
func (c *Client) WebWxSendAppMsg(msg *SendMessage, request BaseRequest) (*http.Response, error)
发送文件信息
func (*Client) WebWxSendMsg ¶
func (c *Client) WebWxSendMsg(msg *SendMessage, info LoginInfo, request BaseRequest) (*http.Response, error)
发送文本消息
func (*Client) WebWxSendMsgImg ¶
func (c *Client) WebWxSendMsgImg(msg *SendMessage, request BaseRequest, info LoginInfo) (*http.Response, error)
发送图片 这个接口依赖上传文件的接口 发送的图片必须是已经成功上传的图片
func (*Client) WebWxStatusNotify ¶
func (c *Client) WebWxStatusNotify(request BaseRequest, response WebInitResponse, info LoginInfo) (*http.Response, error)
通知手机已登录
func (*Client) WebWxSync ¶
func (c *Client) WebWxSync(request BaseRequest, response WebInitResponse, info LoginInfo) (*http.Response, error)
获取消息接口
func (*Client) WebWxUploadMedia ¶
func (c *Client) WebWxUploadMedia(file *os.File, request BaseRequest, info LoginInfo, forUserName, toUserName, contentType, mediaType string) (*http.Response, error)
上传文件
func (*Client) WebWxVerifyUser ¶
func (c *Client) WebWxVerifyUser(storage WechatStorage, info RecommendInfo, verifyContent string) (*http.Response, error)
添加用户为好友接口
type Friend ¶
type Friend struct{ *User }
func (*Friend) RemarkName ¶
func (*Friend) SendMsg ¶
func (f *Friend) SendMsg(msg *SendMessage) error
type Group ¶
type Group struct{ *User }
func (*Group) SendMsg ¶
func (g *Group) SendMsg(msg *SendMessage) error
type LoginInfo ¶
type LoginInfo struct { Ret int `xml:"ret"` Message string `xml:"message"` SKey string `xml:"skey"` WxSid string `xml:"wxsid"` WxUin int `xml:"wxuin"` PassTicket string `xml:"pass_ticket"` IsGrayScale int `xml:"isgrayscale"` }
登录信息
type MPSubscribeMsg ¶
type MPSubscribeMsg struct { UserName string Time int64 NickName string MPArticleCount int MPArticleList []struct { Title string Cover string Digest string Url string } }
公众号的订阅信息
type Message ¶
type Message struct { AppInfo struct { AppID string Type int } AppMsgType int Content string CreateTime int64 EncryFileName string FileName string FileSize string ForwardFlag int FromUserName string HasProductId int ImgHeight int ImgStatus int ImgWidth int MediaId string MsgId string MsgType int NewMsgId int64 OriContent string PlayLength int64 RecommendInfo RecommendInfo Status int StatusNotifyCode int StatusNotifyUserName string SubMsgType int Ticket string ToUserName string Url string VoiceLength int Bot *Bot Context context.Context // contains filtered or unexported fields }
func (*Message) IsFriendAdd ¶
func (*Message) IsRecalled ¶
type MessageHandler ¶
type MessageHandler func(message *Message)
type MessageHandlerGroup ¶
type MessageHandlerGroup struct {
// contains filtered or unexported fields
}
func (MessageHandlerGroup) ProcessMessage ¶
func (m MessageHandlerGroup) ProcessMessage(message *Message)
func (*MessageHandlerGroup) RegisterHandler ¶
func (m *MessageHandlerGroup) RegisterHandler(handler MessageHandler)
type RecommendInfo ¶
type RecommendInfo struct { Alias string AttrStatus int64 City string Content string NickName string OpCode int Province string QQNum int64 Scene int Sex int Signature string Ticket string UserName string VerifyFlag int }
一些特殊类型的消息会携带该结构体信息
type ReturnResponse ¶
Http请求的响应结构体封装
func NewReturnResponse ¶
func NewReturnResponse(response *http.Response, err error) *ReturnResponse
Constructor for ReturnResponse
type SendMessage ¶
type SendMessage struct { Type int Content string FromUserName string ToUserName string LocalID int64 ClientMsgId int64 MediaId string }
发送消息的结构体
func NewMediaSendMessage ¶
func NewMediaSendMessage(msgType int, fromUserName, toUserName, mediaId string) *SendMessage
媒体消息的构造方法
func NewSendMessage ¶
func NewSendMessage(msgType int, content, fromUserName, toUserName, mediaId string) *SendMessage
SendMessage的构造方法
func NewTextSendMessage ¶
func NewTextSendMessage(content, fromUserName, toUserName string) *SendMessage
文本消息的构造方法
type SimpleWechatStorage ¶
type SimpleWechatStorage struct {
// contains filtered or unexported fields
}
implement WechatStorage WechatStorage接口的实现
func NewSimpleWechatStorage ¶
func NewSimpleWechatStorage() *SimpleWechatStorage
func (*SimpleWechatStorage) GetBaseRequest ¶
func (s *SimpleWechatStorage) GetBaseRequest() BaseRequest
func (*SimpleWechatStorage) GetLoginInfo ¶
func (s *SimpleWechatStorage) GetLoginInfo() LoginInfo
func (*SimpleWechatStorage) GetWebInitResponse ¶
func (s *SimpleWechatStorage) GetWebInitResponse() WebInitResponse
func (*SimpleWechatStorage) SetBaseRequest ¶
func (s *SimpleWechatStorage) SetBaseRequest(baseRequest BaseRequest)
func (*SimpleWechatStorage) SetLoginInfo ¶
func (s *SimpleWechatStorage) SetLoginInfo(loginInfo LoginInfo)
func (*SimpleWechatStorage) SetWebInitResponse ¶
func (s *SimpleWechatStorage) SetWebInitResponse(webInitResponse WebInitResponse)
type SyncCheckResponse ¶
func (*SyncCheckResponse) NorMal ¶
func (s *SyncCheckResponse) NorMal() bool
func (*SyncCheckResponse) Success ¶
func (s *SyncCheckResponse) Success() bool
type User ¶
type User struct { Uin int HideInputBarFlag int StarFriend int Sex int AppAccountFlag int VerifyFlag int ContactFlag int WebWxPluginSwitch int HeadImgFlag int SnsFlag int UserName string NickName string HeadImgUrl string RemarkName string PYInitial string PYQuanPin string RemarkPYInitial string RemarkPYQuanPin string Signature string MemberCount int MemberList Members OwnerUin int Statues int AttrStatus int Province string City string Alias string UniFriend int DisplayName string ChatRoomId int KeyWord string EncryChatRoomId string IsOwner int Self *Self }
type UserDetailItem ¶
type UserDetailItemList ¶
type UserDetailItemList []UserDetailItem
func NewUserDetailItemList ¶
func NewUserDetailItemList(members Members) UserDetailItemList
type WebInitResponse ¶
type WebInitResponse struct { BaseResponse BaseResponse Count int ChatSet string SKey string SyncKey SyncKey User User ClientVersion int SystemTime int64 GrayScale int InviteStartCount int MPSubscribeMsgCount int MPSubscribeMsgList []MPSubscribeMsg ClickReportInterval int ContactList []User }
初始化的相应信息
type WebWxBatchContactResponse ¶
type WebWxBatchContactResponse struct { BaseResponse BaseResponse ContactList []*User Count int }
type WebWxContactResponse ¶
type WebWxContactResponse struct { BaseResponse BaseResponse MemberCount int MemberList []*User Seq int }
type WebWxSyncResponse ¶
type WechatStorage ¶
type WechatStorage interface { SetLoginInfo(loginInfo LoginInfo) SetBaseRequest(baseRequest BaseRequest) SetWebInitResponse(webInitResponse WebInitResponse) GetLoginInfo() LoginInfo GetBaseRequest() BaseRequest GetWebInitResponse() WebInitResponse }
WechatStorage 可以根据自己的情况来实现该接口
Click to show internal directories.
Click to hide internal directories.