Documentation
¶
Index ¶
- Constants
- func AdminPermission(ctx *Ctx) bool
- func HasMemePicture(ctx *Ctx) bool
- func MustMemePicture(ctx *Ctx) bool
- func OnlyAtMe(ctx *Ctx) bool
- func OnlyGroup(ctx *Ctx) bool
- func OnlyPrivate(ctx *Ctx) bool
- func UserOrGroupAdmin(ctx *Ctx) bool
- type Config
- type Ctx
- func (ctx *Ctx) AgreeFriendVerify(v3, v4, scene string) error
- func (ctx *Ctx) CheckGroupSession() Rule
- func (ctx *Ctx) CheckUserSession() Rule
- func (ctx *Ctx) EventChannel(rule ...Rule) *EventChannel
- func (ctx *Ctx) GetFriendsList(isRefresh bool) ([]*FriendInfo, error)
- func (ctx *Ctx) GetGroupList(isRefresh bool) ([]*GroupInfo, error)
- func (ctx *Ctx) GetMatcher() *Matcher
- func (ctx *Ctx) GetSubscriptionList(isRefresh bool) ([]*SubscriptionInfo, error)
- func (ctx *Ctx) InviteIntoGroup(groupWxId, wxId string, typ int) error
- func (ctx *Ctx) IsApp() bool
- func (ctx *Ctx) IsAt() bool
- func (ctx *Ctx) IsAuthentication() bool
- func (ctx *Ctx) IsEventFriendVerify() bool
- func (ctx *Ctx) IsEventGroupChat() bool
- func (ctx *Ctx) IsEventPrivateChat() bool
- func (ctx *Ctx) IsEventSelfMessage() bool
- func (ctx *Ctx) IsEventSubscription() bool
- func (ctx *Ctx) IsImage() bool
- func (ctx *Ctx) IsLocation() bool
- func (ctx *Ctx) IsMemePictures() (string, bool)
- func (ctx *Ctx) IsMicroVideo() bool
- func (ctx *Ctx) IsPossibleFriend() bool
- func (ctx *Ctx) IsRecalled() bool
- func (ctx *Ctx) IsReference() bool
- func (ctx *Ctx) IsShareCard() bool
- func (ctx *Ctx) IsSystem() bool
- func (ctx *Ctx) IsText() bool
- func (ctx *Ctx) IsVideo() bool
- func (ctx *Ctx) IsVoice() bool
- func (ctx *Ctx) MessageString() string
- func (ctx *Ctx) ReplyBusinessCard(targetWxId string) error
- func (ctx *Ctx) ReplyEmoji(path string) error
- func (ctx *Ctx) ReplyFavorites(favoritesId string) error
- func (ctx *Ctx) ReplyFile(path string) error
- func (ctx *Ctx) ReplyImage(path string) error
- func (ctx *Ctx) ReplyMessageRecord(title string, dataList []map[string]interface{}) error
- func (ctx *Ctx) ReplyMessageRecordXML(xmlStr string) error
- func (ctx *Ctx) ReplyMiniProgram(ghId, title, content, imagePath, jumpPath string) error
- func (ctx *Ctx) ReplyMusic(name, author, app, jumpUrl, musicUrl, coverUrl string) error
- func (ctx *Ctx) ReplyShareLink(title, desc, imageUrl, jumpUrl string) error
- func (ctx *Ctx) ReplyText(text string) error
- func (ctx *Ctx) ReplyTextAndAt(text string) error
- func (ctx *Ctx) ReplyVideo(path string) error
- func (ctx *Ctx) ReplyXML(xmlStr string) error
- func (ctx *Ctx) SendBusinessCard(toWxId, targetWxId string) error
- func (ctx *Ctx) SendEmoji(wxId, path string) error
- func (ctx *Ctx) SendFavorites(toWxId, favoritesId string) error
- func (ctx *Ctx) SendFile(wxId, path string) error
- func (ctx *Ctx) SendImage(wxId, path string) error
- func (ctx *Ctx) SendMessageRecord(toWxId, title string, dataList []map[string]interface{}) error
- func (ctx *Ctx) SendMessageRecordXML(toWxId, xmlStr string) error
- func (ctx *Ctx) SendMiniProgram(toWxId, ghId, title, content, imagePath, jumpPath string) error
- func (ctx *Ctx) SendMusic(toWxId, name, author, app, jumpUrl, musicUrl, coverUrl string) error
- func (ctx *Ctx) SendShareLink(wxId, title, desc, imageUrl, jumpUrl string) error
- func (ctx *Ctx) SendText(wxId, text string) error
- func (ctx *Ctx) SendTextAndAt(groupWxId, wxId, text string) error
- func (ctx *Ctx) SendVideo(wxId, path string) error
- func (ctx *Ctx) SendXML(toWxId, xmlStr string) error
- type Engine
- func (e *Engine) On(rules ...Rule) *Matcher
- func (e *Engine) OnCommand(commands string, rules ...Rule) *Matcher
- func (e *Engine) OnCommandGroup(commands []string, rules ...Rule) *Matcher
- func (e *Engine) OnFullMatch(src string, rules ...Rule) *Matcher
- func (e *Engine) OnFullMatchGroup(src []string, rules ...Rule) *Matcher
- func (e *Engine) OnKeyword(keyword string, rules ...Rule) *Matcher
- func (e *Engine) OnKeywordGroup(keywords []string, rules ...Rule) *Matcher
- func (e *Engine) OnPrefix(prefix string, rules ...Rule) *Matcher
- func (e *Engine) OnPrefixGroup(prefix []string, rules ...Rule) *Matcher
- func (e *Engine) OnRegex(regexPattern string, rules ...Rule) *Matcher
- func (e *Engine) OnSuffix(suffix string, rules ...Rule) *Matcher
- func (e *Engine) OnSuffixGroup(suffix []string, rules ...Rule) *Matcher
- func (e *Engine) SetBlock(block bool) *Engine
- func (e *Engine) UseMidHandler(rules ...Rule)
- func (e *Engine) UsePostHandler(handler ...Handler)
- func (e *Engine) UsePreHandler(rules ...Rule)
- type Event
- type EventBuffer
- type EventBufferItem
- type EventChannel
- type FriendInfo
- type FriendVerify
- type GroupInfo
- type GroupMemberDecrease
- type GroupMemberIncrease
- type GroupMemberInfo
- type Handler
- type IFramework
- type Matcher
- func On(rules ...Rule) *Matcher
- func OnCommand(commands string, rules ...Rule) *Matcher
- func OnCommandGroup(commands []string, rules ...Rule) *Matcher
- func OnFullMatch(src string, rules ...Rule) *Matcher
- func OnFullMatchGroup(src []string, rules ...Rule) *Matcher
- func OnKeyword(keyword string, rules ...Rule) *Matcher
- func OnKeywordGroup(keywords []string, rules ...Rule) *Matcher
- func OnPrefix(prefix string, rules ...Rule) *Matcher
- func OnPrefixGroup(prefix []string, rules ...Rule) *Matcher
- func OnRegex(regexPattern string, rules ...Rule) *Matcher
- func OnSuffix(suffix string, rules ...Rule) *Matcher
- func OnSuffixGroup(suffix []string, rules ...Rule) *Matcher
- func StoreMatcher(m *Matcher) *Matcher
- func StoreTempMatcher(m *Matcher) *Matcher
- func (m *Matcher) Delete()
- func (m *Matcher) EventChannel(rule ...Rule) *EventChannel
- func (m *Matcher) FirstPriority() *Matcher
- func (m *Matcher) Handle(handler Handler) *Matcher
- func (m *Matcher) SetBlock(block bool) *Matcher
- func (m *Matcher) SetNoTimeout(noTimeout bool) *Matcher
- func (m *Matcher) SetPriority(priority uint64) *Matcher
- type Message
- type ObjectInfo
- type Robot
- type Rule
- type State
- type SubscriptionInfo
- type Transfer
- type Withdraw
Constants ¶
const ( EventGroupChat = "EventGroupChat" // 群聊消息事件 EventPrivateChat = "EventPrivateChat" // 私聊消息事件 EventSubscription = "EventSubscription" // 订阅号消息事件 EventSelfMessage = "EventSelfMessage" // 自己发的消息事件 EventFriendVerify = "EventFriendVerify" // 好友请求事件 EventTransfer = "EventTransfer" // 好友转账事件 EventMessageWithdraw = "EventMessageWithdraw" // 消息撤回事件 EventSystem = "EventSystem" // 系统消息事件 EventGroupMemberIncrease = "EventGroupMemberIncrease" // 群成员增加事件 EventGroupMemberDecrease = "EventGroupMemberDecrease" // 群成员减少事件 EventInvitedInGroup = "EventInvitedInGroup" // 被邀请入群事件 )
const ( MsgTypeText = 1 // 文本消息 MsgTypeImage = 3 // 图片消息 MsgTypeVoice = 34 // 语音消息 MsgTypeAuthentication = 37 // 认证消息 MsgTypePossibleFriend = 40 // 好友推荐消息 MsgTypeVideo = 43 // 视频消息 MsgTypeMemePicture = 47 // 表情消息 MsgTypeLocation = 48 // 地理位置消息 MsgTypeApp = 49 // APP消息 MsgTypeMicroVideo = 62 // 小视频消息 MsgTypeSystem = 10000 // 系统消息 MsgTypeRecalled = 10002 // 消息撤回 MsgTypeReference = 10003 // 消息引用 )
Variables ¶
This section is empty.
Functions ¶
func MustMemePicture ¶
MustMemePicture 消息不存在表情包图片阻塞至有图片,默认30s,超时返回false 阻塞时长可通过ctx.State["timeout"]设置
Types ¶
type Config ¶
type Config struct {
BotWxId string // 机器人微信ID
BotNickname string // 机器人名称
SuperUsers []string // 超级用户(管理员)
CommandPrefix string // 管理员触发命令
BufferLen uint // 事件缓冲区长度, 默认4096
Latency time.Duration // 事件处理延迟 (延迟 latency + (0~100ms) 再处理事件) (默认1s)
MaxProcessTime time.Duration // 事件最大处理时间 (默认3min)
Framework IFramework // 接入框架需实现该接口
}
type Ctx ¶
func (*Ctx) AgreeFriendVerify ¶
AgreeFriendVerify 同意好友验证
func (*Ctx) CheckGroupSession ¶
CheckGroupSession 判断会话连续性,必须同一个群,可以不同用户
func (*Ctx) CheckUserSession ¶
CheckUserSession 判断会话连续性,必须同一个群同一个用户
func (*Ctx) EventChannel ¶
func (ctx *Ctx) EventChannel(rule ...Rule) *EventChannel
EventChannel 用当前事件创建一个新的事件通道
func (*Ctx) GetFriendsList ¶ added in v1.1.0
func (ctx *Ctx) GetFriendsList(isRefresh bool) ([]*FriendInfo, error)
GetFriendsList 获取好友列表 isRefresh: 是否刷新 false-从缓存中获取,true-重新遍历二叉树并刷新缓存
func (*Ctx) GetGroupList ¶ added in v1.1.0
GetGroupList 获取群组列表 isRefresh: 是否刷新 false-从缓存中获取,true-重新遍历二叉树并刷新缓存
func (*Ctx) GetSubscriptionList ¶ added in v1.1.0
func (ctx *Ctx) GetSubscriptionList(isRefresh bool) ([]*SubscriptionInfo, error)
GetSubscriptionList 获取订阅号列表 isRefresh: 是否刷新 false-从缓存中获取,true-重新遍历二叉树并刷新缓存
func (*Ctx) InviteIntoGroup ¶
InviteIntoGroup 邀请好友加入群组; typ:1-直接拉,2-发送邀请链接
func (*Ctx) IsAuthentication ¶
IsAuthentication 判断消息类型是否是认证消息
func (*Ctx) IsEventFriendVerify ¶
IsEventFriendVerify 判断消息是否是好友请求消息
func (*Ctx) IsEventPrivateChat ¶
IsEventPrivateChat 判断消息是否是私聊消息
func (*Ctx) IsEventSelfMessage ¶ added in v1.0.10
IsEventSelfMessage 判断消息是否是机器人自己发出的消息
func (*Ctx) IsEventSubscription ¶ added in v1.1.2
IsEventSubscription 判断消息是否是订阅消息
func (*Ctx) IsMemePictures ¶
IsMemePictures 判断消息类型是否为表情包
func (*Ctx) IsPossibleFriend ¶
IsPossibleFriend 判断消息类型是否是好友推荐消息
func (*Ctx) ReplyBusinessCard ¶
ReplyBusinessCard 回复名片消息
func (*Ctx) ReplyFavorites ¶
ReplyFavorites 回复收藏消息
func (*Ctx) ReplyMessageRecord ¶
ReplyMessageRecord 回复消息记录
func (*Ctx) ReplyMessageRecordXML ¶
ReplyMessageRecordXML 回复消息记录(XML方式)
func (*Ctx) ReplyMiniProgram ¶
ReplyMiniProgram 回复小程序消息
func (*Ctx) ReplyMusic ¶
ReplyMusic 回复音乐消息
func (*Ctx) ReplyShareLink ¶
ReplyShareLink 回复分享链接消息
func (*Ctx) ReplyTextAndAt ¶
ReplyTextAndAt 回复文本消息并@某人,如果在私聊中则不会@某人
func (*Ctx) SendBusinessCard ¶
SendBusinessCard 发送名片消息到指定好友
func (*Ctx) SendFavorites ¶
SendFavorites 发送收藏消息到指定好友
func (*Ctx) SendMessageRecord ¶
SendMessageRecord 发送消息记录到指定好友
func (*Ctx) SendMessageRecordXML ¶
SendMessageRecordXML 发送消息记录(XML方式)到指定好友
func (*Ctx) SendMiniProgram ¶
SendMiniProgram 发送小程序消息到指定好友
func (*Ctx) SendShareLink ¶
SendShareLink 发送分享链接消息到指定好友
func (*Ctx) SendTextAndAt ¶
SendTextAndAt 发送文本消息并@某人到指定群指定用户,仅限群聊
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) OnCommandGroup ¶
OnCommandGroup 命令触发器组
func (*Engine) OnFullMatch ¶
OnFullMatch 完全匹配触发器
func (*Engine) OnFullMatchGroup ¶
OnFullMatchGroup 完全匹配触发器组
func (*Engine) OnKeywordGroup ¶
OnKeywordGroup 关键词触发器组
func (*Engine) OnPrefixGroup ¶
OnPrefixGroup 前缀触发器组
func (*Engine) OnSuffixGroup ¶
OnSuffixGroup 后缀触发器组
func (*Engine) UseMidHandler ¶
UseMidHandler 添加中间处理器,会在 Rule 判断后, Matcher 触发前触发,如果 midHandler 没有通过,则 Matcher 不会触发 可用于速率限制等
func (*Engine) UsePostHandler ¶
UsePostHandler 添加后置处理器,会在 Matcher 触发后触发,如果 postHandler 返回 false,则后续的 post handler 不会触发 可用于反并发等
func (*Engine) UsePreHandler ¶
UsePreHandler 添加前置处理器,会在 Rule 判断前触发,如果 preHandler 没有通过,则 Rule, Matcher 不会触发 可用于分群组管理插件等
type Event ¶
type Event struct {
Type string // 消息类型
RobotWxId string // 机器人微信id
IsAtMe bool // 机器人是否被@了,@所有人不算
FromUniqueID string // 消息来源唯一id, 私聊为发送者微信id, 群聊为群id
FromWxId string // 消息来源微信id
FromName string // 消息来源昵称
FromGroup string // 消息来源群id
FromGroupName string // 消息来源群名称
RawMessage string // 原始消息
Message *Message // 消息内容
SubscriptionMessage *Message // 订阅号消息
FriendVerify *FriendVerify // 好友验证消息
Transfer *Transfer // 转账消息
Withdraw *Withdraw // 撤回消息
GroupMemberIncrease *GroupMemberIncrease // 群成员增加消息
GroupMemberDecrease *GroupMemberDecrease // 群成员减少消息
}
Event 记录一次回调事件
type EventBuffer ¶
func NewEventBuffer ¶
func NewEventBuffer(bufferLen uint) *EventBuffer
func (*EventBuffer) Loop ¶
func (e *EventBuffer) Loop(latency, maxWait time.Duration, process func(*Event, IFramework, time.Duration))
Loop 以给定的延迟和最长等待时间处理环中的事件
func (*EventBuffer) ProcessEvent ¶
func (e *EventBuffer) ProcessEvent(event *Event, framework IFramework)
ProcessEvent 处理事件
type EventBufferItem ¶
type EventBufferItem struct {
// contains filtered or unexported fields
}
type EventChannel ¶
EventChannel 用于异步获取指定事件
func NewEventChannel ¶
func NewEventChannel(Priority uint64, Block bool, rule ...Rule) *EventChannel
NewEventChannel 创建一个新的 EventChannel用于异步获取指定事件
func (*EventChannel) Next ¶
func (n *EventChannel) Next() <-chan *Ctx
Next 返回一个 chan 用于接收下一个指定事件 该 chan 必须接收,如需手动取消监听,请使用 Repeat 方法
func (*EventChannel) Repeat ¶
func (n *EventChannel) Repeat() (recv <-chan *Ctx, cancel func())
Repeat 返回一个 chan 用于接收无穷个指定事件,和一个取消监听的函数 如果没有取消监听,将不断监听指定事件
type FriendInfo ¶ added in v1.1.0
type FriendInfo struct {
WxId string `json:"wxId"` // 微信ID
WxNum string `json:"wxNum"` // 微信号
Nick string `json:"nick"` // 昵称
Remark string `json:"remark"` // 备注
NickBrief string `json:"nickBrief"` // 昵称简拼
NickWhole string `json:"nickWhole"` // 昵称全拼
RemarkBrief string `json:"remarkBrief"` // 备注简拼
RemarkWhole string `json:"remarkWhole"` // 备注全拼
EnBrief string `json:"enBrief"` // 英文简拼
EnWhole string `json:"enWhole"` // 英文全拼
V3 string `json:"v3"` // v3数据,同意好友验证时需要
Sign string `json:"sign"` // 签名,需要在会话列表中
Country string `json:"country"` // 国家,需要在会话列表中
Province string `json:"province"` // 省份,需要在会话列表中
City string `json:"city"` // 城市,需要在会话列表中
MomentsBackgroundImgUrl string `json:"momentsBackgroundImgUrl"` // 朋友圈背景图,需要在朋友圈中
AvatarMinUrl string `json:"avatarMinUrl"` // 头像小图,需要在会话列表中
AvatarMaxUrl string `json:"avatarMaxUrl"` // 头像大图,需要在会话列表中
Sex string `json:"sex"` // 性别,1男,2女,0未知
MemberNum int `json:"memberNum"` // 群成员数量,仅当对象是群聊时有效
}
FriendInfo 好友信息
type FriendVerify ¶
type FriendVerify struct {
WxId string // 发送者微信id
Nick string // 发送者昵称
V1 string // 验证V1
V2 string // 验证V2
V3 string // 验证V3
V4 string // 验证V4
AvatarUrl string // 头像url
Content string // 验证内容
Scene string // 验证场景
}
FriendVerify 记录好友验证消息的具体内容
type GroupInfo ¶ added in v1.1.0
type GroupInfo struct {
WxId string `json:"wxId"` // 微信ID
WxNum string `json:"wxNum"` // 微信号
Nick string `json:"nick"` // 昵称
Remark string `json:"remark"` // 备注
NickBrief string `json:"nickBrief"` // 昵称简拼
NickWhole string `json:"nickWhole"` // 昵称全拼
RemarkBrief string `json:"remarkBrief"` // 备注简拼
RemarkWhole string `json:"remarkWhole"` // 备注全拼
EnBrief string `json:"enBrief"` // 英文简拼
EnWhole string `json:"enWhole"` // 英文全拼
MemberNum int `json:"memberNum"` // 群成员数量,仅当对象是群聊时有效
AvatarMinUrl string `json:"avatarMinUrl"` // 头像小图,需要在会话列表中
AvatarMaxUrl string `json:"avatarMaxUrl"` // 头像大图,需要在会话列表中
}
GroupInfo 群信息
type GroupMemberDecrease ¶ added in v1.0.10
type GroupMemberDecrease struct {
}
GroupMemberDecrease 记录群成员减少消息的具体内容
type GroupMemberIncrease ¶ added in v1.0.10
type GroupMemberIncrease struct {
}
GroupMemberIncrease 记录群成员增加消息的具体内容
type GroupMemberInfo ¶ added in v1.1.1
type GroupMemberInfo struct {
WxId string `json:"wxId"` // 微信ID
WxNum string `json:"wxNum"` // 微信号
Nick string `json:"nick"` // 昵称
Remark string `json:"remark"` // 备注
Country string `json:"country"` // 国家,需要在会话列表中
Province string `json:"province"` // 省份,需要在会话列表中
City string `json:"city"` // 城市,需要在会话列表中
AvatarMinUrl string `json:"avatarMinUrl"` // 头像小图,需要在会话列表中
AvatarMaxUrl string `json:"avatarMaxUrl"` // 头像大图,需要在会话列表中
Sex string `json:"sex"` // 性别,1男,2女,0未知
}
GroupMemberInfo 群成员信息
type IFramework ¶
type IFramework interface {
// Callback 这是消息回调方法,vx框架回调消息转发给该Server
Callback(func(*Event, IFramework))
// GetMemePictures 获取表情包图片地址(迷因图)
// return: 图片链接(网络URL或图片base64)
GetMemePictures(message *Message) string
// SendText 发送文本消息
// toWxId: 好友ID/群ID
// text: 文本内容
SendText(toWxId, text string) error
// SendTextAndAt 发送文本消息并@,只有群聊有效
// toGroupWxId: 群ID
// toWxId: 好友ID/群ID/all
// toWxName: 好友昵称/群昵称,留空为自动获取
// text: 文本内容
SendTextAndAt(toGroupWxId, toWxId, toWxName, text string) error
// SendImage 发送图片消息
// toWxId: 好友ID/群ID
// path: 图片路径
SendImage(toWxId, path string) error
// toWxId: 好友ID/群ID
// title: 标题
// desc: 描述
// imageUrl: 图片链接
// jumpUrl: 跳转链接
SendShareLink(toWxId, title, desc, imageUrl, jumpUrl string) error
// SendFile 发送文件消息
// toWxId: 好友ID/群ID/公众号ID
// path: 本地文件绝对路径
SendFile(toWxId, path string) error
// SendVideo 发送视频消息
// toWxId: 好友ID/群ID/公众号ID
// path: 本地视频文件绝对路径
SendVideo(toWxId, path string) error
// SendEmoji 发送表情消息
// toWxId: 好友ID/群ID/公众号ID
// path: 本地动态表情文件绝对路径
SendEmoji(toWxId, path string) error
// SendMusic 发送音乐消息
// toWxId: 好友ID/群ID/公众号ID
// name: 音乐名称
// author: 音乐作者
// app: 音乐来源(VLW需留空),酷狗/wx79f2c4418704b4f8,网易云/wx8dd6ecd81906fd84,QQ音乐/wx5aa333606550dfd5
// jumpUrl: 音乐跳转链接
// musicUrl: 网络歌曲直链
// coverUrl: 封面图片链接
SendMusic(toWxId, name, author, app, jumpUrl, musicUrl, coverUrl string) error
// SendMiniProgram 发送小程序消息
// toWxId: 好友ID/群ID/公众号ID
// ghId: 小程序ID
// title: 标题
// content: 内容
// imagePath: 图片路径, 本地图片路径或网络图片URL
// jumpPath: 小程序点击跳转地址,例如:pages/index/index.html
SendMiniProgram(toWxId, ghId, title, content, imagePath, jumpPath string) error
// SendMessageRecord 发送消息记录
// toWxId: 好友ID/群ID/公众号ID
// title: 仅供电脑上显示用,手机上的话微信会根据[显示昵称]来自动生成 谁和谁的聊天记录
// dataList:
// - wxid: 发送此条消息的人的wxid
// - nickName: 显示的昵称(可随意伪造)
// - timestamp: 10位时间戳
// - msg: 消息内容
SendMessageRecord(toWxId, title string, dataList []map[string]interface{}) error
// SendMessageRecordXML 发送消息记录(XML方式)
// toWxId: 好友ID/群ID/公众号ID
// xmlStr: 消息记录XML代码
SendMessageRecordXML(toWxId, xmlStr string) error
// SendFavorites 发送收藏消息
// toWxId: 好友ID/群ID/公众号ID
// favoritesId: 收藏夹ID
SendFavorites(toWxId, favoritesId string) error
// SendXML 发送XML消息
// toWxId: 好友ID/群ID/公众号ID
// xmlStr: XML代码
SendXML(toWxId, xmlStr string) error
// SendBusinessCard 发送名片消息
// toWxId: 好友ID/群ID/公众号ID
// targetWxId: 目标用户ID
SendBusinessCard(toWxId, targetWxId string) error
// AgreeFriendVerify 同意好友验证
// v3: 验证V3
// v4: 验证V4
// scene: 验证场景
AgreeFriendVerify(v3, v4, scene string) error
// InviteIntoGroup 邀请好友加入群组
// groupWxId: 群ID
// wxId: 好友ID
// typ: 邀请类型,1-直接拉,2-发送邀请链接
InviteIntoGroup(groupWxId, wxId string, typ int) error
// GetObjectInfo 获取对象信息
// wxId: 好友ID/群ID/公众号ID
// return: ObjectInfo, error
GetObjectInfo(wxId string) (*ObjectInfo, error)
// GetFriendsList 获取好友列表
// isRefresh: 是否刷新 false-从缓存中获取,true-重新遍历二叉树并刷新缓存
// return: []*FriendInfo, error
GetFriendsList(isRefresh bool) ([]*FriendInfo, error)
// GetGroupList 获取群组列表
// isRefresh: 是否刷新 false-从缓存中获取,true-重新遍历二叉树并刷新缓存
// return: []*GroupInfo, error
GetGroupList(isRefresh bool) ([]*GroupInfo, error)
// GetGroupMemberList 获取群成员列表
// groupWxId: 群ID
// isRefresh: 是否刷新 false-从缓存中获取,true-重新遍历二叉树并刷新缓存
// return: []*GroupMemberInfo, error
GetGroupMemberList(groupWxId string, isRefresh bool) ([]*GroupMemberInfo, error)
// GetSubscriptionList 获取订阅列表
// isRefresh: 是否刷新 false-从缓存中获取,true-重新遍历二叉树并刷新缓存
// return: []*SubscriptionInfo, error
GetSubscriptionList(isRefresh bool) ([]*SubscriptionInfo, error)
}
IFramework 这是接入框架所定义的接口
type Matcher ¶
type Matcher struct {
// Temp 是否为临时Matcher,临时 Matcher 匹配一次后就会删除当前 Matcher
Temp bool
// Block 是否阻断后续 Matcher,为true时当前Matcher匹配成功后,后续Matcher不参与匹配
Block bool
// Break 是否退出后续匹配流程, 只有 Rule 返回false且此值为真才会退出, 且不对 mid handler以下的 Rule 生效
Break bool
// NoTimeout 处理是否不设超时
NoTimeout bool
// Priority 优先级,越小优先级越高
Priority uint64
// Rules 匹配规则
Rules []Rule
// Handler 处理事件的函数
Handler Handler
// Engine 注册 Matcher 的 Engine,Engine可为一系列 Matcher 添加通用 Rule 和其他钩子
Engine *Engine
}
Matcher 是匹配和处理事件的最小单元
func OnCommandGroup ¶
OnCommandGroup 命令触发器组
func OnFullMatchGroup ¶
OnFullMatchGroup 完全匹配触发器组
func OnKeywordGroup ¶
OnKeywordGroup 关键词触发器组
func OnPrefixGroup ¶
OnPrefixGroup 前缀触发器组
func OnSuffixGroup ¶
OnSuffixGroup 后缀触发器组
func StoreTempMatcher ¶
StoreTempMatcher 向匹配器列表中添加一个临时匹配器,临时匹配器只会触发匹配一次
func (*Matcher) EventChannel ¶
func (m *Matcher) EventChannel(rule ...Rule) *EventChannel
EventChannel 用当前上下文创建一个EventChannel,会阻塞其他事件
func (*Matcher) FirstPriority ¶
FirstPriority 设置当前 Matcher 优先级 - 0
func (*Matcher) SetNoTimeout ¶
SetNoTimeout 设置处理时不设超时
func (*Matcher) SetPriority ¶
SetPriority 设置当前 Matcher 优先级
type ObjectInfo ¶
type ObjectInfo struct {
WxId string `json:"wxId"` // 微信ID
WxNum string `json:"wxNum"` // 微信号
Nick string `json:"nick"` // 昵称
Remark string `json:"remark"` // 备注
NickBrief string `json:"nickBrief"` // 昵称简拼
NickWhole string `json:"nickWhole"` // 昵称全拼
RemarkBrief string `json:"remarkBrief"` // 备注简拼
RemarkWhole string `json:"remarkWhole"` // 备注全拼
EnBrief string `json:"enBrief"` // 英文简拼
EnWhole string `json:"enWhole"` // 英文全拼
V3 string `json:"v3"` // v3数据,同意好友验证时需要
V4 string `json:"v4"` // v4数据,同意好友验证时需要
Sign string `json:"sign"` // 签名,需要在会话列表中
Country string `json:"country"` // 国家,需要在会话列表中
Province string `json:"province"` // 省份,需要在会话列表中
City string `json:"city"` // 城市,需要在会话列表中
MomentsBackgroundImgUrl string `json:"momentsBackgroundImgUrl"` // 朋友圈背景图,需要在朋友圈中
AvatarMinUrl string `json:"avatarMinUrl"` // 头像小图,需要在会话列表中
AvatarMaxUrl string `json:"avatarMaxUrl"` // 头像大图,需要在会话列表中
Sex string `json:"sex"` // 性别,1男,2女,0未知
MemberNum int `json:"memberNum"` // 群成员数量,仅当对象是群聊时有效
}
ObjectInfo 对象信息 对象可以是好友、群、公众号
type Robot ¶ added in v1.1.0
type Robot struct {
BotConfig *Config
Framework IFramework
FriendsList []*FriendInfo
GroupList []*GroupInfo
SubscriptionList []*SubscriptionInfo
}
var (
WxBot *Robot // 当前机器人
)
type SubscriptionInfo ¶ added in v1.1.0
type SubscriptionInfo struct {
WxId string `json:"wxId"` // 微信ID
WxNum string `json:"wxNum"` // 微信号
Nick string `json:"nick"` // 昵称
Remark string `json:"remark"` // 备注
NickBrief string `json:"nickBrief"` // 昵称简拼
NickWhole string `json:"nickWhole"` // 昵称全拼
RemarkBrief string `json:"remarkBrief"` // 备注简拼
RemarkWhole string `json:"remarkWhole"` // 备注全拼
EnBrief string `json:"enBrief"` // 英文简拼
EnWhole string `json:"enWhole"` // 英文全拼
V3 string `json:"v3"` // v3数据,同意好友验证时需要
Sign string `json:"sign"` // 签名,需要在会话列表中
Country string `json:"country"` // 国家,需要在会话列表中
Province string `json:"province"` // 省份,需要在会话列表中
City string `json:"city"` // 城市,需要在会话列表中
MomentsBackgroundImgUrl string `json:"momentsBackgroundImgUrl"` // 朋友圈背景图,需要在朋友圈中
AvatarMinUrl string `json:"avatarMinUrl"` // 头像小图,需要在会话列表中
AvatarMaxUrl string `json:"avatarMaxUrl"` // 头像大图,需要在会话列表中
}
SubscriptionInfo 订阅公众号信息
type Transfer ¶ added in v1.0.10
type Transfer struct {
FromWxId string // 发送者微信ID
MsgSource int64 // 消息来源 1:收到转账 2:对方接收转账 3:发出转账 4:自己接收转账 5:对方退还 6:自己退还
TransferType int64 // 转账类型 1:即时到账 2:延时到账
Money string // 转账金额,单位元
Memo string // 转账备注
TransferId string // 转账ID
TransferTime string // 转账时间,10位时间戳
}
Transfer 记录转账消息的具体内容