Documentation
¶
Overview ¶
Package botoy 极简的OPQ开发框架
这是一个十分简单的框架,模块的方法很少,只封装了常用的几个功能, 比如发文字,发图。。。但在多数情况下够用了
Index ¶
- Constants
- Variables
- type Botoy
- type ConnectedPack
- type DisConnectedPack
- type FriendMsgPack
- type FriendPicPayload
- type FriendRevokePack
- type FriendTextPayload
- type FriendVoicePayload
- type GroupExitPack
- type GroupExitSuccessPack
- type GroupJSONPayload
- type GroupJoinPack
- type GroupMsgPack
- type GroupPicPayload
- type GroupReplyPayload
- type GroupRevokePack
- type GroupShutPack
- type GroupTextPayload
- type GroupVoicePayload
- type GroupXMLPayload
- type PhoneTextPayload
- type PrivatePicPayload
- type PrivateTextPayload
Constants ¶
const ( AtMsgType = "AtMsg" PicMsgType = "PicMsg" TextMsgType = "TextMsg" ReplyMsgType = "ReplyMsg" ReplyMsgAType = "ReplayMsg" VoiceMsgType = "VoiceMsg" VideoMsgType = "VideoMsg" PhoneMsgType = "PhoneMsg" RedBagMsgType = "RedBagMsg" TempSessionMsgType = "TempSessionMsg" FriendFileMsgType = "FriendFileMsg" GroupFileMsgType = "GroupFileMsg" GroupRevokeEventType = "ON_EVENT_GROUP_REVOKE" GroupAdminsysnotifyEventType = "ON_EVENT_GROUP_ADMINSYSNOTIFY" FriendRevokeEventType = "ON_EVENT_FRIEND_REVOKE" GroupJoinEventType = "ON_EVENT_GROUP_JOIN" GroupExitEventType = "ON_EVENT_GROUP_EXIT" FriendDeleteEventType = "ON_EVENT_FRIEND_DELETE" GroupShutEventType = "ON_EVENT_GROUP_SHUT" GroupAdminEventType = "ON_EVENT_GROUP_ADMIN" NotifyPushaddfrdEventType = "ON_EVENT_NOTIFY_PUSHADDFRD" FriendAddedEventType = "ON_EVENT_FRIEND_ADDED" GroupExitSuccEventType = "ON_EVENT_GROUP_EXIT_SUCC" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Botoy ¶
type Botoy struct {
// 机器人QQ号
BotID int64
// 连接地址 如: http://127.0.0.1:8888
Address string
// contains filtered or unexported fields
}
func NewBotoy ¶
NewBotoy 新建Botoy
如果bot为0,会监听所有机器人的消息,如果为一个确定的qq号,则只会接收该QQ号机器人所收到的消息
如果bot为0,将无法使用 Do 方法
func (*Botoy) AddReceiver ¶
AddReceiver 添加对应消息的处理函数
参数必须是函数,参数必须为模块内名字以Pack结尾的类型
可以添加多个函数,收到消息后各个函数异步执行
每个消息都可以添加多个函数进行处理
使用示例:
bot.AddReceiver(
func(pack botoy.FriendMsgPack) {
fmt.Printf("收到一条好友消息, 发送人: %d, 内容: %s\n", pack.FromUin, pack.Content)
},
func(pack botoy.GroupMsgPack) {
fmt.Printf("收到一条群消息, 发送人: %d, 群id: %d, 内容: %s\n", pack.FromUserID, pack.FromGroupID, pack.Content)
},
func(pack botoy.ConnectedPack) {
fmt.Println("socketio已连接!")
},
)
bot.AddReceiver(
func(pack botoy.FriendRevokePack) {
fmt.Printf("好友【%d】撤回了一条消息!\n", pack.Eventdata.Userid)
},
)
bot.AddReceiver(
func(pack botoy.GroupMsgPack) {
fmt.Printf("收到一条群消息, 消息类型为: %s\n", pack.MsgType)
},
)
type FriendMsgPack ¶
type FriendMsgPack struct {
CurrentQQ int64 `json:"CurrentQQ,omitempty"`
Content string `json:"Content"`
FromUin int64 `json:"FromUin"`
MsgSeq int `json:"MsgSeq"`
MsgType string `json:"MsgType"`
ToUin int64 `json:"ToUin"`
TempUin int64 `json:"TempUin"`
RedBaginfo interface{} `json:"RedBaginfo"`
}
FriendMsgPack 好友消息
type FriendPicPayload ¶
type FriendPicPayload struct {
ToUser int64
Content string
PicURL string
PicBase64 string
FileMd5 string
Flash bool
}
FriendPicPayload 好友图片消息
type FriendRevokePack ¶
type FriendRevokePack struct {
CurrentQQ int64 `json:"CurrentQQ,omitempty"`
Eventdata struct {
Msgseq int `json:"MsgSeq"`
Userid int `json:"UserID"`
} `json:"EventData"`
Eventmsg struct {
Fromuin int `json:"FromUin"`
Touin int `json:"ToUin"`
Msgtype string `json:"MsgType"`
Msgseq int `json:"MsgSeq"`
Content string `json:"Content"`
Redbaginfo interface{} `json:"RedBaginfo"`
} `json:"EventMsg"`
Eventname string `json:"EventName"`
}
FriendRevokePack 好友撤回事件
type FriendTextPayload ¶
FriendTextPayload 好友文字消息
type FriendVoicePayload ¶
FriendVoicePayload 好友语音消息
type GroupExitPack ¶
type GroupExitPack struct {
CurrentQQ int64 `json:"CurrentQQ,omitempty"`
EventData struct {
UserID int64 `json:"UserID"`
} `json:"EventData"`
EventMsg struct {
FromUin int64 `json:"FromUin"`
ToUin int64 `json:"ToUin"`
MsgType string `json:"MsgType"`
MsgSeq int `json:"MsgSeq"`
Content string `json:"Content"`
RedBaginfo interface{} `json:"RedBaginfo"`
} `json:"EventMsg"`
}
GroupExitPack 退群事件
type GroupExitSuccessPack ¶
type GroupExitSuccessPack struct {
CurrentQQ int64 `json:"CurrentQQ,omitempty"`
EventData struct {
GroupID int64 `json:"GroupID"`
} `json:"EventData"`
EventMsg struct {
FromUin int64 `json:"FromUin"`
ToUin int64 `json:"ToUin"`
MsgType string `json:"MsgType"`
MsgSeq int `json:"MsgSeq"`
Content string `json:"Content"`
RedBaginfo interface{} `json:"RedBaginfo"`
} `json:"EventMsg"`
}
GroupExitSuccessPack 退群事件
type GroupJSONPayload ¶
GroupJSONPayload 群json消息
type GroupJoinPack ¶
type GroupJoinPack struct {
CurrentQQ int64 `json:"CurrentQQ,omitempty"`
EventData struct {
InviteUin int64 `json:"InviteUin"`
UserID int64 `json:"UserID"`
UserName string `json:"UserName"`
} `json:"EventData"`
EventMsg struct {
FromUin int64 `json:"FromUin"`
ToUin int64 `json:"ToUin"`
MsgType string `json:"MsgType"`
MsgSeq int `json:"MsgSeq"`
Content string `json:"Content"`
RedBaginfo interface{} `json:"RedBaginfo"`
} `json:"EventMsg"`
}
GroupJoinPack 加群事件
type GroupMsgPack ¶
type GroupMsgPack struct {
CurrentQQ int64 `json:"CurrentQQ,omitempty"`
Content string `json:"Content"`
FromGroupID int64 `json:"FromGroupId"`
FromGroupName string `json:"FromGroupName"`
FromNickName string `json:"FromNickName"`
FromUserID int64 `json:"FromUserId"`
MsgRandom int `json:"MsgRandom"`
MsgSeq int `json:"MsgSeq"`
MsgTime int `json:"MsgTime"`
MsgType string `json:"MsgType"`
RedBaginfo interface{} `json:"RedBaginfo"`
}
GroupMsgPack 群消息
type GroupPicPayload ¶
type GroupPicPayload struct {
GroupID int64
Content string
PicURL string
PicBase64 string
PicMD5s []string
PicMD5 string
Flash bool
}
GroupPicPayload 群图片消息
type GroupReplyPayload ¶
type GroupReplyPayload struct {
GroupID int64
Content string
RawMsgSeq int
RawMsgTime int
RawMsgUserID int64
RawMsgContent string
}
GroupReplyPayload 群回复消息
type GroupRevokePack ¶
type GroupRevokePack struct {
CurrentQQ int64 `json:"CurrentQQ,omitempty"`
EventData struct {
AdminUserID int `json:"AdminUserID"`
GroupID int64 `json:"GroupID"`
MsgRandom int64 `json:"MsgRandom"`
MsgSeq int `json:"MsgSeq"`
UserID int64 `json:"UserID"`
} `json:"EventData"`
EventMsg struct {
FromUin int64 `json:"FromUin"`
ToUin int64 `json:"ToUin"`
MsgType string `json:"MsgType"`
MsgSeq int `json:"MsgSeq"`
Content string `json:"Content"`
RedBaginfo interface{} `json:"RedBaginfo"`
} `json:"EventMsg"`
}
GroupRevokePack 群撤回消息
type GroupShutPack ¶
type GroupShutPack struct {
CurrentQQ int64 `json:"CurrentQQ,omitempty"`
EventData struct {
GroupID int64 `json:"GroupID"`
ShutTime int `json:"ShutTime"`
UserID int64 `json:"UserID"`
} `json:"EventData"`
EventMsg struct {
FromUin int64 `json:"FromUin"`
ToUin int64 `json:"ToUin"`
MsgType string `json:"MsgType"`
MsgSeq int `json:"MsgSeq"`
Content string `json:"Content"`
RedBaginfo interface{} `json:"RedBaginfo"`
} `json:"EventMsg"`
}
GroupShutPack 群禁言
type GroupTextPayload ¶
GroupTextPayload 群文字消息
type GroupVoicePayload ¶
GroupVoicePayload 群语音消息
type GroupXMLPayload ¶
GroupXMLPayload 群XML消息
type PrivatePicPayload ¶
type PrivatePicPayload struct {
ToUserID int64
GroupID int64
PicURL string
PicBase64 string
FileMd5 string
Content string
Flash bool
}
PrivatePicPayload 私聊图片消息
type PrivateTextPayload ¶
PrivateTextPayload 私聊文字消息