diff --git a/coolq/api.go b/coolq/api.go index 5e34047e9..611dcccd7 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -1519,7 +1519,7 @@ func (bot *CQBot) CQGetEssenceMessageList(groupID int64) global.MSG { "operator_id": m.OperatorUin, } if operator := bot.Client.GetCachedMemberInfo(m.OperatorUin, uint32(groupID)); operator != nil { - msg["operator_nick"] = operator.MemberName + msg["operator_nick"] = operator.DisplayName() } msg["message_id"] = db.ToGlobalID(groupID, int32(m.Message.ID)) list = append(list, msg) diff --git a/coolq/bot.go b/coolq/bot.go index 2a26286b7..134f88da5 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -294,11 +294,7 @@ func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) (in member := bot.Client.GetCachedMemberInfo(i.TargetUin, uint32(groupID)) if member != nil { i.TargetUID = member.UID - if member.MemberCard != "" { - i.Display = "@" + member.MemberCard - } else { - i.Display = "@" + member.MemberName - } + i.Display = "@" + member.DisplayName() } } } diff --git a/coolq/converter.go b/coolq/converter.go index eeb6fe218..384bdbe23 100644 --- a/coolq/converter.go +++ b/coolq/converter.go @@ -14,8 +14,12 @@ import ( ) func convertGroupMemberInfo(groupID int64, m *entity.GroupMember) global.MSG { - // TODO nt 协议依然是获取不到 sex := "unknown" + //if m.Gender == 1 { // unknown = 0xff + // sex = "female" + //} else if m.Gender == 0 { + // sex = "male" + //} role := "member" switch m.Permission { // nolint:exhaustive case entity.Owner: @@ -28,7 +32,7 @@ func convertGroupMemberInfo(groupID int64, m *entity.GroupMember) global.MSG { return global.MSG{ "group_id": groupID, "user_id": m.Uin, - "nickname": m.MemberName, + "nickname": m.Nickname, "card": m.MemberCard, "sex": sex, "age": 0, diff --git a/coolq/event.go b/coolq/event.go index 6f7a8d0da..2043f57ed 100644 --- a/coolq/event.go +++ b/coolq/event.go @@ -179,8 +179,8 @@ func (bot *CQBot) tempMessageEvent(_ *client.QQClient, e *message.TempMessage) { func (bot *CQBot) groupMutedEvent(c *client.QQClient, e *event2.GroupMute) { g := c.GetCachedGroupInfo(e.GroupUin) operator := c.GetCachedMemberInfo(c.GetUin(e.OperatorUID, e.GroupUin), e.GroupUin) - target := c.GetCachedMemberInfo(c.GetUin(e.TargetUID, e.GroupUin), e.GroupUin) - if e.TargetUID == "" { + target := c.GetCachedMemberInfo(c.GetUin(e.UserUID, e.GroupUin), e.GroupUin) + if e.UserUID == "" { if e.Duration != 0 { log.Infof("群 %v 被 %v 开启全员禁言.", formatGroupName(g), formatMemberName(operator)) @@ -219,7 +219,7 @@ func (bot *CQBot) groupRecallEvent(c *client.QQClient, e *event2.GroupRecall) { g := c.GetCachedGroupInfo(e.GroupUin) gid := db.ToGlobalID(int64(e.GroupUin), int32(e.Sequence)) operator := c.GetCachedMemberInfo(c.GetUin(e.OperatorUID, e.GroupUin), e.GroupUin) - Author := c.GetCachedMemberInfo(c.GetUin(e.AuthorUID, e.GroupUin), e.GroupUin) + Author := c.GetCachedMemberInfo(c.GetUin(e.UserUID, e.GroupUin), e.GroupUin) log.Infof("群 %v 内 %v 撤回了 %v 的消息: %v.", formatGroupName(g), formatMemberName(operator), formatMemberName(Author), gid) @@ -239,13 +239,13 @@ func (bot *CQBot) groupNotifyEvent(c *client.QQClient, e event2.INotifyEvent) { //nolint:gocritic switch notify := e.(type) { case *event2.GroupPokeEvent: - sender := c.GetCachedMemberInfo(notify.Sender, e.From()) + sender := c.GetCachedMemberInfo(notify.UserUin, e.From()) receiver := c.GetCachedMemberInfo(notify.Receiver, e.From()) log.Infof("群 %v 内 %v 戳了戳 %v", formatGroupName(group), formatMemberName(sender), formatMemberName(receiver)) bot.dispatchEvent("notice/notify/poke", global.MSG{ "group_id": group.GroupUin, - "user_id": notify.Sender, - "sender_id": notify.Sender, + "user_id": notify.UserUin, + "sender_id": notify.UserUin, "target_id": notify.Receiver, }) //case *client.GroupRedBagLuckyKingNotifyEvent: @@ -301,25 +301,25 @@ func (bot *CQBot) friendNotifyEvent(c *client.QQClient, e event2.INotifyEvent) { func (bot *CQBot) memberTitleUpdatedEvent(c *client.QQClient, e *event2.MemberSpecialTitleUpdated) { group := c.GetCachedGroupInfo(e.GroupUin) - mem := c.GetCachedMemberInfo(e.Uin, e.GroupUin) + mem := c.GetCachedMemberInfo(e.UserUin, e.GroupUin) log.Infof("群 %v(%v) 内成员 %v(%v) 获得了新的头衔: %v", group.GroupName, group.GroupUin, mem.MemberCard, mem.Uin, e.NewTitle) bot.dispatchEvent("notice/notify/title", global.MSG{ "group_id": group.GroupUin, - "user_id": e.Uin, + "user_id": e.UserUin, "title": e.NewTitle, }) } func (bot *CQBot) friendRecallEvent(c *client.QQClient, e *event2.FriendRecall) { f := c.GetCachedFriendInfo(c.GetUin(e.FromUID)) - gid := db.ToGlobalID(int64(f.Uin), int32(e.Sequence)) - //if f != nil { - log.Infof("好友 %v(%v) 撤回了消息: %v", f.Nickname, f.Uin, gid) - //} else { - // log.Infof("好友 %v 撤回了消息: %v", e.FriendUin, gid) - //} + gid := db.ToGlobalID(int64(e.FromUin), int32(e.Sequence)) + if f != nil { + log.Infof("好友 %v(%v) 撤回了消息: %v", f.Nickname, f.Uin, gid) + } else { + log.Infof("好友 %v 撤回了消息: %v", e.FromUin, gid) + } ev := bot.event("notice/friend_recall", global.MSG{ - "user_id": f.Uin, + "user_id": e.FromUin, "message_id": gid, }) ev.Time = int64(e.Time) @@ -365,7 +365,7 @@ func (bot *CQBot) memberPermissionChangedEvent(_ *client.QQClient, e *event2.Gro } bot.dispatchEvent("notice/group_admin/"+st, global.MSG{ "group_id": e.GroupUin, - "user_id": e.TargetUin, + "user_id": e.UserUin, }) } @@ -381,12 +381,12 @@ func (bot *CQBot) memberPermissionChangedEvent(_ *client.QQClient, e *event2.Gro //} func (bot *CQBot) memberJoinEvent(c *client.QQClient, e *event2.GroupMemberIncrease) { - log.Infof("新成员 %v 进入了群 %v.", formatMemberName(c.GetCachedMemberInfo(e.MemberUin, e.GroupUin)), formatGroupName(c.GetCachedGroupInfo(e.GroupUin))) - bot.dispatch(bot.groupIncrease(int64(e.GroupUin), 0, int64(e.MemberUin))) + log.Infof("新成员 %v 进入了群 %v.", formatMemberName(c.GetCachedMemberInfo(e.UserUin, e.GroupUin)), formatGroupName(c.GetCachedGroupInfo(e.GroupUin))) + bot.dispatch(bot.groupIncrease(int64(e.GroupUin), 0, int64(e.UserUin))) } func (bot *CQBot) memberLeaveEvent(c *client.QQClient, e *event2.GroupMemberDecrease) { - member := c.GetCachedMemberInfo(c.GetUin(e.MemberUID), e.GroupUin) + member := c.GetCachedMemberInfo(c.GetUin(e.UserUID), e.GroupUin) op := c.GetCachedMemberInfo(c.GetUin(e.OperatorUID), e.GroupUin) group := c.GetCachedGroupInfo(e.GroupUin) if e.IsKicked() { @@ -431,11 +431,11 @@ func (bot *CQBot) groupInvitedEvent(_ *client.QQClient, e *event2.GroupInvite) { func (bot *CQBot) groupJoinReqEvent(c *client.QQClient, e *event2.GroupMemberJoinRequest) { group := c.GetCachedGroupInfo(e.GroupUin) - log.Infof("群 %v(%v) 收到来自用户 %v(%v) 的加群请求.", group.GroupName, e.GroupUin, e.TargetNick, e.TargetUin) + log.Infof("群 %v(%v) 收到来自用户 %v(%v) 的加群请求.", group.GroupName, e.GroupUin, e.TargetNick, e.UserUin) flag := strconv.FormatInt(int64(e.RequestSeq), 10) bot.dispatchEvent("request/group/add", global.MSG{ "group_id": e.GroupUin, - "user_id": e.TargetUin, + "user_id": e.UserUin, "invitor_id": e.InvitorUin, "comment": e.Answer, "flag": flag, @@ -458,7 +458,6 @@ func (bot *CQBot) groupJoinReqEvent(c *client.QQClient, e *event2.GroupMemberJoi // }) //} -// TODO 精华消息 func (bot *CQBot) groupEssenceMsg(c *client.QQClient, e *event2.GroupDigestEvent) { g := c.GetCachedGroupInfo(e.GroupUin) gid := db.ToGlobalID(int64(e.GroupUin), int32(e.MessageID)) @@ -467,7 +466,7 @@ func (bot *CQBot) groupEssenceMsg(c *client.QQClient, e *event2.GroupDigestEvent "群 %v 内 %v 将 %v 的消息(%v)设为了精华消息.", formatGroupName(g), formatMemberName(c.GetCachedMemberInfo(e.OperatorUin, e.GroupUin)), - formatMemberName(c.GetCachedMemberInfo(e.SenderUin, e.GroupUin)), + formatMemberName(c.GetCachedMemberInfo(e.UserUin, e.GroupUin)), gid, ) } else { @@ -475,7 +474,7 @@ func (bot *CQBot) groupEssenceMsg(c *client.QQClient, e *event2.GroupDigestEvent "群 %v 内 %v 将 %v 的消息(%v)移出了精华消息.", formatGroupName(g), formatMemberName(c.GetCachedMemberInfo(e.OperatorUin, e.GroupUin)), - formatMemberName(c.GetCachedMemberInfo(e.SenderUin, e.GroupUin)), + formatMemberName(c.GetCachedMemberInfo(e.UserUin, e.GroupUin)), gid, ) } @@ -488,7 +487,7 @@ func (bot *CQBot) groupEssenceMsg(c *client.QQClient, e *event2.GroupDigestEvent } bot.dispatchEvent("notice/essence/"+subtype, global.MSG{ "group_id": e.GroupUin, - "sender_id": e.SenderUin, + "sender_id": e.UserUin, "operator_id": e.OperatorUin, "message_id": gid, }) diff --git a/go.mod b/go.mod index d6c5a2b71..09c78b192 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/FloatTech/sqlite v1.6.3 - github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129090211-e0fdf8ca5390 + github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129102648-b22bfd7d71ba github.com/Microsoft/go-winio v0.6.2-0.20230724192519-b29bbd58a65a github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7 github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 diff --git a/go.sum b/go.sum index 8df9666ea..59a687669 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1 h1:g4pTnDJUW4VbJ9Nvo github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129090211-e0fdf8ca5390 h1:NIDdk9Z5ztBhWcLJc8WvXxRSgdSqZlikrFBU5pII78Q= github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129090211-e0fdf8ca5390/go.mod h1:m7ydyvA8DKOg5c6iTFDfNtfIK9uhqXVJKRXl4mlGkTA= +github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129102648-b22bfd7d71ba h1:x3ccoK+TJhIcZjO+Ybsv1YwCbowNq9ZHvjOtlKBuCFU= +github.com/LagrangeDev/LagrangeGo v0.1.3-0.20241129102648-b22bfd7d71ba/go.mod h1:m7ydyvA8DKOg5c6iTFDfNtfIK9uhqXVJKRXl4mlGkTA= github.com/Microsoft/go-winio v0.6.2-0.20230724192519-b29bbd58a65a h1:aU1703IHxupjzipvhu16qYKLMR03e+8WuNR+JMsKfGU= github.com/Microsoft/go-winio v0.6.2-0.20230724192519-b29bbd58a65a/go.mod h1:OZqLNXdYJHmx7aqq/T6wAdFEdoGm5nmIfC4kU7M8P8o= github.com/RomiChan/protobuf v0.1.1-0.20230204044148-2ed269a2e54d h1:/Xuj3fIiMY2ls1TwvPKmaqQrtJsPY+c9s+0lOScVHd8= @@ -162,6 +164,7 @@ golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJ golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.ilharper.com/x/isatty v1.1.1 h1:RAg32Pxq/nIK4AVtdm9RBqxsxZZX1uRKRSS21E5SHMk= gopkg.ilharper.com/x/isatty v1.1.1/go.mod h1:ofpv77Td5qQO6R1dmDd3oNt8TZdRo+l5gYAMxopRyS0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=