diff --git a/client/client.go b/client/client.go index d1aec2ad..6da519a2 100644 --- a/client/client.go +++ b/client/client.go @@ -95,6 +95,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient { "MessageSvc.PushNotify": decodeSvcNotify, "OnlinePush.PbPushGroupMsg": decodeGroupMessagePacket, "OnlinePush.ReqPush": decodeOnlinePushReqPacket, + "OnlinePush.PbPushTransMsg": decodeOnlinePushTransPacket, "ConfigPushSvc.PushReq": decodePushReqPacket, "MessageSvc.PbGetMsg": decodeMessageSvcPacket, "friendlist.getFriendGroupList": decodeFriendGroupListResponse, diff --git a/client/decoders.go b/client/decoders.go index d7260029..06209b33 100644 --- a/client/decoders.go +++ b/client/decoders.go @@ -156,15 +156,25 @@ func decodeMessageSvcPacket(c *QQClient, seq uint16, payload []byte) (interface{ groupJoinLock.Lock() group := c.FindGroup(message.Head.FromUin) if message.Head.AuthUin == c.Uin { - if group != nil { - groupJoinLock.Unlock() - continue + if group == nil && c.ReloadGroupList() == nil { + c.dispatchJoinGroupEvent(c.FindGroup(message.Head.FromUin)) } - if c.ReloadGroupList() != nil { - groupJoinLock.Unlock() - continue + } else { + if group != nil && group.FindMember(message.Head.AuthUin) == nil { + mem := &GroupMemberInfo{ + Uin: message.Head.AuthUin, + Nickname: func() string { + if message.Head.AuthNick == "" { + return message.Head.FromNick + } + return message.Head.AuthNick + }(), + JoinTime: time.Now().Unix(), + Permission: Member, + } + group.Members = append(group.Members, mem) + c.dispatchNewMemberEvent(group, mem) } - c.dispatchJoinGroupEvent(c.FindGroup(message.Head.FromUin)) } groupJoinLock.Unlock() case 166: @@ -379,3 +389,12 @@ func decodeOnlinePushReqPacket(c *QQClient, seq uint16, payload []byte) (interfa return nil, nil } + +func decodeOnlinePushTransPacket(c *QQClient, seq uint16, payload []byte) (interface{}, error) { + info := msg.TransMsgInfo{} + err := proto.Unmarshal(payload, &info) + if err != nil { + return nil, err + } + return nil, nil +} diff --git a/client/events.go b/client/events.go index 79ab6e05..c202b6c4 100644 --- a/client/events.go +++ b/client/events.go @@ -14,6 +14,7 @@ type eventHandlers struct { groupMuteEventHandlers []func(*QQClient, *GroupMuteEvent) groupRecalledHandlers []func(*QQClient, *GroupMessageRecalledEvent) joinGroupHandlers []func(*QQClient, *GroupInfo) + memberJoinedHandlers []func(*QQClient, *GroupInfo, *GroupMemberInfo) groupMessageReceiptHandlers sync.Map } @@ -29,6 +30,8 @@ func (c *QQClient) OnEvent(i interface{}) error { c.OnGroupMessageRecalled(f) case func(*QQClient, *GroupInfo): c.OnJoinGroup(f) + case func(*QQClient, *GroupInfo, *GroupMemberInfo): + c.OnGroupMemberJoined(f) default: return ErrEventUndefined } @@ -59,6 +62,10 @@ func (c *QQClient) OnJoinGroup(f func(*QQClient, *GroupInfo)) { c.eventHandlers.joinGroupHandlers = append(c.eventHandlers.joinGroupHandlers, f) } +func (c *QQClient) OnGroupMemberJoined(f func(*QQClient, *GroupInfo, *GroupMemberInfo)) { + c.eventHandlers.memberJoinedHandlers = append(c.eventHandlers.memberJoinedHandlers, f) +} + func (c *QQClient) OnGroupMessageRecalled(f func(*QQClient, *GroupMessageRecalledEvent)) { c.eventHandlers.groupRecalledHandlers = append(c.eventHandlers.groupRecalledHandlers, f) } @@ -132,6 +139,17 @@ func (c *QQClient) dispatchJoinGroupEvent(group *GroupInfo) { } } +func (c *QQClient) dispatchNewMemberEvent(group *GroupInfo, mem *GroupMemberInfo) { + if group == nil || mem == nil { + return + } + for _, f := range c.eventHandlers.memberJoinedHandlers { + cover(func() { + f(c, group, mem) + }) + } +} + func (c *QQClient) dispatchGroupMessageReceiptEvent(e *groupMessageReceiptEvent) { c.eventHandlers.groupMessageReceiptHandlers.Range(func(_, f interface{}) bool { go f.(func(*QQClient, *groupMessageReceiptEvent))(c, e) diff --git a/client/pb/msg/msg.pb.go b/client/pb/msg/msg.pb.go index 5cf6b64f..d82baac2 100644 --- a/client/pb/msg/msg.pb.go +++ b/client/pb/msg/msg.pb.go @@ -4306,6 +4306,149 @@ func (x *SyncCookie) GetConst4() int64 { return 0 } +type TransMsgInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FromUin int64 `protobuf:"varint,1,opt,name=fromUin,proto3" json:"fromUin,omitempty"` + ToUin int64 `protobuf:"varint,2,opt,name=toUin,proto3" json:"toUin,omitempty"` + MsgType int32 `protobuf:"varint,3,opt,name=msgType,proto3" json:"msgType,omitempty"` + MsgSubtype int32 `protobuf:"varint,4,opt,name=msgSubtype,proto3" json:"msgSubtype,omitempty"` + MsgSeq int32 `protobuf:"varint,5,opt,name=msgSeq,proto3" json:"msgSeq,omitempty"` + MsgUid int64 `protobuf:"varint,6,opt,name=msgUid,proto3" json:"msgUid,omitempty"` + MsgTime int32 `protobuf:"varint,7,opt,name=msgTime,proto3" json:"msgTime,omitempty"` + RealMsgTime int32 `protobuf:"varint,8,opt,name=realMsgTime,proto3" json:"realMsgTime,omitempty"` + NickName string `protobuf:"bytes,9,opt,name=nickName,proto3" json:"nickName,omitempty"` + MsgData []byte `protobuf:"bytes,10,opt,name=msgData,proto3" json:"msgData,omitempty"` + SvrIp int32 `protobuf:"varint,11,opt,name=svrIp,proto3" json:"svrIp,omitempty"` + ExtGroupKeyInfo *ExtGroupKeyInfo `protobuf:"bytes,12,opt,name=extGroupKeyInfo,proto3" json:"extGroupKeyInfo,omitempty"` + GeneralFlag int32 `protobuf:"varint,17,opt,name=generalFlag,proto3" json:"generalFlag,omitempty"` +} + +func (x *TransMsgInfo) Reset() { + *x = TransMsgInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[38] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TransMsgInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TransMsgInfo) ProtoMessage() {} + +func (x *TransMsgInfo) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[38] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TransMsgInfo.ProtoReflect.Descriptor instead. +func (*TransMsgInfo) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{38} +} + +func (x *TransMsgInfo) GetFromUin() int64 { + if x != nil { + return x.FromUin + } + return 0 +} + +func (x *TransMsgInfo) GetToUin() int64 { + if x != nil { + return x.ToUin + } + return 0 +} + +func (x *TransMsgInfo) GetMsgType() int32 { + if x != nil { + return x.MsgType + } + return 0 +} + +func (x *TransMsgInfo) GetMsgSubtype() int32 { + if x != nil { + return x.MsgSubtype + } + return 0 +} + +func (x *TransMsgInfo) GetMsgSeq() int32 { + if x != nil { + return x.MsgSeq + } + return 0 +} + +func (x *TransMsgInfo) GetMsgUid() int64 { + if x != nil { + return x.MsgUid + } + return 0 +} + +func (x *TransMsgInfo) GetMsgTime() int32 { + if x != nil { + return x.MsgTime + } + return 0 +} + +func (x *TransMsgInfo) GetRealMsgTime() int32 { + if x != nil { + return x.RealMsgTime + } + return 0 +} + +func (x *TransMsgInfo) GetNickName() string { + if x != nil { + return x.NickName + } + return "" +} + +func (x *TransMsgInfo) GetMsgData() []byte { + if x != nil { + return x.MsgData + } + return nil +} + +func (x *TransMsgInfo) GetSvrIp() int32 { + if x != nil { + return x.SvrIp + } + return 0 +} + +func (x *TransMsgInfo) GetExtGroupKeyInfo() *ExtGroupKeyInfo { + if x != nil { + return x.ExtGroupKeyInfo + } + return nil +} + +func (x *TransMsgInfo) GetGeneralFlag() int32 { + if x != nil { + return x.GeneralFlag + } + return 0 +} + var File_msg_proto protoreflect.FileDescriptor var file_msg_proto_rawDesc = []byte{ @@ -4991,11 +5134,36 @@ var file_msg_proto_rawDesc = []byte{ 0x79, 0x6e, 0x63, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x34, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x63, 0x6f, 0x6e, - 0x73, 0x74, 0x34, 0x2a, 0x2e, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x46, 0x6c, 0x61, 0x67, 0x12, - 0x09, 0x0a, 0x05, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, - 0x4e, 0x54, 0x49, 0x4e, 0x55, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x54, 0x4f, - 0x50, 0x10, 0x02, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x6d, 0x73, 0x67, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x74, 0x34, 0x22, 0x8e, 0x03, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4d, 0x73, 0x67, + 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x72, 0x6f, 0x6d, 0x55, 0x69, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x66, 0x72, 0x6f, 0x6d, 0x55, 0x69, 0x6e, 0x12, 0x14, + 0x0a, 0x05, 0x74, 0x6f, 0x55, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x74, + 0x6f, 0x55, 0x69, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, + 0x0a, 0x0a, 0x6d, 0x73, 0x67, 0x53, 0x75, 0x62, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0a, 0x6d, 0x73, 0x67, 0x53, 0x75, 0x62, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x6d, 0x73, 0x67, 0x53, 0x65, 0x71, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, + 0x6d, 0x73, 0x67, 0x53, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x73, 0x67, 0x55, 0x69, 0x64, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6d, 0x73, 0x67, 0x55, 0x69, 0x64, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x73, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x07, 0x6d, 0x73, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x61, 0x6c, + 0x4d, 0x73, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x72, + 0x65, 0x61, 0x6c, 0x4d, 0x73, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, + 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, + 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x73, 0x67, 0x44, 0x61, 0x74, + 0x61, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6d, 0x73, 0x67, 0x44, 0x61, 0x74, 0x61, + 0x12, 0x14, 0x0a, 0x05, 0x73, 0x76, 0x72, 0x49, 0x70, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x73, 0x76, 0x72, 0x49, 0x70, 0x12, 0x3a, 0x0a, 0x0f, 0x65, 0x78, 0x74, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x10, 0x2e, 0x45, 0x78, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4b, 0x65, 0x79, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x20, 0x0a, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x46, 0x6c, 0x61, + 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, + 0x46, 0x6c, 0x61, 0x67, 0x2a, 0x2e, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x46, 0x6c, 0x61, 0x67, + 0x12, 0x09, 0x0a, 0x05, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, + 0x4f, 0x4e, 0x54, 0x49, 0x4e, 0x55, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x54, + 0x4f, 0x50, 0x10, 0x02, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x6d, 0x73, 0x67, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -5011,7 +5179,7 @@ func file_msg_proto_rawDescGZIP() []byte { } var file_msg_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 38) +var file_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 39) var file_msg_proto_goTypes = []interface{}{ (SyncFlag)(0), // 0: SyncFlag (*GetMessageRequest)(nil), // 1: GetMessageRequest @@ -5052,6 +5220,7 @@ var file_msg_proto_goTypes = []interface{}{ (*InstInfo)(nil), // 36: InstInfo (*ExtGroupKeyInfo)(nil), // 37: ExtGroupKeyInfo (*SyncCookie)(nil), // 38: SyncCookie + (*TransMsgInfo)(nil), // 39: TransMsgInfo } var file_msg_proto_depIdxs = []int32{ 0, // 0: GetMessageRequest.syncFlag:type_name -> SyncFlag @@ -5094,11 +5263,12 @@ var file_msg_proto_depIdxs = []int32{ 36, // 37: InstCtrl.msgSendToInst:type_name -> InstInfo 36, // 38: InstCtrl.msgExcludeInst:type_name -> InstInfo 36, // 39: InstCtrl.msgFromInst:type_name -> InstInfo - 40, // [40:40] is the sub-list for method output_type - 40, // [40:40] is the sub-list for method input_type - 40, // [40:40] is the sub-list for extension type_name - 40, // [40:40] is the sub-list for extension extendee - 0, // [0:40] is the sub-list for field type_name + 37, // 40: TransMsgInfo.extGroupKeyInfo:type_name -> ExtGroupKeyInfo + 41, // [41:41] is the sub-list for method output_type + 41, // [41:41] is the sub-list for method input_type + 41, // [41:41] is the sub-list for extension type_name + 41, // [41:41] is the sub-list for extension extendee + 0, // [0:41] is the sub-list for field type_name } func init() { file_msg_proto_init() } @@ -5563,6 +5733,18 @@ func file_msg_proto_init() { return nil } } + file_msg_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TransMsgInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -5570,7 +5752,7 @@ func file_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_msg_proto_rawDesc, NumEnums: 1, - NumMessages: 38, + NumMessages: 39, NumExtensions: 0, NumServices: 0, }, diff --git a/client/pb/msg/msg.proto b/client/pb/msg/msg.proto index f831c4b8..f1596485 100644 --- a/client/pb/msg/msg.proto +++ b/client/pb/msg/msg.proto @@ -526,6 +526,22 @@ message SyncCookie { int64 const4 = 14; } +message TransMsgInfo { + int64 fromUin = 1; + int64 toUin = 2; + int32 msgType = 3; + int32 msgSubtype = 4; + int32 msgSeq = 5; + int64 msgUid = 6; + int32 msgTime = 7; + int32 realMsgTime = 8; + string nickName = 9; + bytes msgData = 10; + int32 svrIp = 11; + ExtGroupKeyInfo extGroupKeyInfo = 12; + int32 generalFlag = 17; +} + enum SyncFlag { START = 0; CONTINUME = 1;