Commit 06e40a94 authored by Mrs4s's avatar Mrs4s

feature: offline file event.

parent 95376a8a
...@@ -61,6 +61,7 @@ func NewQQBot(cli *client.QQClient, conf *global.JsonConfig) *CQBot { ...@@ -61,6 +61,7 @@ func NewQQBot(cli *client.QQClient, conf *global.JsonConfig) *CQBot {
bot.Client.OnGroupMessageRecalled(bot.groupRecallEvent) bot.Client.OnGroupMessageRecalled(bot.groupRecallEvent)
bot.Client.OnGroupNotify(bot.groupNotifyEvent) bot.Client.OnGroupNotify(bot.groupNotifyEvent)
bot.Client.OnFriendMessageRecalled(bot.friendRecallEvent) bot.Client.OnFriendMessageRecalled(bot.friendRecallEvent)
bot.Client.OnReceivedOfflineFile(bot.offlineFileEvent)
bot.Client.OnJoinGroup(bot.joinGroupEvent) bot.Client.OnJoinGroup(bot.joinGroupEvent)
bot.Client.OnLeaveGroup(bot.leaveGroupEvent) bot.Client.OnLeaveGroup(bot.leaveGroupEvent)
bot.Client.OnGroupMemberJoined(bot.memberJoinEvent) bot.Client.OnGroupMemberJoined(bot.memberJoinEvent)
......
...@@ -278,6 +278,26 @@ func (bot *CQBot) friendRecallEvent(c *client.QQClient, e *client.FriendMessageR ...@@ -278,6 +278,26 @@ func (bot *CQBot) friendRecallEvent(c *client.QQClient, e *client.FriendMessageR
}) })
} }
func (bot *CQBot) offlineFileEvent(c *client.QQClient, e *client.OfflineFileEvent) {
f := c.FindFriend(e.Sender)
if f == nil {
return
}
log.Infof("好友 %v(%v) 发送了离线文件 %v", f.Nickname, f.Uin, e.FileName)
bot.dispatchEventMessage(MSG{
"post_type": "notice",
"notice_type": "offline_file",
"user_id": e.Sender,
"file": MSG{
"name": e.FileName,
"size": e.FileSize,
"url": e.DownloadUrl,
},
"self_id": c.Uin,
"time": time.Now().Unix(),
})
}
func (bot *CQBot) joinGroupEvent(c *client.QQClient, group *client.GroupInfo) { func (bot *CQBot) joinGroupEvent(c *client.QQClient, group *client.GroupInfo) {
log.Infof("Bot进入了群 %v.", formatGroupName(group)) log.Infof("Bot进入了群 %v.", formatGroupName(group))
bot.dispatchEventMessage(bot.groupIncrease(group.Code, 0, c.Uin)) bot.dispatchEventMessage(bot.groupIncrease(group.Code, 0, c.Uin))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment