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 IgnoreNetworkError(errHandler func(err error)) func(error)
- func IsNetworkError(err error) bool
- func NewFileAppMessage(stat os.FileInfo, attachId string) *appmsg
- func NewJsonFileHotReloadStorage(filename string) io.ReadWriteCloser
- func PrintlnQrcodeUrl(uuid string)
- func ToBuffer(v interface{}) (*bytes.Buffer, error)
- type AppMessageData
- type AppMessageType
- 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) DumpTo(writer io.Writer) error
- func (b *Bot) Exit()
- func (b *Bot) GetCurrentUser() (*Self, error)
- func (b *Bot) HandleLogin(data []byte) error
- func (b *Bot) HotLogin(storage HotReloadStorage, retries ...bool) error
- func (b *Bot) IsHot() bool
- func (b *Bot) Login() error
- func (b *Bot) LoginWithUUID(uuid string) error
- func (b *Bot) Logout() error
- func (b *Bot) MessageOnError(h func(err error) bool)
- func (b *Bot) MessageOnSuccess(h func(msg *Message))
- func (b *Bot) OnLogin(f func(body []byte))
- func (b *Bot) OnLogout(f func(bot *Bot))
- func (b *Bot) OnScanned(f func(body []byte))
- func (b *Bot) SetDeviceId(deviceId string)
- func (b *Bot) UUID() string
- func (b *Bot) WebInit() error
- 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(request *BaseRequest, 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) WebWxCreateChatRoom(request *BaseRequest, info *LoginInfo, topic string, friends Friends) (*Group, error)
- func (c *Caller) WebWxGetContact(info *LoginInfo) (Members, error)
- func (c *Caller) WebWxOplog(request *BaseRequest, remarkName, toUserName string) error
- func (c *Caller) WebWxPushLogin(uin int) (*PushLoginResponse, error)
- func (c *Caller) WebWxRelationPin(request *BaseRequest, user *User, op uint8) error
- func (c *Caller) WebWxRenameChatRoom(request *BaseRequest, info *LoginInfo, newTopic string, group *Group) 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) WebWxSendVideoMsg(file *os.File, request *BaseRequest, info *LoginInfo, ...) (*SentMessage, error)
- func (c *Caller) WebWxStatusAsRead(request *BaseRequest, info *LoginInfo, msg *Message) 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) SetMode(mode Mode)
- func (c *Client) SyncCheck(request *BaseRequest, 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) WebWxCreateChatRoom(request *BaseRequest, info *LoginInfo, topic string, friends Friends) (*http.Response, error)
- func (c *Client) WebWxGetContact(info *LoginInfo, reqs int64) (*http.Response, error)
- func (c *Client) WebWxGetHeadImg(user *User) (*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) WebWxPushLogin(uin int) (*http.Response, error)
- func (c *Client) WebWxRelationPin(request *BaseRequest, op uint8, user *User) (*http.Response, error)
- func (c *Client) WebWxRenameChatRoom(request *BaseRequest, info *LoginInfo, newTopic string, group *Group) (*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) WebWxSendVideoMsg(request *BaseRequest, msg *SendMessage) (*http.Response, error)
- func (c *Client) WebWxStatusAsRead(request *BaseRequest, info *LoginInfo, msg *Message) (*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) SendText(content string) (*SentMessage, error)
- func (f *Friend) SendVideo(file *os.File) (*SentMessage, error)
- func (f *Friend) SetRemarkName(name string) error
- func (f Friend) String() string
- type FriendAddMessage
- type Friends
- func (f Friends) AsMembers() Members
- func (f Friends) Count() int
- func (f Friends) First() *Friend
- func (f Friends) GetByNickName(nickname string) *Friend
- func (f Friends) GetByRemarkName(remarkName string) *Friend
- func (f Friends) GetByUsername(username string) *Friend
- func (f Friends) Last() *Friend
- func (f Friends) Search(limit int, searchFuncList ...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, delays ...time.Duration) error
- func (f Friends) SendText(text string, delays ...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) Rename(name string) error
- func (g *Group) SearchMemberByUsername(username string) (*User, error)
- func (g *Group) SendFile(file *os.File) (*SentMessage, error)
- func (g *Group) SendImage(file *os.File) (*SentMessage, error)
- func (g *Group) SendText(content string) (*SentMessage, error)
- func (g *Group) SendVideo(file *os.File) (*SentMessage, error)
- func (g Group) String() string
- type Groups
- func (g Groups) AsMembers() Members
- func (g Groups) Count() int
- func (g Groups) First() *Group
- func (g Groups) GetByNickName(nickname string) *Group
- func (g Groups) GetByRemarkName(remarkName string) *Group
- func (g Groups) GetByUsername(username string) *Group
- func (g Groups) Last() *Group
- func (g Groups) Search(limit int, searchFuncList ...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) SendFile(file *os.File, delay ...time.Duration) error
- func (g Groups) SendImage(file *os.File, delay ...time.Duration) error
- func (g Groups) SendText(text string, delay ...time.Duration) error
- type HotReloadStorage
- type HotReloadStorageItem
- type HttpHook
- type HttpHooks
- type LoginInfo
- type MPSubscribeMsg
- type MatchFunc
- func MatchFuncList(matchFuncs ...MatchFunc) MatchFunc
- func SenderFriendRequired() MatchFunc
- func SenderGroupRequired() MatchFunc
- func SenderMatchFunc(matchFuncs ...MessageSenderMatchFunc) MatchFunc
- func SenderMpRequired() MatchFunc
- func SenderNickNameContainsMatchFunc(nickname string) MatchFunc
- func SenderNickNameEqualMatchFunc(nickname string) MatchFunc
- func SenderRemakeNameContainsFunc(remakeName string) MatchFunc
- func SenderRemarkNameEqualMatchFunc(remarkName string) MatchFunc
- type Members
- func (m Members) Count() int
- func (m Members) First() *User
- func (m Members) Friends() Friends
- func (m Members) GetByNickName(nickname string) (*User, bool)
- func (m Members) GetByRemarkName(remarkName string) (*User, bool)
- func (m Members) GetByUserName(username string) (*User, bool)
- func (m Members) Groups() Groups
- func (m Members) Last() *User
- func (m Members) MPs() Mps
- func (m Members) Search(limit int, searchFuncList ...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)
- type Message
- func (m *Message) Agree(verifyContents ...string) (*Friend, error)
- func (m *Message) AsRead() 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) GetMedia() (*http.Response, error)
- func (m *Message) GetPicture() (*http.Response, error)
- func (m *Message) GetVideo() (*http.Response, error)
- func (m *Message) GetVoice() (*http.Response, error)
- func (m *Message) HasFile() bool
- func (m *Message) IsArticle() bool
- func (m *Message) IsAt() bool
- func (m *Message) IsCard() bool
- func (m *Message) IsComeFromGroup() bool
- func (m *Message) IsEmoticon() bool
- func (m *Message) IsFriendAdd() bool
- func (m *Message) IsJoinGroup() bool
- func (m *Message) IsLocation() bool
- func (m *Message) IsMedia() bool
- func (m *Message) IsNotify() bool
- func (m *Message) IsPaiYiPai() bool
- func (m *Message) IsPicture() bool
- func (m *Message) IsRealtimeLocation() bool
- func (m *Message) IsRealtimeLocationStart() bool
- func (m *Message) IsRealtimeLocationStop() bool
- func (m *Message) IsRecalled() bool
- func (m *Message) IsReceiveRedPacket() bool
- func (m *Message) IsRenameGroup() 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) IsTickled() bool
- func (m *Message) IsTransferAccounts() bool
- func (m *Message) IsVideo() bool
- func (m *Message) IsVoice() bool
- func (m *Message) IsVoipInvite() bool
- func (m *Message) MediaData() (*AppMessageData, error)
- func (m *Message) Receiver() (*User, 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) ReplyVideo(file *os.File) (*SentMessage, error)
- func (m *Message) RevokeMsg() (*RevokeMsg, error)
- func (m *Message) SaveFile(writer io.Writer) error
- func (m *Message) SaveFileToLocal(filename string) 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
- func (m *Message) String() string
- type MessageContext
- type MessageContextHandler
- type MessageContextHandlerGroup
- type MessageDispatcher
- type MessageHandler
- type MessageMatchDispatcher
- func (m *MessageMatchDispatcher) AsMessageHandler() MessageHandler
- func (m *MessageMatchDispatcher) Dispatch(msg *Message)
- func (m *MessageMatchDispatcher) OnCard(handlers ...MessageContextHandler)
- func (m *MessageMatchDispatcher) OnEmoticon(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) OnMedia(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 MessageResponseParser
- type MessageSenderMatchFunc
- type MessageType
- type Mode
- type Mp
- type Mps
- func (m Mps) AsMembers() Members
- func (m Mps) Count() int
- func (m Mps) First() *Mp
- func (m Mps) GetByNickName(nickname string) *Mp
- func (m Mps) GetByUserName(username string) *Mp
- func (m Mps) Last() *Mp
- func (m Mps) Search(limit int, searchFuncList ...func(group *Mp) bool) (results Mps)
- func (m Mps) SearchByNickName(limit int, nickName string) (results Mps)
- func (m Mps) SearchByUserName(limit int, userName string) (results Mps)
- type PushLoginResponse
- type RecommendInfo
- type Ret
- 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) CreateGroup(topic string, friends ...*Friend) (*Group, error)
- func (s *Self) FileHelper() *Friend
- func (s *Self) ForwardMessageToFriends(msg *SentMessage, delay time.Duration, friends ...*Friend) error
- func (s *Self) ForwardMessageToGroups(msg *SentMessage, delay time.Duration, 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) RenameGroup(group *Group, newName string) error
- func (s *Self) RevokeMessage(msg *SentMessage) error
- func (s *Self) SendFileToFriend(friend *Friend, file *os.File) (*SentMessage, error)
- func (s *Self) SendFileToFriends(file *os.File, delay time.Duration, friends ...*Friend) error
- func (s *Self) SendFileToGroup(group *Group, file *os.File) (*SentMessage, error)
- func (s *Self) SendFileToGroups(file *os.File, delay time.Duration, groups ...*Group) error
- func (s *Self) SendFileToMp(mp *Mp, file *os.File) (*SentMessage, error)
- func (s *Self) SendImageToFriend(friend *Friend, file *os.File) (*SentMessage, error)
- func (s *Self) SendImageToFriends(img *os.File, delay time.Duration, friends ...*Friend) error
- func (s *Self) SendImageToGroup(group *Group, file *os.File) (*SentMessage, error)
- func (s *Self) SendImageToGroups(img *os.File, delay time.Duration, groups ...*Group) error
- func (s *Self) SendImageToMp(mp *Mp, file *os.File) (*SentMessage, error)
- func (s *Self) SendTextToFriend(friend *Friend, text string) (*SentMessage, error)
- func (s *Self) SendTextToFriends(text string, delay time.Duration, friends ...*Friend) error
- func (s *Self) SendTextToGroup(group *Group, text string) (*SentMessage, error)
- func (s *Self) SendTextToGroups(text string, delay time.Duration, groups ...*Group) error
- func (s *Self) SendTextToMp(mp *Mp, text string) (*SentMessage, error)
- func (s *Self) SendVideoToFriend(friend *Friend, file *os.File) (*SentMessage, error)
- func (s *Self) SendVideoToFriends(video *os.File, delay time.Duration, friends ...*Friend) error
- func (s *Self) SendVideoToGroup(group *Group, file *os.File) (*SentMessage, error)
- func (s *Self) SendVideoToGroups(video *os.File, delay time.Duration, groups ...*Group) error
- func (s *Self) SendVideoToMp(mp *Mp, file *os.File) (*SentMessage, error)
- func (s *Self) SetRemarkNameToFriend(friend *Friend, remarkName string) error
- func (s *Self) UpdateMembersDetail() error
- type SendMessage
- type SentMessage
- func (s *SentMessage) CanRevoke() bool
- func (s *SentMessage) ForwardToFriends(friends ...*Friend) error
- func (s *SentMessage) ForwardToFriendsWithDelay(delay time.Duration, friends ...*Friend) error
- func (s *SentMessage) ForwardToGroups(groups ...*Group) error
- func (s *SentMessage) ForwardToGroupsWithDelay(delay time.Duration, groups ...*Group) error
- func (s *SentMessage) Revoke() error
- type Storage
- type SyncCheckResponse
- type SyncKey
- type UploadResponse
- type User
- func (u *User) Detail() error
- func (u *User) GetAvatarResponse() (resp *http.Response, err error)
- func (u *User) ID() string
- func (u *User) IsFriend() bool
- func (u *User) IsGroup() bool
- func (u *User) IsMP() bool
- func (u *User) IsPin() bool
- func (u *User) Pin() error
- func (u *User) SaveAvatar(filename string) error
- func (u *User) SaveAvatarWithWriter(writer io.Writer) error
- func (u *User) String() string
- func (u *User) UnPin() error
- type UserAgentHook
- type UserDetailItem
- type UserDetailItemList
- type WebInitResponse
- type WebWxBatchContactResponse
- type WebWxContactResponse
- type WebWxSyncResponse
- type WechatDomain
Examples ¶
Constants ¶
const ( StatusSuccess = "200" StatusScanned = "201" StatusTimeout = "400" StatusWait = "408" )
登录状态
const ( MALE = 1 FEMALE = 2 )
性别
const ALL = 0
ALL 跟search函数搭配
friends.Search(openwechat.ALL, )
const (
AppMessage = 6
)
消息类型
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 ( // ErrForbidden 禁止当前账号登录 ErrForbidden = errors.New("login forbidden") // ErrInvalidStorage define invalid storage error ErrInvalidStorage = errors.New("invalid storage") // NetworkErr define wechat network error NetworkErr = errors.New("wechat network error") )
var ( ErrNoSuchUserFoundError = errors.New("no such user found") ErrLoginTimeout = errors.New("login timeout") )
errors
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)
DispatchMessage 跟 MessageDispatcher 结合封装成 MessageHandler Deprecated: use MessageMatchDispatcher.AsMessageHandler instead
func FormatEmoji ¶
func GetFileContentType ¶
GetFileContentType 获取文件上传的类型
func IgnoreNetworkError ¶
IgnoreNetworkError 忽略网络请求的错误
func IsNetworkError ¶
func NewFileAppMessage ¶
func NewJsonFileHotReloadStorage ¶
func NewJsonFileHotReloadStorage(filename string) io.ReadWriteCloser
NewJsonFileHotReloadStorage 创建JsonFileHotReloadStorage
Types ¶
type AppMessageData ¶
type AppMessageData struct { XMLName xml.Name `xml:"msg"` AppMsg struct { Appid string `xml:"appid,attr"` SdkVer string `xml:"sdkver,attr"` Title string `xml:"title"` Des string `xml:"des"` Action string `xml:"action"` Type AppMessageType `xml:"type"` ShowType string `xml:"showtype"` Content string `xml:"content"` URL string `xml:"url"` DataUrl string `xml:"dataurl"` LowUrl string `xml:"lowurl"` LowDataUrl string `xml:"lowdataurl"` RecordItem string `xml:"recorditem"` ThumbUrl string `xml:"thumburl"` MessageAction string `xml:"messageaction"` Md5 string `xml:"md5"` ExtInfo string `xml:"extinfo"` SourceUsername string `xml:"sourceusername"` SourceDisplayName string `xml:"sourcedisplayname"` CommentUrl string `xml:"commenturl"` AppAttach struct { TotalLen string `xml:"totallen"` AttachId string `xml:"attachid"` EmoticonMd5 string `xml:"emoticonmd5"` FileExt string `xml:"fileext"` FileUploadToken string `xml:"fileuploadtoken"` OverwriteNewMsgId string `xml:"overwrite_newmsgid"` FileKey string `xml:"filekey"` CdnAttachUrl string `xml:"cdnattachurl"` AesKey string `xml:"aeskey"` EncryVer string `xml:"encryver"` } `xml:"appattach"` WeAppInfo struct { PagePath string `xml:"pagepath"` Username string `xml:"username"` Appid string `xml:"appid"` AppServiceType string `xml:"appservicetype"` } `xml:"weappinfo"` WebSearch string `xml:"websearch"` } `xml:"appmsg"` FromUsername string `xml:"fromusername"` Scene string `xml:"scene"` AppInfo struct { Version string `xml:"version"` AppName string `xml:"appname"` } `xml:"appinfo"` CommentUrl string `xml:"commenturl"` }
AppMessageData 获取APP消息的正文 See https://github.com/eatmoreapple/openwechat/issues/62
func (*AppMessageData) IsArticle ¶
func (a *AppMessageData) IsArticle() bool
IsArticle 判断当前的消息类型是否为文章
func (*AppMessageData) IsFromApplet ¶
func (a *AppMessageData) IsFromApplet() bool
IsFromApplet 判断当前的消息类型是否来自小程序
type AppMessageType ¶
type AppMessageType int
AppMessageType 以Go惯用形式定义了PC微信所有的官方App消息类型。
const ( AppMsgTypeText AppMessageType = 1 // 文本消息 AppMsgTypeImg AppMessageType = 2 // 图片消息 AppMsgTypeAudio AppMessageType = 3 // 语音消息 AppMsgTypeVideo AppMessageType = 4 // 视频消息 AppMsgTypeUrl AppMessageType = 5 // 文章消息 AppMsgTypeAttach AppMessageType = 6 // 附件消息 AppMsgTypeOpen AppMessageType = 7 // Open AppMsgTypeEmoji AppMessageType = 8 // 表情消息 AppMsgTypeVoiceRemind AppMessageType = 9 // VoiceRemind AppMsgTypeScanGood AppMessageType = 10 // ScanGood AppMsgTypeGood AppMessageType = 13 // Good AppMsgTypeEmotion AppMessageType = 15 // Emotion AppMsgTypeCardTicket AppMessageType = 16 // 名片消息 AppMsgTypeTransfers AppMessageType = 2000 // 转账消息 AppMsgTypeRedEnvelopes AppMessageType = 2001 // 红包消息 AppMsgTypeReaderType AppMessageType = 100001 //自定义的消息 )
func (AppMessageType) String ¶
func (i AppMessageType) String() string
type BaseRequest ¶
BaseRequest 初始的请求信息 几乎所有的请求都要携带该参数
type BaseResponse ¶
BaseResponse 大部分返回对象都携带该信息
func (BaseResponse) Err ¶
func (b BaseResponse) Err() error
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的回调函数 SyncCheckCallback func(resp SyncCheckResponse) // 心跳回调 MessageHandler MessageHandler // 获取消息成功的handle MessageErrorHandler func(err error) bool // 获取消息发生错误的handle, 返回true则尝试继续监听 Caller *Caller Storage *Storage // contains filtered or unexported fields }
func DefaultBot ¶
DefaultBot 默认的Bot的构造方法, mode不传入默认为 openwechat.Desktop,详情见mode
bot := openwechat.DefaultBot(openwechat.Desktop)
func (*Bot) DumpHotReloadStorage ¶
DumpHotReloadStorage 写入HotReloadStorage
func (*Bot) GetCurrentUser ¶
GetCurrentUser 获取当前的用户
self, err := bot.GetCurrentUser() if err != nil { return } fmt.Println(self.NickName)
func (*Bot) HotLogin ¶
func (b *Bot) HotLogin(storage HotReloadStorage, retries ...bool) error
HotLogin 热登录,可实现重复登录, retry设置为true可在热登录失效后进行普通登录行为
Storage := NewJsonFileHotReloadStorage("Storage.json") err := bot.HotLogin(Storage, true) fmt.Println(err)
func (*Bot) LoginWithUUID ¶
LoginWithUUID 用户登录 该方法会一直阻塞,直到用户扫码登录,或者二维码过期
func (*Bot) MessageOnError ¶
MessageOnError setter for Bot.GetMessageErrorHandler
func (*Bot) MessageOnSuccess ¶
MessageOnSuccess setter for Bot.MessageHandler
func (*Bot) SetDeviceId ¶
SetDeviceId @description: 设置设备Id @receiver b @param deviceId
type Caller ¶
type Caller struct {
Client *Client
}
Caller 调用请求和解析请求 上层模块可以直接获取封装后的请求结果
func (*Caller) AddFriendIntoChatRoom ¶
func (c *Caller) AddFriendIntoChatRoom(req *BaseRequest, info *LoginInfo, group *Group, friends ...*Friend) error
AddFriendIntoChatRoom 拉好友入群
func (*Caller) CheckLogin ¶
func (c *Caller) CheckLogin(uuid string) (*CheckLoginResponse, error)
CheckLogin 检查是否登录成功
func (*Caller) GetLoginInfo ¶
GetLoginInfo 获取登录信息
func (*Caller) GetLoginUUID ¶
GetLoginUUID 获取登录的uuid
func (*Caller) RemoveFriendFromChatRoom ¶
func (c *Caller) RemoveFriendFromChatRoom(req *BaseRequest, info *LoginInfo, group *Group, users ...*User) error
RemoveFriendFromChatRoom 从群聊中移除用户
func (*Caller) SyncCheck ¶
func (c *Caller) SyncCheck(request *BaseRequest, info *LoginInfo, response *WebInitResponse) (*SyncCheckResponse, error)
SyncCheck 异步获取是否有新的消息
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)
WebInit 获取初始化信息
func (*Caller) WebWxBatchGetContact ¶
func (c *Caller) WebWxBatchGetContact(members Members, request *BaseRequest) (Members, error)
WebWxBatchGetContact 获取联系人的详情 注: Members参数的长度不要大于50
func (*Caller) WebWxCreateChatRoom ¶
func (c *Caller) WebWxCreateChatRoom(request *BaseRequest, info *LoginInfo, topic string, friends Friends) (*Group, error)
WebWxCreateChatRoom 创建群聊
func (*Caller) WebWxGetContact ¶
WebWxGetContact 获取所有的联系人
func (*Caller) WebWxOplog ¶
func (c *Caller) WebWxOplog(request *BaseRequest, remarkName, toUserName string) error
WebWxOplog 修改用户备注接口
func (*Caller) WebWxPushLogin ¶
func (c *Caller) WebWxPushLogin(uin int) (*PushLoginResponse, error)
WebWxPushLogin 免扫码登陆接口
func (*Caller) WebWxRelationPin ¶
func (c *Caller) WebWxRelationPin(request *BaseRequest, user *User, op uint8) error
WebWxRelationPin 将联系人是否置顶
func (*Caller) WebWxRenameChatRoom ¶
func (c *Caller) WebWxRenameChatRoom(request *BaseRequest, info *LoginInfo, newTopic string, group *Group) error
WebWxRenameChatRoom 群组重命名
func (*Caller) WebWxRevokeMsg ¶
func (c *Caller) WebWxRevokeMsg(msg *SentMessage, request *BaseRequest) error
WebWxRevokeMsg 撤回消息操作
func (*Caller) WebWxSendAppMsg ¶
func (c *Caller) WebWxSendAppMsg(msg *SendMessage, req *BaseRequest) (*SentMessage, error)
WebWxSendAppMsg 发送媒体消息
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)
WebWxSendImageMsg 发送图片消息接口
func (*Caller) WebWxSendMsg ¶
func (c *Caller) WebWxSendMsg(msg *SendMessage, info *LoginInfo, request *BaseRequest) (*SentMessage, error)
WebWxSendMsg 发送消息接口
func (*Caller) WebWxSendVideoMsg ¶
func (c *Caller) WebWxSendVideoMsg(file *os.File, request *BaseRequest, info *LoginInfo, fromUserName, toUserName string) (*SentMessage, error)
func (*Caller) WebWxStatusAsRead ¶
func (c *Caller) WebWxStatusAsRead(request *BaseRequest, info *LoginInfo, msg *Message) error
WebWxStatusAsRead 将消息设置为已读
func (*Caller) WebWxStatusNotify ¶
func (c *Caller) WebWxStatusNotify(request *BaseRequest, response *WebInitResponse, info *LoginInfo) error
WebWxStatusNotify 通知手机已登录
func (*Caller) WebWxSync ¶
func (c *Caller) WebWxSync(request *BaseRequest, response *WebInitResponse, info *LoginInfo) (*WebWxSyncResponse, error)
WebWxSync 获取新的消息接口
func (*Caller) WebWxVerifyUser ¶
func (c *Caller) WebWxVerifyUser(storage *Storage, info RecommendInfo, verifyContent string) error
WebWxVerifyUser 同意加好友请求
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"` }
Card 名片消息内容
type CheckLoginResponse ¶
type Client ¶
type Client struct { HttpHooks HttpHooks *http.Client Domain WechatDomain MaxRetryTimes int // contains filtered or unexported fields }
Client http请求客户端 客户端需要维持Session会话 并且客户端不允许跳转
func (*Client) AddHttpHook ¶
func (*Client) AddMemberIntoChatRoom ¶
func (c *Client) AddMemberIntoChatRoom(req *BaseRequest, info *LoginInfo, group *Group, friends ...*Friend) (*http.Response, error)
AddMemberIntoChatRoom 添加用户进群聊
func (*Client) CheckLogin ¶
CheckLogin 检查是否登录
func (*Client) GetCookieMap ¶
GetCookieMap 获取当前client的所有的有效的client
func (*Client) GetLoginInfo ¶
GetLoginInfo 请求获取LoginInfo
func (*Client) GetLoginQrcode ¶
GetLoginQrcode 获取登录的二维吗
func (*Client) GetLoginUUID ¶
GetLoginUUID 获取登录的uuid
func (*Client) RemoveMemberFromChatRoom ¶
func (c *Client) RemoveMemberFromChatRoom(req *BaseRequest, info *LoginInfo, group *Group, friends ...*User) (*http.Response, error)
RemoveMemberFromChatRoom 从群聊中移除用户
func (*Client) SyncCheck ¶
func (c *Client) SyncCheck(request *BaseRequest, info *LoginInfo, response *WebInitResponse) (*http.Response, error)
SyncCheck 异步检查是否有新的消息返回
func (*Client) WebInit ¶
func (c *Client) WebInit(request *BaseRequest) (*http.Response, error)
WebInit 请求获取初始化信息
func (*Client) WebWxBatchGetContact ¶
func (c *Client) WebWxBatchGetContact(members Members, request *BaseRequest) (*http.Response, error)
WebWxBatchGetContact 获取联系人详情
func (*Client) WebWxCreateChatRoom ¶
func (c *Client) WebWxCreateChatRoom(request *BaseRequest, info *LoginInfo, topic string, friends Friends) (*http.Response, error)
WebWxCreateChatRoom 创建群聊
func (*Client) WebWxGetContact ¶
WebWxGetContact 获取联系人信息
func (*Client) WebWxGetHeadImg ¶
WebWxGetHeadImg 获取用户的头像
func (*Client) WebWxGetMedia ¶
WebWxGetMedia 获取文件消息的文件响应
func (*Client) WebWxGetMsgImg ¶
WebWxGetMsgImg 获取图片消息的图片响应
func (*Client) WebWxGetVideo ¶
WebWxGetVideo 获取视频消息的视频响应
func (*Client) WebWxGetVoice ¶
WebWxGetVoice 获取语音消息的语音响应
func (*Client) WebWxOplog ¶
func (c *Client) WebWxOplog(request *BaseRequest, remarkName, userName string) (*http.Response, error)
WebWxOplog 用户重命名接口
func (*Client) WebWxPushLogin ¶
WebWxPushLogin 免扫码登陆接口
func (*Client) WebWxRelationPin ¶
func (c *Client) WebWxRelationPin(request *BaseRequest, op uint8, user *User) (*http.Response, error)
WebWxRelationPin 联系人置顶接口
func (*Client) WebWxRenameChatRoom ¶
func (c *Client) WebWxRenameChatRoom(request *BaseRequest, info *LoginInfo, newTopic string, group *Group) (*http.Response, error)
WebWxRenameChatRoom 群组重命名接口
func (*Client) WebWxRevokeMsg ¶
func (c *Client) WebWxRevokeMsg(msg *SentMessage, request *BaseRequest) (*http.Response, error)
WebWxRevokeMsg 撤回消息
func (*Client) WebWxSendAppMsg ¶
func (c *Client) WebWxSendAppMsg(msg *SendMessage, request *BaseRequest) (*http.Response, error)
WebWxSendAppMsg 发送文件信息
func (*Client) WebWxSendMsg ¶
func (c *Client) WebWxSendMsg(msg *SendMessage, info *LoginInfo, request *BaseRequest) (*http.Response, error)
WebWxSendMsg 发送文本消息
func (*Client) WebWxSendMsgImg ¶
func (c *Client) WebWxSendMsgImg(msg *SendMessage, request *BaseRequest, info *LoginInfo) (*http.Response, error)
WebWxSendMsgImg 发送图片 这个接口依赖上传文件的接口 发送的图片必须是已经成功上传的图片
func (*Client) WebWxSendVideoMsg ¶
func (c *Client) WebWxSendVideoMsg(request *BaseRequest, msg *SendMessage) (*http.Response, error)
WebWxSendVideoMsg 发送视频消息接口
func (*Client) WebWxStatusAsRead ¶
func (*Client) WebWxStatusNotify ¶
func (c *Client) WebWxStatusNotify(request *BaseRequest, response *WebInitResponse, info *LoginInfo) (*http.Response, error)
WebWxStatusNotify 通知手机已登录
func (*Client) WebWxSync ¶
func (c *Client) WebWxSync(request *BaseRequest, response *WebInitResponse, info *LoginInfo) (*http.Response, error)
WebWxSync 获取消息接口
func (*Client) WebWxUploadMediaByChunk ¶
func (*Client) WebWxVerifyUser ¶
func (c *Client) WebWxVerifyUser(storage *Storage, info RecommendInfo, verifyContent string) (*http.Response, error)
WebWxVerifyUser 添加用户为好友接口
type Friend ¶
type Friend struct{ *User }
func NewFriendHelper ¶
NewFriendHelper 创建一个文件传输助手 文件传输助手的微信身份标识符永远是filehelper
func (*Friend) AddIntoGroup ¶
AddIntoGroup 拉该好友入群
func (*Friend) SendFile ¶
func (f *Friend) SendFile(file *os.File) (*SentMessage, error)
SendFile 发送文件消息
func (*Friend) SendImage ¶
func (f *Friend) SendImage(file *os.File) (*SentMessage, error)
SendImage 发送图片消息
func (*Friend) SendText ¶
func (f *Friend) SendText(content string) (*SentMessage, error)
SendText 发送文本消息
func (*Friend) SendVideo ¶
func (f *Friend) SendVideo(file *os.File) (*SentMessage, error)
SendVideo 发送视频消息
func (*Friend) SetRemarkName ¶
SetRemarkName 重命名当前好友
type FriendAddMessage ¶
type FriendAddMessage struct { XMLName xml.Name `xml:"msg"` Shortpy string `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"` }
FriendAddMessage 好友添加消息信息内容
type Friends ¶
type Friends []*Friend
func (Friends) GetByNickName ¶
GetByNickName 根据nickname查询一个Friend
func (Friends) GetByRemarkName ¶
GetByRemarkName 根据remarkName查询一个Friend
func (Friends) GetByUsername ¶
GetByUsername 根据username查询一个Friend
func (Friends) SearchByNickName ¶
SearchByNickName 根据昵称查找好友
func (Friends) SearchByRemarkName ¶
SearchByRemarkName 根据备注查找好友
func (Friends) SearchByUserName ¶
SearchByUserName 根据用户名查找好友
type Group ¶
type Group struct{ *User }
func (*Group) AddFriendsIn ¶
AddFriendsIn 拉好友入群
func (*Group) RemoveMembers ¶
RemoveMembers 从群聊中移除用户 Deprecated 无论是网页版,还是程序上都不起作用
func (*Group) SearchMemberByUsername ¶
SearchMemberByUsername 根据用户名查找群成员
func (*Group) SendFile ¶
func (g *Group) SendFile(file *os.File) (*SentMessage, error)
SendFile 发送文件给当前的群组
func (*Group) SendImage ¶
func (g *Group) SendImage(file *os.File) (*SentMessage, error)
SendImage 发行图片消息给当前的群组
func (*Group) SendText ¶
func (g *Group) SendText(content string) (*SentMessage, error)
SendText 发行文本消息给当前的群组
type Groups ¶
type Groups []*Group
func (Groups) GetByNickName ¶
GetByNickName 根据nickname查询一个Group
func (Groups) GetByRemarkName ¶
GetByRemarkName 根据remarkName查询一个Group
func (Groups) GetByUsername ¶
GetByUsername 根据username查询一个Group
func (Groups) SearchByNickName ¶
SearchByNickName 根据昵称查找群组
func (Groups) SearchByRemarkName ¶
SearchByRemarkName 根据备注查找群组
func (Groups) SearchByUserName ¶
SearchByUserName 根据用户名查找群组
type HotReloadStorageItem ¶
type HotReloadStorageItem struct { Cookies map[string][]*http.Cookie BaseRequest *BaseRequest LoginInfo *LoginInfo WechatDomain WechatDomain UUID string }
type HttpHook ¶
type HttpHook interface { BeforeRequest(req *http.Request) AfterRequest(response *http.Response, err error) }
HttpHook 请求上下文钩子
type LoginInfo ¶
type LoginInfo struct { Ret int `xml:"ret"` WxUin int64 `xml:"wxuin"` IsGrayScale int `xml:"isgrayscale"` Message string `xml:"message"` SKey string `xml:"skey"` WxSid string `xml:"wxsid"` PassTicket string `xml:"pass_ticket"` }
LoginInfo 登录信息
type MPSubscribeMsg ¶
type MPSubscribeMsg struct { MPArticleCount int Time int64 UserName string NickName string MPArticleList []struct { Title string Cover string Digest string Url string } }
MPSubscribeMsg 公众号的订阅信息
type MatchFunc ¶
MatchFunc 消息匹配函数,返回为true则表示匹配
func MatchFuncList ¶
MatchFuncList 将多个MatchFunc封装成一个MatchFunc
func SenderMatchFunc ¶
func SenderMatchFunc(matchFuncs ...MessageSenderMatchFunc) MatchFunc
SenderMatchFunc 抽象的匹配发送者特征的处理函数
dispatcher := NewMessageMatchDispatcher() matchFuncList := MatchFuncList(SenderFriendRequired(), SenderNickNameContainsMatchFunc("多吃点苹果")) dispatcher.RegisterHandler(matchFuncList, func(ctx *MessageContext) { do your own business })
func SenderNickNameContainsMatchFunc ¶
SenderNickNameContainsMatchFunc 根据用户昵称是否包含指定字符串的匹配函数
func SenderNickNameEqualMatchFunc ¶
SenderNickNameEqualMatchFunc 根据用户昵称是否等于指定字符串的匹配函数
func SenderRemakeNameContainsFunc ¶
SenderRemakeNameContainsFunc 根据用户备注名是否包含指定字符串的匹配函数
func SenderRemarkNameEqualMatchFunc ¶
SenderRemarkNameEqualMatchFunc 根据用户备注是否等于指定字符串的匹配函数
type Members ¶
type Members []*User
Members 抽象的用户组
func (Members) GetByNickName ¶
GetByNickName 根据nickname查找用户
func (Members) GetByRemarkName ¶
GetByRemarkName 根据remarkName查找用户
func (Members) GetByUserName ¶
GetByUserName 根据username查找用户
func (Members) SearchByNickName ¶
SearchByNickName 根据昵称查找
func (Members) SearchByRemarkName ¶
SearchByRemarkName 根据备注查找
type Message ¶
type Message struct { AppInfo struct { Type int AppID string } AppMsgType AppMessageType HasProductId int ImgHeight int ImgStatus int ImgWidth int ForwardFlag int MsgType MessageType 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 `json:"-"` Context context.Context `json:"-"` Raw []byte `json:"-"` RawContent string `json:"-"` // 消息原始内容 // contains filtered or unexported fields }
func (*Message) FriendAddMessageContent ¶
func (m *Message) FriendAddMessageContent() (*FriendAddMessage, error)
FriendAddMessageContent 获取FriendAddMessageContent内容
func (*Message) GetPicture ¶
GetPicture 获取图片消息的响应
func (*Message) IsComeFromGroup ¶
IsComeFromGroup 判断消息是否来自群组 可能是自己或者别的群员发送
func (*Message) IsFriendAdd ¶
func (*Message) IsLocation ¶
func (*Message) IsPaiYiPai ¶
IsPaiYiPai 判断消息是否为拍一拍 不要问我为什么取名为PaiYiPai,因为我也不知道取啥名字好
func (*Message) IsRealtimeLocation ¶
func (*Message) IsRealtimeLocationStart ¶
func (*Message) IsRealtimeLocationStop ¶
func (*Message) IsReceiveRedPacket ¶
IsReceiveRedPacket 判断当前是否收到红包
func (*Message) IsSendRedPacket ¶
IsSendRedPacket 否发出红包判断当前是
func (*Message) IsSysNotice ¶
func (*Message) IsTransferAccounts ¶
IsTransferAccounts 判断当前的消息是不是微信转账
func (*Message) MediaData ¶
func (m *Message) MediaData() (*AppMessageData, error)
MediaData 获取当前App Message的具体内容
func (*Message) ReplyFile ¶
func (m *Message) ReplyFile(file *os.File) (*SentMessage, error)
ReplyFile 回复文件消息
func (*Message) ReplyImage ¶
func (m *Message) ReplyImage(file *os.File) (*SentMessage, error)
ReplyImage 回复图片消息
func (*Message) ReplyText ¶
func (m *Message) ReplyText(content string) (*SentMessage, error)
ReplyText 回复文本消息
func (*Message) ReplyVideo ¶
func (m *Message) ReplyVideo(file *os.File) (*SentMessage, error)
ReplyVideo 回复视频消息
func (*Message) SaveFileToLocal ¶
SaveFileToLocal 保存文件到本地
func (*Message) SenderInGroup ¶
SenderInGroup 获取消息在群里面的发送者
type MessageContext ¶
type MessageContext struct { *Message // contains filtered or unexported fields }
MessageContext 消息处理上下文对象
func (*MessageContext) Abort ¶
func (c *MessageContext) Abort()
Abort 中断当前消息处理, 不会调用下一个消息处理函数, 但是不会中断当前的处理函数
func (*MessageContext) AbortHandler ¶
func (c *MessageContext) AbortHandler() MessageContextHandler
AbortHandler 获取当前中断的消息处理函数
type MessageContextHandler ¶
type MessageContextHandler func(ctx *MessageContext)
MessageContextHandler 消息处理函数
type MessageContextHandlerGroup ¶
type MessageContextHandlerGroup []MessageContextHandler
type MessageDispatcher ¶
type MessageDispatcher interface {
Dispatch(msg *Message)
}
MessageDispatcher 消息分发处理接口 跟 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
NewMessageMatchDispatcher Constructor
func (*MessageMatchDispatcher) AsMessageHandler ¶
func (m *MessageMatchDispatcher) AsMessageHandler() MessageHandler
AsMessageHandler 将MessageMatchDispatcher转换为MessageHandler
func (*MessageMatchDispatcher) Dispatch ¶
func (m *MessageMatchDispatcher) Dispatch(msg *Message)
Dispatch impl MessageDispatcher 遍历 MessageMatchDispatcher 所有的消息处理函数 获取所有匹配上的函数 执行处理的消息处理方法
func (*MessageMatchDispatcher) OnCard ¶
func (m *MessageMatchDispatcher) OnCard(handlers ...MessageContextHandler)
OnCard 注册处理消息类型为Card的处理函数
func (*MessageMatchDispatcher) OnEmoticon ¶
func (m *MessageMatchDispatcher) OnEmoticon(handlers ...MessageContextHandler)
OnEmoticon 注册处理消息类型为Emoticon的处理函数(表情包)
func (*MessageMatchDispatcher) OnFriend ¶
func (m *MessageMatchDispatcher) OnFriend(handlers ...MessageContextHandler)
OnFriend 注册发送者为好友的处理函数
func (*MessageMatchDispatcher) OnFriendAdd ¶
func (m *MessageMatchDispatcher) OnFriendAdd(handlers ...MessageContextHandler)
OnFriendAdd 注册处理消息类型为FriendAdd的处理函数
func (*MessageMatchDispatcher) OnFriendByNickName ¶
func (m *MessageMatchDispatcher) OnFriendByNickName(nickName string, handlers ...MessageContextHandler)
OnFriendByNickName 注册根据好友昵称是否匹配的消息处理函数
func (*MessageMatchDispatcher) OnFriendByRemarkName ¶
func (m *MessageMatchDispatcher) OnFriendByRemarkName(remarkName string, handlers ...MessageContextHandler)
OnFriendByRemarkName 注册根据好友备注是否匹配的消息处理函数
func (*MessageMatchDispatcher) OnGroup ¶
func (m *MessageMatchDispatcher) OnGroup(handlers ...MessageContextHandler)
OnGroup 注册发送者为群组的处理函数
func (*MessageMatchDispatcher) OnGroupByGroupName ¶
func (m *MessageMatchDispatcher) OnGroupByGroupName(groupName string, handlers ...MessageContextHandler)
OnGroupByGroupName 注册根据群名是否匹配的消息处理函数
func (*MessageMatchDispatcher) OnImage ¶
func (m *MessageMatchDispatcher) OnImage(handlers ...MessageContextHandler)
OnImage 注册处理消息类型为Image的处理函数
func (*MessageMatchDispatcher) OnMedia ¶
func (m *MessageMatchDispatcher) OnMedia(handlers ...MessageContextHandler)
OnMedia 注册处理消息类型为Media(多媒体消息,包括但不限于APP分享、文件分享)的处理函数
func (*MessageMatchDispatcher) OnText ¶
func (m *MessageMatchDispatcher) OnText(handlers ...MessageContextHandler)
OnText 注册处理消息类型为Text的处理函数
func (*MessageMatchDispatcher) OnUser ¶
func (m *MessageMatchDispatcher) OnUser(f func(user *User) bool, handlers ...MessageContextHandler)
OnUser 注册根据消息发送者的行为是否匹配的消息处理函数
func (*MessageMatchDispatcher) OnVoice ¶
func (m *MessageMatchDispatcher) OnVoice(handlers ...MessageContextHandler)
OnVoice 注册处理消息类型为Voice的处理函数
func (*MessageMatchDispatcher) RegisterHandler ¶
func (m *MessageMatchDispatcher) RegisterHandler(matchFunc MatchFunc, handlers ...MessageContextHandler)
RegisterHandler 注册消息处理函数, 根据自己的需求自定义 matchFunc返回true则表示处理对应的handlers
func (*MessageMatchDispatcher) SetAsync ¶
func (m *MessageMatchDispatcher) SetAsync(async bool)
SetAsync 设置是否异步处理
type MessageResponse ¶
type MessageResponse struct { BaseResponse BaseResponse LocalID string MsgID string }
type MessageResponseParser ¶
MessageResponseParser 消息响应解析器
func (*MessageResponseParser) MsgID ¶
func (p *MessageResponseParser) MsgID() (string, error)
MsgID 解析消息ID
func (*MessageResponseParser) SentMessage ¶
func (p *MessageResponseParser) SentMessage(msg *SendMessage) (*SentMessage, error)
SentMessage 返回 SentMessage
type MessageSenderMatchFunc ¶
type MessageType ¶
type MessageType int
MessageType 以Go惯用形式定义了PC微信所有的官方消息类型。 详见 message_test.go
Example (Output) ¶
for _, wxt := range []MessageType{ MsgTypeText, MsgTypeImage, MsgTypeVoice, MsgTypeVerify, MsgTypePossibleFriend, MsgTypeShareCard, MsgTypeVideo, MsgTypeEmoticon, MsgTypeLocation, MsgTypeApp, MsgTypeVoip, MsgTypeVoipNotify, MsgTypeVoipInvite, MsgTypeMicroVideo, MsgTypeSys, MsgTypeRecalled} { fmt.Printf("收到一条%s(type %d)\n", wxt, wxt) } fmt.Println("=======") for _, wxt := range []MessageType{10000, 6, 51} { wxtstr := wxt.String() if regexp.MustCompile(`^M`).MatchString(wxtstr) { wxtstr = "未知消息" } fmt.Printf("收到一条%s(type %d): %s\n", wxtstr, wxt, wxt) }
Output: 收到一条文本消息(type 1) 收到一条图片消息(type 3) 收到一条语音消息(type 34) 收到一条认证消息(type 37) 收到一条好友推荐消息(type 40) 收到一条名片消息(type 42) 收到一条视频消息(type 43) 收到一条表情消息(type 47) 收到一条地理位置消息(type 48) 收到一条APP消息(type 49) 收到一条VOIP消息(type 50) 收到一条VOIP结束消息(type 52) 收到一条VOIP邀请(type 53) 收到一条小视频消息(type 62) 收到一条系统消息(type 10000) 收到一条消息撤回(type 10002) ======= 收到一条系统消息(type 10000): 系统消息 收到一条未知消息(type 6): MessageType(6) 收到一条未知消息(type 51): MessageType(51)
const ( MsgTypeText MessageType = 1 // 文本消息 MsgTypeImage MessageType = 3 // 图片消息 MsgTypeVoice MessageType = 34 // 语音消息 MsgTypeVerify MessageType = 37 // 认证消息 MsgTypePossibleFriend MessageType = 40 // 好友推荐消息 MsgTypeVideo MessageType = 43 // 视频消息 MsgTypeEmoticon MessageType = 47 // 表情消息 MsgTypeLocation MessageType = 48 // 地理位置消息 MsgTypeApp MessageType = 49 // APP消息 MsgTypeVoip MessageType = 50 // VOIP消息 MsgTypeVoipNotify MessageType = 52 // VOIP结束消息 MsgTypeVoipInvite MessageType = 53 // VOIP邀请 MsgTypeMicroVideo MessageType = 62 // 小视频消息 MsgTypeSys MessageType = 10000 // 系统消息 MsgTypeRecalled MessageType = 10002 // 消息撤回 )
func (MessageType) String ¶
func (i MessageType) String() string
type Mode ¶
type Mp ¶
type Mp struct{ *User }
Mp 公众号对象
func (*Mp) SendFile ¶
func (m *Mp) SendFile(file *os.File) (*SentMessage, error)
SendFile 发送文件消息给公众号
func (*Mp) SendImage ¶
func (m *Mp) SendImage(file *os.File) (*SentMessage, error)
SendImage 发送图片消息给公众号
type Mps ¶
type Mps []*Mp
Mps 公众号组对象
func (Mps) GetByNickName ¶
GetByNickName 根据nickname查询一个Mp
func (Mps) GetByUserName ¶
GetByUserName 根据username查询一个Mp
func (Mps) SearchByNickName ¶
SearchByNickName 根据昵称查找
type PushLoginResponse ¶
type PushLoginResponse struct { Ret string `json:"ret"` Msg string `json:"msg"` UUID string `json:"uuid"` }
func (PushLoginResponse) Ok ¶
func (p PushLoginResponse) Ok() bool
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 }
RecommendInfo 一些特殊类型的消息会携带该结构体信息
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"` }
RevokeMsg 撤回消息Content
type Self ¶
Self 自己,当前登录用户对象
func (*Self) AddFriendIntoManyGroups ¶
AddFriendIntoManyGroups 拉好友进多个群聊 AddFriendIntoGroups, 名字和上面的有点像
func (*Self) AddFriendsIntoGroup ¶
AddFriendsIntoGroup 拉多名好友进群 最好自己是群主,成功率高一点,因为有的群允许非群组拉人,而有的群不允许
func (*Self) CreateGroup ¶
CreateGroup 创建群聊 topic 群昵称,可以传递字符串 friends 群员,最少为2个,加上自己3个,三人才能成群
func (*Self) FileHelper ¶
FileHelper 获取文件传输助手对象,封装成Friend返回
fh := self.FileHelper() // or fh := openwechat.NewFriendHelper(self)
func (*Self) ForwardMessageToFriends ¶
func (s *Self) ForwardMessageToFriends(msg *SentMessage, delay time.Duration, friends ...*Friend) error
ForwardMessageToFriends 转发给好友
func (*Self) ForwardMessageToGroups ¶
func (s *Self) ForwardMessageToGroups(msg *SentMessage, delay time.Duration, groups ...*Group) error
ForwardMessageToGroups 转发给群组
func (*Self) RemoveMemberFromGroup ¶
RemoveMemberFromGroup 从群聊中移除用户 Deprecated 无论是网页版,还是程序上都不起作用
func (*Self) RenameGroup ¶
RenameGroup 群组重命名
func (*Self) RevokeMessage ¶
func (s *Self) RevokeMessage(msg *SentMessage) error
RevokeMessage 撤回消息
sentMessage, err := friend.SendText("message") if err == nil { self.RevokeMessage(sentMessage) // or sentMessage.Revoke() }
func (*Self) SendFileToFriend ¶
SendFileToFriend 发送文件给好友
func (*Self) SendFileToFriends ¶
SendFileToFriends 发送文件给好友
func (*Self) SendFileToGroup ¶
SendFileToGroup 发送文件给群组
func (*Self) SendFileToGroups ¶
SendFileToGroups 发送文件给群组
func (*Self) SendFileToMp ¶
SendFileToMp 发送文件给公众号
func (*Self) SendImageToFriend ¶
SendImageToFriend 发送图片消息给好友
func (*Self) SendImageToFriends ¶
SendImageToFriends 发送图片消息给好友
func (*Self) SendImageToGroup ¶
SendImageToGroup 发送图片消息给群组
func (*Self) SendImageToGroups ¶
SendImageToGroups 发送图片消息给群组
func (*Self) SendImageToMp ¶
SendImageToMp 发送图片消息给公众号
func (*Self) SendTextToFriend ¶
func (s *Self) SendTextToFriend(friend *Friend, text string) (*SentMessage, error)
SendTextToFriend 发送文本消息给好友
func (*Self) SendTextToFriends ¶
SendTextToFriends 发送文本消息给好友
func (*Self) SendTextToGroup ¶
func (s *Self) SendTextToGroup(group *Group, text string) (*SentMessage, error)
SendTextToGroup 发送文本消息给群组
func (*Self) SendTextToGroups ¶
SendTextToGroups 发送文本消息给群组
func (*Self) SendTextToMp ¶
func (s *Self) SendTextToMp(mp *Mp, text string) (*SentMessage, error)
SendTextToMp 发送文本消息给公众号
func (*Self) SendVideoToFriend ¶
SendVideoToFriend 发送视频给好友
func (*Self) SendVideoToFriends ¶
SendVideoToFriends 发送视频给好友
func (*Self) SendVideoToGroup ¶
SendVideoToGroup 发送视频给群组
func (*Self) SendVideoToGroups ¶
SendVideoToGroups 发送视频给群组
func (*Self) SendVideoToMp ¶
SendVideoToMp 发送视频消息给公众号
func (*Self) SetRemarkNameToFriend ¶
SetRemarkNameToFriend 设置好友备注
self.SetRemarkNameToFriend(friend, "remark") // or friend.SetRemarkName("remark")
func (*Self) UpdateMembersDetail ¶
UpdateMembersDetail 更新所有的联系人信息
type SendMessage ¶
type SendMessage struct { Type MessageType Content string FromUserName string ToUserName string LocalID string ClientMsgId string MediaId string `json:"MediaId,omitempty"` }
SendMessage 发送消息的结构体
func NewMediaSendMessage ¶
func NewMediaSendMessage(msgType MessageType, fromUserName, toUserName, mediaId string) *SendMessage
NewMediaSendMessage 媒体消息的构造方法
func NewSendMessage ¶
func NewSendMessage(msgType MessageType, content, fromUserName, toUserName, mediaId string) *SendMessage
NewSendMessage SendMessage的构造方法
func NewTextSendMessage ¶
func NewTextSendMessage(content, fromUserName, toUserName string) *SendMessage
NewTextSendMessage 文本消息的构造方法
type SentMessage ¶
type SentMessage struct { *SendMessage Self *Self MsgId string }
SentMessage 已发送的信息
func (*SentMessage) ForwardToFriends ¶
func (s *SentMessage) ForwardToFriends(friends ...*Friend) error
ForwardToFriends 转发该消息给好友 该方法会阻塞直到所有好友都接收到消息 这里为了兼容以前的版本,默认休眠0.5秒,如果需要更快的速度,可以使用 SentMessage.ForwardToFriendsWithDelay
func (*SentMessage) ForwardToFriendsWithDelay ¶
func (s *SentMessage) ForwardToFriendsWithDelay(delay time.Duration, friends ...*Friend) error
ForwardToFriendsWithDelay 转发该消息给好友,延迟指定时间
func (*SentMessage) ForwardToGroups ¶
func (s *SentMessage) ForwardToGroups(groups ...*Group) error
ForwardToGroups 转发该消息给群组 该方法会阻塞直到所有群组都接收到消息 这里为了兼容以前的版本,默认休眠0.5秒,如果需要更快的速度,可以使用 SentMessage.ForwardToGroupsDelay
func (*SentMessage) ForwardToGroupsWithDelay ¶
func (s *SentMessage) ForwardToGroupsWithDelay(delay time.Duration, groups ...*Group) error
ForwardToGroupsWithDelay 转发该消息给群组, 延迟指定时间
type Storage ¶
type Storage struct { LoginInfo *LoginInfo Request *BaseRequest Response *WebInitResponse }
Storage 身份信息, 维持整个登陆的Session会话
type SyncCheckResponse ¶
func (SyncCheckResponse) Err ¶
func (s SyncCheckResponse) Err() error
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 { 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 int64 Uin int64 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 `json:"-"` }
User 抽象的用户结构: 好友 群组 公众号
func (*User) GetAvatarResponse ¶
GetAvatarResponse 获取用户头像
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 }
WebInitResponse 初始化的相应信息
type WebWxBatchContactResponse ¶
type WebWxBatchContactResponse struct { Count int BaseResponse BaseResponse ContactList []*User }
type WebWxContactResponse ¶
type WebWxContactResponse struct { MemberCount int Seq int64 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