diff --git a/coolq/bot.go b/coolq/bot.go index 98e998b..8da773c 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -126,6 +126,7 @@ func NewQQBot(cli *client.QQClient, conf *config.Config) *CQBot { bot.Client.OnGroupMessageRecalled(bot.groupRecallEvent) bot.Client.OnGroupNotify(bot.groupNotifyEvent) bot.Client.OnFriendNotify(bot.friendNotifyEvent) + bot.Client.OnMemberSpecialTitleUpdated(bot.memberTitleUpdatedEvent) bot.Client.OnFriendMessageRecalled(bot.friendRecallEvent) bot.Client.OnReceivedOfflineFile(bot.offlineFileEvent) bot.Client.OnJoinGroup(bot.joinGroupEvent) diff --git a/coolq/event.go b/coolq/event.go index 9efb978..f8839a3 100644 --- a/coolq/event.go +++ b/coolq/event.go @@ -282,6 +282,21 @@ func (bot *CQBot) friendNotifyEvent(c *client.QQClient, e client.INotifyEvent) { } } +func (bot *CQBot) memberTitleUpdatedEvent(c *client.QQClient, e *client.MemberSpecialTitleUpdatedEvent) { + group := c.FindGroup(e.GroupCode) + mem := group.FindMember(e.Uin) + log.Infof("群 %v(%v) 内成员 %v(%v) 获得了新的头衔: %v", group.Name, group.Code, mem.DisplayName(), mem.Uin, e.NewTitle) + bot.dispatchEventMessage(MSG{ + "post_type": "notice", + "notice_type": "notify", + "sub_type": "title", + "self_id": c.Uin, + "user_id": e.Uin, + "time": time.Now().Unix(), + "title": e.NewTitle, + }) +} + func (bot *CQBot) friendRecallEvent(c *client.QQClient, e *client.FriendMessageRecalledEvent) { f := c.FindFriend(e.FriendUin) gid := toGlobalID(e.FriendUin, e.MessageId)