1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-06 20:13:50 +08:00

feature: offline file event.

This commit is contained in:
Mrs4s 2020-10-13 21:05:09 +08:00
parent 95376a8a63
commit 06e40a940e
2 changed files with 21 additions and 0 deletions

View File

@ -61,6 +61,7 @@ func NewQQBot(cli *client.QQClient, conf *global.JsonConfig) *CQBot {
bot.Client.OnGroupMessageRecalled(bot.groupRecallEvent)
bot.Client.OnGroupNotify(bot.groupNotifyEvent)
bot.Client.OnFriendMessageRecalled(bot.friendRecallEvent)
bot.Client.OnReceivedOfflineFile(bot.offlineFileEvent)
bot.Client.OnJoinGroup(bot.joinGroupEvent)
bot.Client.OnLeaveGroup(bot.leaveGroupEvent)
bot.Client.OnGroupMemberJoined(bot.memberJoinEvent)

View File

@ -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) {
log.Infof("Bot进入了群 %v.", formatGroupName(group))
bot.dispatchEventMessage(bot.groupIncrease(group.Code, 0, c.Uin))