Documentation ¶
Index ¶
- Constants
- Variables
- func DispatchMessage(dispatcher MessageDispatcher) func(msg *Message)
- func FormatEmoji(text string) string
- func GetFileContentType(file multipart.File) (string, error)
- func GetQrcodeUrl(uuid string) string
- func GetRandomDeviceId() string
- func NewFileAppMessage(stat os.FileInfo, attachId string) *appmsg
- func PrintlnQrcodeUrl(uuid string)
- func ToBuffer(v interface{}) (*bytes.Buffer, error)
- func XmlFormString(text string) string
- type BaseRequest
- type BaseResponse
- type Bot
- func (b *Bot) Alive() bool
- func (b *Bot) Block() error
- func (b *Bot) CrashReason() error
- func (b *Bot) DumpHotReloadStorage() error
- func (b *Bot) GetCurrentUser() (*Self, error)
- func (b *Bot) HotLogin(storage HotReloadStorage, retry ...bool) error
- func (b *Bot) Login() error
- func (b *Bot) Logout() error
- func (b *Bot) MessageOnError(h func(err error))
- func (b *Bot) MessageOnSuccess(h func(msg *Message))
- type Caller
- func (c *Caller) AddFriendIntoChatRoom(req *BaseRequest, info *LoginInfo, group *Group, friends ...*Friend) error
- 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) Logout(info *LoginInfo) error
- func (c *Caller) RemoveFriendFromChatRoom(req *BaseRequest, info *LoginInfo, group *Group, users ...*User) error
- func (c *Caller) SyncCheck(info *LoginInfo, response *WebInitResponse) (*SyncCheckResponse, error)
- func (c *Caller) UploadMedia(file *os.File, request *BaseRequest, info *LoginInfo, ...) (*UploadResponse, 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) WebWxRevokeMsg(msg *SentMessage, request *BaseRequest) error
- func (c *Caller) WebWxSendAppMsg(msg *SendMessage, req *BaseRequest) (*SentMessage, error)
- func (c *Caller) WebWxSendFile(file *os.File, req *BaseRequest, info *LoginInfo, ...) (*SentMessage, error)
- func (c *Caller) WebWxSendImageMsg(file *os.File, request *BaseRequest, info *LoginInfo, ...) (*SentMessage, error)
- func (c *Caller) WebWxSendMsg(msg *SendMessage, info *LoginInfo, request *BaseRequest) (*SentMessage, error)
- func (c *Caller) WebWxStatusNotify(request *BaseRequest, response *WebInitResponse, info *LoginInfo) error
- func (c *Caller) WebWxSync(request *BaseRequest, response *WebInitResponse, info *LoginInfo) (*WebWxSyncResponse, error)
- func (c *Caller) WebWxVerifyUser(storage *Storage, info RecommendInfo, verifyContent string) error
- type Card
- type CheckLoginResponse
- type Client
- func (c *Client) AddHttpHook(hooks ...HttpHook)
- func (c *Client) AddMemberIntoChatRoom(req *BaseRequest, info *LoginInfo, group *Group, friends ...*Friend) (*http.Response, error)
- func (c *Client) CheckLogin(uuid string) (*http.Response, error)
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) GetCookieMap() map[string][]*http.Cookie
- 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) Logout(info *LoginInfo) (*http.Response, error)
- func (c *Client) RemoveMemberFromChatRoom(req *BaseRequest, info *LoginInfo, group *Group, friends ...*User) (*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) WebWxGetMedia(msg *Message, info *LoginInfo) (*http.Response, error)
- func (c *Client) WebWxGetMsgImg(msg *Message, info *LoginInfo) (*http.Response, error)
- func (c *Client) WebWxGetVideo(msg *Message, info *LoginInfo) (*http.Response, error)
- func (c *Client) WebWxGetVoice(msg *Message, info *LoginInfo) (*http.Response, error)
- func (c *Client) WebWxOplog(request *BaseRequest, remarkName, userName string) (*http.Response, error)
- func (c *Client) WebWxRevokeMsg(msg *SentMessage, request *BaseRequest) (*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) WebWxUploadMediaByChunk(file *os.File, request *BaseRequest, info *LoginInfo, ...) (*http.Response, error)
- func (c *Client) WebWxVerifyUser(storage *Storage, info RecommendInfo, verifyContent string) (*http.Response, error)
- type Friend
- func (f *Friend) AddIntoGroup(groups ...*Group) error
- func (f *Friend) SendFile(file *os.File) (*SentMessage, error)
- func (f *Friend) SendImage(file *os.File) (*SentMessage, error)
- func (f *Friend) SendMsg(msg *SendMessage) (*SentMessage, error)
- func (f *Friend) SendText(content string) (*SentMessage, error)
- func (f *Friend) SetRemarkName(name string) error
- func (f Friend) String() string
- type FriendAddMessage
- type Friends
- func (f Friends) Count() int
- func (f Friends) First() *Friend
- func (f Friends) Last() *Friend
- func (f Friends) Search(limit int, condFuncList ...func(friend *Friend) bool) (results Friends)
- func (f Friends) SearchByNickName(limit int, nickName string) (results Friends)
- func (f Friends) SearchByRemarkName(limit int, remarkName string) (results Friends)
- func (f Friends) SearchByUserName(limit int, username string) (results Friends)
- func (f Friends) SendFile(file *os.File, delay ...time.Duration) error
- func (f Friends) SendImage(file *os.File, delay ...time.Duration) error
- func (f Friends) SendMsg(msg *SendMessage, delay ...time.Duration) error
- func (f Friends) SendText(text string, delay ...time.Duration) error
- type Group
- func (g *Group) AddFriendsIn(friends ...*Friend) error
- func (g *Group) Members() (Members, error)
- func (g *Group) RemoveMembers(members Members) error
- func (g *Group) SendFile(file *os.File) (*SentMessage, error)
- func (g *Group) SendImage(file *os.File) (*SentMessage, error)
- func (g *Group) SendMsg(msg *SendMessage) (*SentMessage, error)
- func (g *Group) SendText(content string) (*SentMessage, error)
- func (g Group) String() string
- type Groups
- func (g Groups) Count() int
- func (g Groups) First() *Group
- func (g Groups) Last() *Group
- func (g Groups) Search(limit int, condFuncList ...func(group *Group) bool) (results Groups)
- func (g Groups) SearchByNickName(limit int, nickName string) (results Groups)
- func (g Groups) SearchByRemarkName(limit int, remarkName string) (results Groups)
- func (g Groups) SearchByUserName(limit int, username string) (results Groups)
- func (g Groups) SendImage(file *os.File, delay ...time.Duration) error
- func (g Groups) SendMsg(msg *SendMessage, delay ...time.Duration) error
- func (g Groups) SendText(text string, delay ...time.Duration) error
- type HotReloadStorage
- type HotReloadStorageItem
- type HttpHook
- type HttpHooks
- type JsonFileHotReloadStorage
- type LoginInfo
- type MPSubscribeMsg
- type Members
- func (m Members) Count() int
- func (m Members) First() *User
- func (m Members) Friends() Friends
- func (m Members) Groups() Groups
- func (m Members) Last() *User
- func (m Members) MPs() Mps
- func (m Members) Search(limit int, condFuncList ...func(user *User) bool) (results Members)
- func (m Members) SearchByNickName(limit int, nickName string) (results Members)
- func (m Members) SearchByRemarkName(limit int, remarkName string) (results Members)
- func (m Members) SearchByUserName(limit int, username string) (results Members)
- func (m Members) SetOwner(s *Self)
- type Message
- func (m *Message) Agree(verifyContents ...string) error
- func (m *Message) Card() (*Card, error)
- func (m *Message) FriendAddMessageContent() (*FriendAddMessage, error)
- func (m *Message) Get(key string) (value interface{}, exist bool)
- func (m *Message) GetFile() (*http.Response, error)
- func (m *Message) HasFile() bool
- func (m *Message) IsCard() bool
- func (m *Message) IsFriendAdd() bool
- func (m *Message) IsMap() bool
- func (m *Message) IsMedia() bool
- func (m *Message) IsNotify() bool
- func (m *Message) IsPicture() bool
- func (m *Message) IsRecalled() bool
- func (m *Message) IsReceiveRedPacket() bool
- func (m *Message) IsSendByFriend() bool
- func (m *Message) IsSendByGroup() bool
- func (m *Message) IsSendBySelf() bool
- func (m *Message) IsSendRedPacket() bool
- func (m *Message) IsSysNotice() bool
- func (m *Message) IsSystem() bool
- func (m *Message) IsText() bool
- func (m *Message) IsTransferAccounts() bool
- func (m *Message) IsVideo() bool
- func (m *Message) IsVoice() bool
- func (m *Message) Receiver() (*User, error)
- func (m *Message) Reply(msgType int, content, mediaId string) (*SentMessage, error)
- func (m *Message) ReplyFile(file *os.File) (*SentMessage, error)
- func (m *Message) ReplyImage(file *os.File) (*SentMessage, error)
- func (m *Message) ReplyText(content string) (*SentMessage, error)
- func (m *Message) RevokeMsg() (*RevokeMsg, error)
- func (m *Message) Sender() (*User, error)
- func (m *Message) SenderInGroup() (*User, error)
- func (m *Message) Set(key string, value interface{})
- func (m *Message) StatusNotify() bool
- type MessageContext
- type MessageContextHandler
- type MessageContextHandlerGroup
- type MessageDispatcher
- type MessageHandler
- type MessageMatchDispatcher
- func (m *MessageMatchDispatcher) Dispatch(msg *Message)
- func (m *MessageMatchDispatcher) OnCard(handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnFriend(handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnFriendAdd(handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnFriendByNickName(nickName string, handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnFriendByRemarkName(remarkName string, handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnGroup(handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnGroupByGroupName(groupName string, handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnImage(handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnText(handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnUser(f func(user *User) bool, handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnVoice(handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) RegisterHandler(matchFunc matchFunc, handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) SetAsync(async bool)
- type MessageResponse
- type Mp
- type Mps
- type RecommendInfo
- type RevokeMsg
- type Self
- func (s *Self) AddFriendIntoManyGroups(friend *Friend, groups ...*Group) error
- func (s *Self) AddFriendsIntoGroup(group *Group, friends ...*Friend) error
- func (s *Self) FileHelper() (*Friend, error)
- func (s *Self) ForwardMessageToFriends(msg *SentMessage, friends ...*Friend) error
- func (s *Self) ForwardMessageToGroups(msg *SentMessage, groups ...*Group) error
- func (s *Self) Friends(update ...bool) (Friends, error)
- func (s *Self) Groups(update ...bool) (Groups, error)
- func (s *Self) Members(update ...bool) (Members, error)
- func (s *Self) Mps(update ...bool) (Mps, error)
- func (s *Self) RemoveMemberFromGroup(group *Group, members Members) error
- func (s *Self) RevokeMessage(msg *SentMessage) error
- func (s *Self) SendFileToFriend(friend *Friend, file *os.File) (*SentMessage, error)
- func (s *Self) SendFileToGroup(group *Group, file *os.File) (*SentMessage, error)
- func (s *Self) SendImageToFriend(friend *Friend, file *os.File) (*SentMessage, error)
- func (s *Self) SendImageToGroup(group *Group, file *os.File) (*SentMessage, error)
- func (s *Self) SendMessageToFriend(friend *Friend, msg *SendMessage) (*SentMessage, error)
- func (s *Self) SendMessageToGroup(group *Group, msg *SendMessage) (*SentMessage, error)
- func (s *Self) SendTextToFriend(friend *Friend, text string) (*SentMessage, error)
- func (s *Self) SendTextToGroup(group *Group, text string) (*SentMessage, error)
- func (s *Self) SetRemarkNameToFriend(friend *Friend, remarkName string) error
- func (s *Self) UpdateMembersDetail() error
- type SendMessage
- type SentMessage
- type Storage
- type SyncCheckResponse
- type SyncKey
- type UploadResponse
- type User
- type UserAgentHook
- type UserDetailItem
- type UserDetailItemList
- type WebInitResponse
- type WebWxBatchContactResponse
- type WebWxContactResponse
- type WebWxSyncResponse
- type WechatDomain
Constants ¶
const ( TextMessage = 1 ImageMessage = 3 AppMessage = 6 )
消息类型
const ( MsgtypeText = 1 // 文本消息 MsgtypeImage = 3 // 图片消息 MsgtypeVoice = 34 // 语音消息 MsgtypeVerifymsg = 37 // 认证消息 MsgtypePossiblefriendMsg = 40 // 好友推荐消息 MsgtypeVideo = 43 // 视频消息 MsgtypeEmoticon = 47 // 表情消息 MsgtypeLocation = 48 // 地理位置消息 MsgtypeApp = 49 // APP消息 MsgtypeVoipmsg = 50 // voip msg //VOIP消息 MsgtypeVoipnotify = 52 // voip 结束消息 MsgtypeVoipinvite = 53 // voip 邀请 MsgtypeMicrovideo = 62 // 小视频消息 MsgtypeSys = 10000 // 系统消息 MsgtypeRecalled = 10002 // 消息撤回 )
https://res.wx.qq.com/a/wx_fed/webwx/res/static/js/index_c7d281c.js
varcaser.Caser{ From: varcaser.ScreamingSnakeCase, To: varcaser.UpperCamelCaseKeepCaps}
const ( MALE = 1 FEMALE = 2 )
性别
const ( Normal mode = "normal" Desktop mode = "desktop" // 突破网页版登录限制 )
向外暴露2种模式
const ALL = 0
ALL跟search函数搭配
friends.Search(openwechat.ALL, )
const TimeFormat = "Mon Jan 02 2006 15:04:05 GMT+0800 (中国标准时间)"
const ZombieText = "وُحfخe ̷̴̐nخg ̷̴̐cخh ̷̴̐aخo امارتيخ ̷̴̐خ\n"
ZombieText 检测僵尸好友字符串 发送该字符给好友,能正常发送不报错的为正常好友,否则为僵尸好友
Variables ¶
var Emoji = struct { Smile string Grimace string Drool string Scowl string CoolGuy string Sob string Shy string Silent string Sleep string Cry string Awkward string Angry string Tongue string Grin string Surprise string Frown string Ruthless string Blush string Scream string Puke string Chuckle string Joyful string Slight string Smug string Hungry string Drowsy string Panic string Sweat string Laugh string Commando string Determined string Scold string Shocked string Shhh string Dizzy string Tormented string Toasted string Skull string Hammer string Wave string Speechless string NosePick string Clap string Shame string Trick string BahL string BahR string Yawn string PoohPooh string Shrunken string TearingUp string Sly string Kiss string Wrath string Whimper string Cleaver string Watermelon string Beer string Basketball string PingPong string Coffee string Rice string Pig string Rose string Wilt string Lips string Heart string BrokenHeart string Cake string Lightning string Bomb string Dagger string Soccer string Ladybug string Poop string Moon string Sun string Gift string Hug string ThumbsUp string ThumbsDown string Shake string Peace string Fight string Beckon string Fist string Pinky string RockOn string Nuhuh string OK string InLove string Blowkiss string Waddle string Tremble string Aaagh string Twirl string Kotow string Dramatic string JumpRope string Surrender string Hooray string Meditate string Smooch string TaiChiL string TaiChiR string Hey string Facepalm string Smirk string Smart string Moue string Yeah string Tea string Packet string Candle string Blessing string Chick string Onlooker string GoForIt string Sweats string OMG string Emm string Respect string Doge string NoProb string MyBad string KeepFighting string Wow string Rich string Broken string Hurt string Sigh string LetMeSee string Awesome string Boring string }{}/* 134 elements not displayed */
emoji 表情 字段太多了,污染命名空间,封装成struct返回
Functions ¶
func DispatchMessage ¶
func DispatchMessage(dispatcher MessageDispatcher) func(msg *Message)
跟 MessageDispatcher 结合封装成 MessageHandler
func FormatEmoji ¶
func NewFileAppMessage ¶
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 { ScanCallBack func(body []byte) // 扫码回调,可获取扫码用户的头像 LoginCallBack func(body []byte) // 登陆回调 LogoutCallBack func(bot *Bot) // 退出回调 UUIDCallback func(uuid string) // 获取UUID的回调函数 MessageHandler MessageHandler // 获取消息成功的handle GetMessageErrorHandler func(err error) // 获取消息发生错误的handle Caller *Caller // contains filtered or unexported fields }
func DefaultBot ¶
func DefaultBot(modes ...mode) *Bot
默认的Bot的构造方法, mode不传入默认为openwechat.Normal,详情见mode
bot := openwechat.DefaultBot(openwechat.Desktop)
func (*Bot) GetCurrentUser ¶
获取当前的用户
self, err := bot.GetCurrentUser() if err != nil { return } fmt.Println(self.NickName)
func (*Bot) HotLogin ¶
func (b *Bot) HotLogin(storage HotReloadStorage, retry ...bool) error
热登录,可实现重复登录, retry设置为true可在热登录失效后进行普通登录行为
storage := NewJsonFileHotReloadStorage("storage.json") err := bot.HotLogin(storage, true) fmt.Println(err)
func (*Bot) MessageOnError ¶
setter for Bot.GetMessageErrorHandler
func (*Bot) MessageOnSuccess ¶
setter for Bot.MessageHandler
type Caller ¶
type Caller struct { Client *Client // contains filtered or unexported fields }
调用请求和解析请求 上层模块可以直接获取封装后的请求结果
func (*Caller) AddFriendIntoChatRoom ¶
func (c *Caller) AddFriendIntoChatRoom(req *BaseRequest, info *LoginInfo, group *Group, friends ...*Friend) error
拉好友入群
func (*Caller) CheckLogin ¶
func (c *Caller) CheckLogin(uuid string) (*CheckLoginResponse, error)
检查是否登录成功
func (*Caller) RemoveFriendFromChatRoom ¶
func (c *Caller) RemoveFriendFromChatRoom(req *BaseRequest, info *LoginInfo, group *Group, users ...*User) error
从群聊中移除用户
func (*Caller) SyncCheck ¶
func (c *Caller) SyncCheck(info *LoginInfo, response *WebInitResponse) (*SyncCheckResponse, error)
异步获取是否有新的消息
func (*Caller) UploadMedia ¶
func (c *Caller) UploadMedia(file *os.File, request *BaseRequest, info *LoginInfo, fromUserName, toUserName string) (*UploadResponse, 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) WebWxRevokeMsg ¶
func (c *Caller) WebWxRevokeMsg(msg *SentMessage, request *BaseRequest) error
撤回消息操作
func (*Caller) WebWxSendAppMsg ¶
func (c *Caller) WebWxSendAppMsg(msg *SendMessage, req *BaseRequest) (*SentMessage, error)
发送媒体消息
func (*Caller) WebWxSendFile ¶
func (c *Caller) WebWxSendFile(file *os.File, req *BaseRequest, info *LoginInfo, fromUserName, toUserName string) (*SentMessage, error)
func (*Caller) WebWxSendImageMsg ¶
func (c *Caller) WebWxSendImageMsg(file *os.File, request *BaseRequest, info *LoginInfo, fromUserName, toUserName string) (*SentMessage, error)
发送图片消息接口
func (*Caller) WebWxSendMsg ¶
func (c *Caller) WebWxSendMsg(msg *SendMessage, info *LoginInfo, request *BaseRequest) (*SentMessage, 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)
获取新的消息接口
func (*Caller) WebWxVerifyUser ¶
func (c *Caller) WebWxVerifyUser(storage *Storage, info RecommendInfo, verifyContent string) error
同意加好友请求
type Card ¶
type Card struct { XMLName xml.Name `xml:"msg"` ImageStatus int `xml:"imagestatus,attr"` Scene int `xml:"scene,attr"` Sex int `xml:"sex,attr"` Certflag int `xml:"certflag,attr"` BigHeadImgUrl string `xml:"bigheadimgurl,attr"` SmallHeadImgUrl string `xml:"smallheadimgurl,attr"` UserName string `xml:"username,attr"` NickName string `xml:"nickname,attr"` ShortPy string `xml:"shortpy,attr"` Alias string `xml:"alias,attr"` // Note: 这个是名片用户的微信号 Province string `xml:"province,attr"` City string `xml:"city,attr"` Sign string `xml:"sign,attr"` Certinfo string `xml:"certinfo,attr"` BrandIconUrl string `xml:"brandIconUrl,attr"` BrandHomeUr string `xml:"brandHomeUr,attr"` BrandSubscriptConfigUrl string `xml:"brandSubscriptConfigUrl,attr"` BrandFlags string `xml:"brandFlags,attr"` RegionCode string `xml:"regionCode,attr"` }
名片消息内容
type CheckLoginResponse ¶
type Client ¶
http请求客户端 客户端需要维持Session会话 并且客户端不允许跳转
func (*Client) AddHttpHook ¶
func (*Client) AddMemberIntoChatRoom ¶
func (c *Client) AddMemberIntoChatRoom(req *BaseRequest, info *LoginInfo, group *Group, friends ...*Friend) (*http.Response, error)
添加用户进群聊
func (*Client) GetCookieMap ¶
获取当前client的所有的有效的client
func (*Client) GetLoginInfo ¶
GetLoginInfo 请求获取LoginInfo
func (*Client) GetLoginQrcode ¶
获取登录的二维吗
func (*Client) RemoveMemberFromChatRoom ¶
func (c *Client) RemoveMemberFromChatRoom(req *BaseRequest, info *LoginInfo, group *Group, friends ...*User) (*http.Response, error)
从群聊中移除用户
func (*Client) WebInit ¶
func (c *Client) WebInit(request *BaseRequest) (*http.Response, error)
请求获取初始化信息
func (*Client) WebWxBatchGetContact ¶
func (c *Client) WebWxBatchGetContact(members Members, request *BaseRequest) (*http.Response, error)
获取联系人详情
func (*Client) WebWxGetContact ¶
获取联系人信息
func (*Client) WebWxGetHeadImg ¶
获取用户的头像
func (*Client) WebWxGetMedia ¶
获取文件消息的文件响应
func (*Client) WebWxGetMsgImg ¶
获取图片消息的图片响应
func (*Client) WebWxGetVideo ¶
获取视频消息的视频响应
func (*Client) WebWxGetVoice ¶
获取语音消息的语音响应
func (*Client) WebWxOplog ¶
func (c *Client) WebWxOplog(request *BaseRequest, remarkName, userName string) (*http.Response, error)
用户重命名接口
func (*Client) WebWxRevokeMsg ¶
func (c *Client) WebWxRevokeMsg(msg *SentMessage, request *BaseRequest) (*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) WebWxUploadMediaByChunk ¶
func (*Client) WebWxVerifyUser ¶
func (c *Client) WebWxVerifyUser(storage *Storage, info RecommendInfo, verifyContent string) (*http.Response, error)
添加用户为好友接口
type Friend ¶
type Friend struct{ *User }
func NewFriendHelper ¶
这里为了兼容Desktop版本找不到文件传输助手的问题 文件传输助手的微信身份标识符永远是filehelper 这种形式的对象可能缺少一些其他属性 但是不影响发送信息的功能
type FriendAddMessage ¶
type FriendAddMessage struct { XMLName xml.Name `xml:"msg"` Shortpy int `xml:"shortpy,attr"` ImageStatus int `xml:"imagestatus,attr"` Scene int `xml:"scene,attr"` PerCard int `xml:"percard,attr"` Sex int `xml:"sex,attr"` AlbumFlag int `xml:"albumflag,attr"` AlbumStyle int `xml:"albumstyle,attr"` SnsFlag int `xml:"snsflag,attr"` Opcode int `xml:"opcode,attr"` FromUserName string `xml:"fromusername,attr"` EncryptUserName string `xml:"encryptusername,attr"` FromNickName string `xml:"fromnickname,attr"` Content string `xml:"content,attr"` Country string `xml:"country,attr"` Province string `xml:"province,attr"` City string `xml:"city,attr"` Sign string `xml:"sign,attr"` Alias string `xml:"alias,attr"` WeiBo string `xml:"weibo,attr"` AlbumBgImgId string `xml:"albumbgimgid,attr"` SnsBgImgId string `xml:"snsbgimgid,attr"` SnsBgObjectId string `xml:"snsbgobjectid,attr"` MHash string `xml:"mhash,attr"` MFullHash string `xml:"mfullhash,attr"` BigHeadImgUrl string `xml:"bigheadimgurl,attr"` SmallHeadImgUrl string `xml:"smallheadimgurl,attr"` Ticket string `xml:"ticket,attr"` GoogleContact string `xml:"googlecontact,attr"` QrTicket string `xml:"qrticket,attr"` ChatRoomUserName string `xml:"chatroomusername,attr"` SourceUserName string `xml:"sourceusername,attr"` CardVersion string `xml:"cardversion,attr"` BrandList struct { Count int `xml:"count,attr"` Ver int64 `xml:"ver,attr"` } `xml:"brandlist"` }
好友添加消息信息内容
type Friends ¶
type Friends []*Friend
func (Friends) SearchByNickName ¶
根据昵称查找好友
func (Friends) SearchByRemarkName ¶
根据备注查找好友
func (Friends) SearchByUserName ¶
根据用户名查找好友
type Group ¶
type Group struct{ *User }
func (*Group) RemoveMembers ¶
从群聊中移除用户 Deprecated 无论是网页版,还是程序上都不起作用
func (*Group) SendImage ¶
func (g *Group) SendImage(file *os.File) (*SentMessage, error)
发行图片消息给当前的群组
type Groups ¶
type Groups []*Group
func (Groups) SearchByNickName ¶
根据昵称查找群组
func (Groups) SearchByRemarkName ¶
根据备注查找群组
func (Groups) SearchByUserName ¶
根据用户名查找群组
type HotReloadStorage ¶
type HotReloadStorage interface { GetHotReloadStorageItem() HotReloadStorageItem // 获取HotReloadStorageItem Dump(item HotReloadStorageItem) error // 实现该方法, 将必要信息进行序列化 Load() error // 实现该方法, 将存储媒介的内容反序列化 }
热登陆存储接口
type HotReloadStorageItem ¶
type HotReloadStorageItem struct { Cookies map[string][]*http.Cookie BaseRequest *BaseRequest LoginInfo *LoginInfo WechatDomain WechatDomain }
type HttpHook ¶
type HttpHook interface { BeforeRequest(req *http.Request) AfterRequest(response *http.Response, err error) }
请求上下文钩子
type JsonFileHotReloadStorage ¶
type JsonFileHotReloadStorage struct {
// contains filtered or unexported fields
}
实现HotReloadStorage接口 默认以json文件的形式存储
func NewJsonFileHotReloadStorage ¶
func NewJsonFileHotReloadStorage(filename string) *JsonFileHotReloadStorage
func (*JsonFileHotReloadStorage) Dump ¶
func (f *JsonFileHotReloadStorage) Dump(item HotReloadStorageItem) error
将信息写入json文件
func (*JsonFileHotReloadStorage) GetHotReloadStorageItem ¶
func (f *JsonFileHotReloadStorage) GetHotReloadStorageItem() HotReloadStorageItem
type LoginInfo ¶
type LoginInfo struct { Ret int `xml:"ret"` WxUin int `xml:"wxuin"` IsGrayScale int `xml:"isgrayscale"` Message string `xml:"message"` SKey string `xml:"skey"` WxSid string `xml:"wxsid"` PassTicket string `xml:"pass_ticket"` }
登录信息
type MPSubscribeMsg ¶
type MPSubscribeMsg struct { MPArticleCount int Time int64 UserName string NickName string MPArticleList []struct { Title string Cover string Digest string Url string } }
公众号的订阅信息
type Members ¶
type Members []*User
抽象的用户组
func (Members) SearchByNickName ¶
根据昵称查找
func (Members) SearchByRemarkName ¶
根据备注查找
func (Members) SearchByUserName ¶
根据用户名查找
type Message ¶
type Message struct { IsAt bool AppInfo struct { Type int AppID string } AppMsgType int HasProductId int ImgHeight int ImgStatus int ImgWidth int ForwardFlag int MsgType int Status int StatusNotifyCode int SubMsgType int VoiceLength int CreateTime int64 NewMsgId int64 PlayLength int64 MediaId string MsgId string EncryFileName string FileName string FileSize string Content string FromUserName string OriContent string StatusNotifyUserName string Ticket string ToUserName string Url string RecommendInfo RecommendInfo Bot *Bot Context context.Context // contains filtered or unexported fields }
func (*Message) FriendAddMessageContent ¶
func (m *Message) FriendAddMessageContent() (*FriendAddMessage, error)
获取FriendAddMessageContent内容
func (*Message) IsFriendAdd ¶
func (*Message) IsSysNotice ¶
func (*Message) Reply ¶
func (m *Message) Reply(msgType int, content, mediaId string) (*SentMessage, error)
回复消息
func (*Message) ReplyImage ¶
func (m *Message) ReplyImage(file *os.File) (*SentMessage, error)
回复图片消息
func (*Message) ReplyText ¶
func (m *Message) ReplyText(content string) (*SentMessage, error)
回复文本消息
type MessageContext ¶
type MessageContext struct { *Message // contains filtered or unexported fields }
MessageContext 消息处理上下文对象
type MessageContextHandler ¶
type MessageContextHandler func(ctx *MessageContext)
MessageMatchDispatcher 消息处理函数
type MessageContextHandlerGroup ¶
type MessageContextHandlerGroup []MessageContextHandler
type MessageDispatcher ¶
type MessageDispatcher interface {
Dispatch(msg *Message)
}
消息分发处理接口 跟 DispatchMessage 结合封装成 MessageHandler
type MessageMatchDispatcher ¶
type MessageMatchDispatcher struct {
// contains filtered or unexported fields
}
MessageMatchDispatcher impl MessageDispatcher interface
dispatcher := NewMessageMatchDispatcher() dispatcher.OnText(func(msg *Message){ msg.ReplyText("hello") }) bot := DefaultBot() bot.MessageHandler = DispatchMessage(dispatcher)
func NewMessageMatchDispatcher ¶
func NewMessageMatchDispatcher() *MessageMatchDispatcher
Constructor for MessageMatchDispatcher
func (*MessageMatchDispatcher) Dispatch ¶
func (m *MessageMatchDispatcher) Dispatch(msg *Message)
Dispatch impl MessageDispatcher 遍历 MessageMatchDispatcher 所有的消息处理函数 获取所有匹配上的函数 执行处理的消息处理方法
func (*MessageMatchDispatcher) OnCard ¶
func (m *MessageMatchDispatcher) OnCard(handlers ...MessageContextHandler)
注册处理消息类型为Card的处理函数
func (*MessageMatchDispatcher) OnFriend ¶
func (m *MessageMatchDispatcher) OnFriend(handlers ...MessageContextHandler)
注册发送者为好友的处理函数
func (*MessageMatchDispatcher) OnFriendAdd ¶
func (m *MessageMatchDispatcher) OnFriendAdd(handlers ...MessageContextHandler)
注册处理消息类型为FriendAdd的处理函数
func (*MessageMatchDispatcher) OnFriendByNickName ¶
func (m *MessageMatchDispatcher) OnFriendByNickName(nickName string, handlers ...MessageContextHandler)
注册根据好友昵称是否匹配的消息处理函数
func (*MessageMatchDispatcher) OnFriendByRemarkName ¶
func (m *MessageMatchDispatcher) OnFriendByRemarkName(remarkName string, handlers ...MessageContextHandler)
注册根据好友备注是否匹配的消息处理函数
func (*MessageMatchDispatcher) OnGroup ¶
func (m *MessageMatchDispatcher) OnGroup(handlers ...MessageContextHandler)
注册发送者为群组的处理函数
func (*MessageMatchDispatcher) OnGroupByGroupName ¶
func (m *MessageMatchDispatcher) OnGroupByGroupName(groupName string, handlers ...MessageContextHandler)
注册根据群名是否匹配的消息处理函数
func (*MessageMatchDispatcher) OnImage ¶
func (m *MessageMatchDispatcher) OnImage(handlers ...MessageContextHandler)
注册处理消息类型为Image的处理函数
func (*MessageMatchDispatcher) OnText ¶
func (m *MessageMatchDispatcher) OnText(handlers ...MessageContextHandler)
注册处理消息类型为Text的处理函数
func (*MessageMatchDispatcher) OnUser ¶
func (m *MessageMatchDispatcher) OnUser(f func(user *User) bool, handlers ...MessageContextHandler)
注册根据消息发送者的行为是否匹配的消息处理函数
func (*MessageMatchDispatcher) OnVoice ¶
func (m *MessageMatchDispatcher) OnVoice(handlers ...MessageContextHandler)
注册处理消息类型为Voice的处理函数
func (*MessageMatchDispatcher) RegisterHandler ¶
func (m *MessageMatchDispatcher) RegisterHandler(matchFunc matchFunc, handlers ...MessageContextHandler)
注册消息处理函数, 根据自己的需求自定义 matchFunc返回true则表示处理对应的handlers
func (*MessageMatchDispatcher) SetAsync ¶
func (m *MessageMatchDispatcher) SetAsync(async bool)
设置是否异步处理
type MessageResponse ¶
type MessageResponse struct { BaseResponse BaseResponse LocalID string MsgID string }
type RecommendInfo ¶
type RecommendInfo struct { OpCode int Scene int Sex int VerifyFlag int AttrStatus int64 QQNum int64 Alias string City string Content string NickName string Province string Signature string Ticket string UserName string }
一些特殊类型的消息会携带该结构体信息
type RevokeMsg ¶
type RevokeMsg struct { SysMsg xml.Name `xml:"sysmsg"` Type string `xml:"type,attr"` RevokeMsg struct { OldMsgId int64 `xml:"oldmsgid"` MsgId int64 `xml:"msgid"` Session string `xml:"session"` ReplaceMsg string `xml:"replacemsg"` } `xml:"revokemsg"` }
撤回消息Content
type Self ¶
自己,当前登录用户对象
func (*Self) AddFriendIntoManyGroups ¶
拉好友进多个群聊 AddFriendIntoGroups, 名字和上面的有点像
func (*Self) AddFriendsIntoGroup ¶
拉多名好友进群 最好自己是群主,成功率高一点,因为有的群允许非群组拉人,而有的群不允许
func (*Self) FileHelper ¶
获取文件传输助手对象,封装成Friend返回
fh, err := self.FileHelper() // or fh := openwechat.NewFriendHelper(self)
func (*Self) ForwardMessageToFriends ¶
func (s *Self) ForwardMessageToFriends(msg *SentMessage, friends ...*Friend) error
转发给好友
func (*Self) ForwardMessageToGroups ¶
func (s *Self) ForwardMessageToGroups(msg *SentMessage, groups ...*Group) error
转发给群组
func (*Self) RemoveMemberFromGroup ¶
从群聊中移除用户 Deprecated 无论是网页版,还是程序上都不起作用
func (*Self) RevokeMessage ¶
func (s *Self) RevokeMessage(msg *SentMessage) error
撤回消息
sentMessage, err := friend.SendText("message") if err == nil { self.RevokeMessage(sentMessage) // or sentMessage.Revoke() }
func (*Self) SendFileToFriend ¶
发送文件给好友
func (*Self) SendFileToGroup ¶
发送文件给群组
func (*Self) SendImageToFriend ¶
发送图片消息给好友
func (*Self) SendImageToGroup ¶
发送图片消息给群组
func (*Self) SendMessageToFriend ¶
func (s *Self) SendMessageToFriend(friend *Friend, msg *SendMessage) (*SentMessage, error)
发送消息给好友
func (*Self) SendMessageToGroup ¶
func (s *Self) SendMessageToGroup(group *Group, msg *SendMessage) (*SentMessage, error)
发送消息给群组
func (*Self) SendTextToFriend ¶
func (s *Self) SendTextToFriend(friend *Friend, text string) (*SentMessage, error)
发送文本消息给好友
func (*Self) SendTextToGroup ¶
func (s *Self) SendTextToGroup(group *Group, text string) (*SentMessage, error)
发送文本消息给群组
func (*Self) SetRemarkNameToFriend ¶
设置好友备注
self.SetRemarkNameToFriend(friend, "remark") // or friend.SetRemarkName("remark")
type SendMessage ¶
type SendMessage struct { Type int Content string FromUserName string ToUserName string LocalID string ClientMsgId string MediaId string `json:"MediaId,omitempty"` }
发送消息的结构体
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 SentMessage ¶
type SentMessage struct { *SendMessage Self *Self MsgId string }
已发送的信息
func (*SentMessage) ForwardToFriends ¶
func (s *SentMessage) ForwardToFriends(friends ...*Friend) error
转发该消息给好友
func (*SentMessage) ForwardToGroups ¶
func (s *SentMessage) ForwardToGroups(groups ...*Group) error
转发该消息给群组
type Storage ¶
type Storage struct { LoginInfo *LoginInfo Request *BaseRequest Response *WebInitResponse }
身份信息, 维持整个登陆的Session会话
type SyncCheckResponse ¶
func (*SyncCheckResponse) NorMal ¶
func (s *SyncCheckResponse) NorMal() bool
func (*SyncCheckResponse) Success ¶
func (s *SyncCheckResponse) Success() bool
type UploadResponse ¶
type UploadResponse struct { BaseResponse BaseResponse MediaId string }
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 IsOwner int MemberCount int ChatRoomId int UniFriend int OwnerUin int Statues int AttrStatus int Province string City string Alias string DisplayName string KeyWord string EncryChatRoomId string UserName string NickName string HeadImgUrl string RemarkName string PYInitial string PYQuanPin string RemarkPYInitial string RemarkPYQuanPin string Signature string MemberList Members Self *Self }
抽象的用户结构: 好友 群组 公众号
type UserAgentHook ¶
type UserAgentHook struct{}
func (UserAgentHook) AfterRequest ¶
func (u UserAgentHook) AfterRequest(response *http.Response, err error)
func (UserAgentHook) BeforeRequest ¶
func (u UserAgentHook) BeforeRequest(req *http.Request)
type UserDetailItem ¶
type UserDetailItemList ¶
type UserDetailItemList []UserDetailItem
func NewUserDetailItemList ¶
func NewUserDetailItemList(members Members) UserDetailItemList
type WebInitResponse ¶
type WebInitResponse struct { Count int ClientVersion int GrayScale int InviteStartCount int MPSubscribeMsgCount int ClickReportInterval int SystemTime int64 ChatSet string SKey string BaseResponse BaseResponse SyncKey SyncKey User User MPSubscribeMsgList []MPSubscribeMsg ContactList []User }
初始化的相应信息
type WebWxBatchContactResponse ¶
type WebWxBatchContactResponse struct { Count int BaseResponse BaseResponse ContactList []*User }
type WebWxContactResponse ¶
type WebWxContactResponse struct { MemberCount int Seq int BaseResponse BaseResponse MemberList []*User }
type WebWxSyncResponse ¶
type WechatDomain ¶
type WechatDomain string
func (WechatDomain) BaseHost ¶
func (w WechatDomain) BaseHost() string
func (WechatDomain) FileHost ¶
func (w WechatDomain) FileHost() string
func (WechatDomain) SyncHost ¶
func (w WechatDomain) SyncHost() string