Documentation
¶
Index ¶
- Constants
- Variables
- func CountBots() int
- func EachBot(f func(*Bot) bool)
- func EnableDump(enabled bool)
- type Bot
- func (bot *Bot) Accept(toUserName, ticket string) (*Contact, error)
- func (bot *Bot) Contacts() *Contacts
- func (bot *Bot) DownloadAvatar(dst string) (string, error)
- func (bot *Bot) DownloadQRCode(dst string) (string, error)
- func (bot *Bot) ForwardImage(toUserName, mediaId string) error
- func (bot *Bot) ForwardVideo(toUserName, mediaId string) error
- func (bot *Bot) GetAttr(attr interface{}, defaultValue interface{}) interface{}
- func (bot *Bot) GetAttrBool(attr string, defaultValue bool) bool
- func (bot *Bot) GetAttrInt(attr string, defaultValue int) int
- func (bot *Bot) GetAttrInt64(attr string, defaultValue int64) int64
- func (bot *Bot) GetAttrString(attr string, defaultValue string) string
- func (bot *Bot) GetAttrUint(attr string, defaultValue uint) uint
- func (bot *Bot) GetAttrUint64(attr string, defaultValue uint64) uint64
- func (bot *Bot) GetContactFromServer(toUserName string) (*Contact, error)
- func (bot *Bot) GetContactsFromServer(toUserNames ...string) ([]*Contact, error)
- func (bot *Bot) Release()
- func (bot *Bot) Remark(toUserName, remark string) error
- func (bot *Bot) Self() *Contact
- func (bot *Bot) SendImage(toUserName string, data []byte, filename string) (string, error)
- func (bot *Bot) SendText(toUserName string, text string) error
- func (bot *Bot) SendVideo(toUserName string, data []byte, filename string) (string, error)
- func (bot *Bot) SetAttr(attr interface{}, value interface{})
- func (bot *Bot) Start(handler Handler)
- func (bot *Bot) Stop()
- func (bot *Bot) Verify(toUserName, ticket string) error
- type Contact
- func (c *Contact) Bot() *Bot
- func (c *Contact) GetAttr(attr interface{}, defaultValue interface{}) interface{}
- func (c *Contact) GetAttrBool(attr string, defaultValue bool) bool
- func (c *Contact) GetAttrInt(attr string, defaultValue int) int
- func (c *Contact) GetAttrInt64(attr string, defaultValue int64) int64
- func (c *Contact) GetAttrString(attr string, defaultValue string) string
- func (c *Contact) GetAttrUint(attr string, defaultValue uint) uint
- func (c *Contact) GetAttrUint64(attr string, defaultValue uint64) uint64
- func (c *Contact) Raw() []byte
- func (c *Contact) SendImage(data []byte, filename string) (string, error)
- func (c *Contact) SendText(text string) error
- func (c *Contact) SendVideo(data []byte, filename string) (string, error)
- func (c *Contact) SetAttr(attr interface{}, value interface{})
- func (c *Contact) Update() *Contact
- type Contacts
- func (cs *Contacts) Add(c *Contact)
- func (cs *Contacts) Count() int
- func (cs *Contacts) Each(f func(*Contact) bool)
- func (cs *Contacts) EachLocked(f func(*Contact) bool)
- func (cs *Contacts) Find(keyword string) *Contact
- func (cs *Contacts) Get(userName string) *Contact
- func (cs *Contacts) Remove(userName string)
- type Handler
- type Message
- func (msg *Message) Bot() *Bot
- func (msg *Message) GetAttr(attr interface{}, defaultValue interface{}) interface{}
- func (msg *Message) GetAttrBool(attr string, defaultValue bool) bool
- func (msg *Message) GetAttrInt(attr string, defaultValue int) int
- func (msg *Message) GetAttrInt64(attr string, defaultValue int64) int64
- func (msg *Message) GetAttrString(attr string, defaultValue string) string
- func (msg *Message) GetAttrUint(attr string, defaultValue uint) uint
- func (msg *Message) GetAttrUint64(attr string, defaultValue uint64) uint64
- func (msg *Message) GetFromContact() *Contact
- func (msg *Message) GetToContact() *Contact
- func (msg *Message) Raw() []byte
- func (msg *Message) ReplyImage(data []byte, filename string) (string, error)
- func (msg *Message) ReplyText(text string) error
- func (msg *Message) ReplyVideo(data []byte, filename string) (string, error)
- func (msg *Message) SetAttr(attr interface{}, value interface{})
Constants ¶
View Source
const ( // 已扫码未确认 StateScan // 等待确认超时 StateScanTimeout // 已确认(正在登录) StateConfirm // 登录成功(此时可以正常收发消息) StateRunning // 已下线(主动、被动或异常) StateStop )
View Source
const ( // 好友 ContactFriend // 群 ContactGroup // 公众号 ContactMPS // 系统 ContactSystem )
View Source
const ( // 自带表情是文本消息,Content字段内容为:[奸笑], // emoji表情也是文本消息,Content字段内容为:<span class="emoji emoji1f633"></span>, // 如果连同文字和表情一起发送,Content字段内容是文字和表情直接是混在一起, // 位置坐标也是文本消息,Content字段内容为:雨花台区雨花西路(德安花园东):/cgi-bin/mmwebwx-bin/webwxgetpubliclinkimg?url=xxx&msgid=741398718084560243&pictype=location MsgText = 1 // 图片/照片消息 MsgImage = 3 // 语音消息 MsgVoice = 34 // 被添加好友待验证 MsgVerify = 37 MsgFriendRecommend = 40 // 名片消息 MsgCard = 42 // 拍摄(视频消息) MsgVideo = 43 // 动画表情, // 包括官方表情包中的表情(Content字段无内容)和自定义的图片表情(Content字段内容为XML) MsgAnimEmotion = 47 MsgLocation = 48 // 公众号推送的链接,分享的链接(AppMsgType=1/3/5),红包(AppMsgType=2001), // 发送的文件,收藏,实时位置共享 MsgLink = 49 MsgVoip = 50 // 登录之后系统发送的初始化消息 MsgInit = 51 MsgVoipNotify = 52 MsgVoipInvite = 53 MsgVideoCall = 62 MsgNotice = 9999 // 系统消息, // 例如通过好友验证,系统会发送"你已添加了...","如果陌生人...","实时位置共享已结束"的消息, MsgSystem = 10000 // 撤回消息 MsgRevoke = 10002 )
Variables ¶
Functions ¶
func EnableDump ¶
func EnableDump(enabled bool)
Types ¶
type Bot ¶
type Bot struct {
StartTime time.Time
StopTime time.Time
// contains filtered or unexported fields
}
func GetBotByUUID ¶
func GetBotByUin ¶
func RunningBots ¶
func RunningBots() []*Bot
func (*Bot) ForwardImage ¶
func (*Bot) ForwardVideo ¶
func (*Bot) GetAttr ¶
func (bot *Bot) GetAttr(attr interface{}, defaultValue interface{}) interface{}
func (*Bot) GetContactFromServer ¶
func (*Bot) GetContactsFromServer ¶
type Contact ¶
type Contact struct {
// 联系人类型,
// 个人和群为0,
// 订阅号为8,
// 企业号为24(包括扩微信支付),
// 系统号为56(微信团队官方帐号),
// 29(未知,招行信用卡为29)
VerifyFlag int
// Type是VerifyFlag解析后的值
Type int
// UserName每次登录都不一样,
// 群以@@开头,其他以@开头,系统帐号则直接是名字,如:
// weixin(微信团队)/filehelper(文件传输助手)/fmessage(朋友消息推荐)
UserName string
// 昵称,如果是群,表示群名称
NickName string
// 备注(仅好友有该字段)
RemarkName string
// 成员列表(仅群有该字段),
// 只在调用Update后才有值,UserName->NickName
Members map[string]string
// contains filtered or unexported fields
}
func GetContact ¶
func (*Contact) GetAttr ¶
func (c *Contact) GetAttr(attr interface{}, defaultValue interface{}) interface{}
func (*Contact) GetAttrInt64 ¶
func (*Contact) GetAttrString ¶
func (*Contact) GetAttrUint64 ¶
type Contacts ¶
type Contacts struct {
// contains filtered or unexported fields
}
func (*Contacts) EachLocked ¶
type Handler ¶
type Handler interface {
// 登录成功(error == nil),
// 登录失败(error != nil)
OnSignIn(error)
// 退出/下线
OnSignOut()
// 收到二维码(需扫码登录),
// 参数为二维码链接
OnQRCode(string)
// 联系人更新,如:
// 好友资料更新、删除好友或被好友删除等,
// 建群、加入群、被拉入群、群改名、群成员变更、退群或被群主移出群等,
// 第二个参数暂时没用
OnContact(*Contact, int)
// 收到消息,
// 第二个参数暂时没用
OnMessage(*Message, int)
}
type Message ¶
type Message struct {
Id string
FromUserName string
ToUserName string
Content string
Url string
CreateTime int64
Type int
// 当前说话人(仅群消息有该字段)
SpeakerUserName string
// contains filtered or unexported fields
}
func (*Message) GetAttr ¶
func (msg *Message) GetAttr(attr interface{}, defaultValue interface{}) interface{}
func (*Message) GetAttrInt64 ¶
func (*Message) GetAttrString ¶
func (*Message) GetAttrUint64 ¶
func (*Message) GetFromContact ¶
func (*Message) GetToContact ¶
func (*Message) ReplyImage ¶
func (*Message) ReplyVideo ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.