diff --git a/client/entity/group.go b/client/entity/group.go index f92c27a..4ac2314 100644 --- a/client/entity/group.go +++ b/client/entity/group.go @@ -67,44 +67,42 @@ type ( } UserJoinGroupRequest struct { - GroupUin uint32 - InvitorUin uint32 - InvitorUID string - TargetUin uint32 - TargetUID string - OperatorUin uint32 - OperatorUID string - Sequence uint64 - State EventState - EventType EventType - Comment string - IsFiltered bool + GroupName string `json:"group_name"` + GroupUin uint32 `json:"group_id"` + InvitorUin uint32 `json:"invitor_uin"` + InvitorUID string `json:"-"` + TargetNick string `json:"requester_nick"` + TargetUin uint32 `json:"requester_uin"` + TargetUID string `json:"-"` + OperatorUin uint32 `json:"actor"` + OperatorUID string `json:"-"` + Sequence uint64 `json:"request_id"` + Checked bool `json:"checked"` + State EventState `json:"-"` + EventType EventType `json:"-"` + Comment string `json:"message"` + IsFiltered bool `json:"is_filtered"` } GroupInvitedRequest struct { - GroupUin uint32 - InvitorUin uint32 - InvitorUID string - Sequence uint64 - State EventState - EventType EventType - IsFiltered bool + GroupUin uint32 `json:"group_id"` + GroupName string `json:"group_name"` + InvitorNick string `json:"invitor_nick"` + InvitorUin uint32 `json:"invitor_uin"` + InvitorUID string `json:"-"` + Sequence uint64 `json:"request_id"` + Checked bool `json:"checked"` + State EventState `json:"-"` + EventType EventType `json:"-"` + IsFiltered bool `json:"is_filtered"` } GroupSystemMessages struct { - InvitedRequests []*GroupInvitedRequest - JoinRequests []*UserJoinGroupRequest + InvitedRequests []*GroupInvitedRequest `json:"invited_requests"` + JoinRequests []*UserJoinGroupRequest `json:"join_requests"` } ) -func (r *UserJoinGroupRequest) Checked() bool { - return r.State != Unprocessed -} - -func (r *GroupInvitedRequest) Checked() bool { - return r.State != Unprocessed -} - func (g *Group) Avatar() string { return fmt.Sprintf("https://p.qlogo.cn/gh/%d/%d/0/", g.GroupUin, g.GroupUin) } diff --git a/client/listener.go b/client/listener.go index 217ea66..15485af 100644 --- a/client/listener.go +++ b/client/listener.go @@ -133,7 +133,7 @@ func decodeOlPushServicePacket(c *QQClient, pkt *network.Packet) (any, error) { filteredRequests, freqErr := c.GetGroupSystemMessages(true, 20, ev.GroupUin) if reqErr == nil && freqErr == nil { for _, request := range append(commonRequests.JoinRequests, filteredRequests.JoinRequests...) { - if request.TargetUID == ev.TargetUID && !request.Checked() { + if request.TargetUID == ev.TargetUID && !request.Checked { ev.RequestSeq = request.Sequence ev.Answer = request.Comment } @@ -180,7 +180,7 @@ func decodeOlPushServicePacket(c *QQClient, pkt *network.Packet) (any, error) { filteredRequests, freqErr := c.GetGroupSystemMessages(true, 20, ev.GroupUin) if reqErr == nil && freqErr == nil { for _, request := range append(commonRequests.InvitedRequests, filteredRequests.InvitedRequests...) { - if !request.Checked() { + if !request.Checked { ev.RequestSeq = request.Sequence break } diff --git a/client/operation.go b/client/operation.go index b6aca4a..2c76411 100644 --- a/client/operation.go +++ b/client/operation.go @@ -618,7 +618,27 @@ func (c *QQClient) GetGroupSystemMessages(isFiltered bool, count uint32, groupUi if err != nil { return nil, err } - return oidb2.ParseFetchGroupSystemMessagesReq(isFiltered, resp, groupUin...) + msgs, err := oidb2.ParseFetchGroupSystemMessagesReq(isFiltered, resp, groupUin...) + if err != nil { + return nil, err + } + for _, req := range msgs.InvitedRequests { + if g, err := c.FetchGroupInfo(req.GroupUin, true); err == nil { + req.GroupName = g.GroupName + } + if u, err := c.FetchUserInfoUin(req.InvitorUin); err == nil { + req.InvitorNick = u.Nickname + } + } + for _, req := range msgs.JoinRequests { + if g, err := c.FetchGroupInfo(req.GroupUin, false); err == nil { + req.GroupName = g.GroupName + } + if u, err := c.FetchUserInfoUin(req.TargetUin); err == nil { + req.TargetNick = u.Nickname + } + } + return msgs, nil } // SetGroupRequest 处理加群请求 diff --git a/client/packets/oidb/fetch_group_system_messages.go b/client/packets/oidb/fetch_group_system_messages.go index 144c09a..8d34fae 100644 --- a/client/packets/oidb/fetch_group_system_messages.go +++ b/client/packets/oidb/fetch_group_system_messages.go @@ -41,6 +41,7 @@ func ParseFetchGroupSystemMessagesReq(isFiltered bool, data []byte, groupUin ... return "" }), Sequence: r.Sequence, + Checked: entity.EventState(r.State) != entity.Unprocessed, State: entity.EventState(r.State), EventType: entity.EventType(r.EventType), Comment: r.Comment, @@ -55,6 +56,7 @@ func ParseFetchGroupSystemMessagesReq(isFiltered bool, data []byte, groupUin ... return "" }), Sequence: r.Sequence, + Checked: entity.EventState(r.State) != entity.Unprocessed, State: entity.EventState(r.State), EventType: entity.EventType(r.EventType), IsFiltered: isFiltered,