1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

supported GroupMemberJoinedEvent.

This commit is contained in:
Mrs4s 2020-07-13 17:50:02 +08:00
parent 8eb14c1181
commit c4107d335f
5 changed files with 255 additions and 19 deletions

View File

@ -95,6 +95,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
"MessageSvc.PushNotify": decodeSvcNotify, "MessageSvc.PushNotify": decodeSvcNotify,
"OnlinePush.PbPushGroupMsg": decodeGroupMessagePacket, "OnlinePush.PbPushGroupMsg": decodeGroupMessagePacket,
"OnlinePush.ReqPush": decodeOnlinePushReqPacket, "OnlinePush.ReqPush": decodeOnlinePushReqPacket,
"OnlinePush.PbPushTransMsg": decodeOnlinePushTransPacket,
"ConfigPushSvc.PushReq": decodePushReqPacket, "ConfigPushSvc.PushReq": decodePushReqPacket,
"MessageSvc.PbGetMsg": decodeMessageSvcPacket, "MessageSvc.PbGetMsg": decodeMessageSvcPacket,
"friendlist.getFriendGroupList": decodeFriendGroupListResponse, "friendlist.getFriendGroupList": decodeFriendGroupListResponse,

View File

@ -156,15 +156,25 @@ func decodeMessageSvcPacket(c *QQClient, seq uint16, payload []byte) (interface{
groupJoinLock.Lock() groupJoinLock.Lock()
group := c.FindGroup(message.Head.FromUin) group := c.FindGroup(message.Head.FromUin)
if message.Head.AuthUin == c.Uin { if message.Head.AuthUin == c.Uin {
if group != nil { if group == nil && c.ReloadGroupList() == nil {
groupJoinLock.Unlock() c.dispatchJoinGroupEvent(c.FindGroup(message.Head.FromUin))
continue
} }
if c.ReloadGroupList() != nil { } else {
groupJoinLock.Unlock() if group != nil && group.FindMember(message.Head.AuthUin) == nil {
continue 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() groupJoinLock.Unlock()
case 166: case 166:
@ -379,3 +389,12 @@ func decodeOnlinePushReqPacket(c *QQClient, seq uint16, payload []byte) (interfa
return nil, nil 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
}

View File

@ -14,6 +14,7 @@ type eventHandlers struct {
groupMuteEventHandlers []func(*QQClient, *GroupMuteEvent) groupMuteEventHandlers []func(*QQClient, *GroupMuteEvent)
groupRecalledHandlers []func(*QQClient, *GroupMessageRecalledEvent) groupRecalledHandlers []func(*QQClient, *GroupMessageRecalledEvent)
joinGroupHandlers []func(*QQClient, *GroupInfo) joinGroupHandlers []func(*QQClient, *GroupInfo)
memberJoinedHandlers []func(*QQClient, *GroupInfo, *GroupMemberInfo)
groupMessageReceiptHandlers sync.Map groupMessageReceiptHandlers sync.Map
} }
@ -29,6 +30,8 @@ func (c *QQClient) OnEvent(i interface{}) error {
c.OnGroupMessageRecalled(f) c.OnGroupMessageRecalled(f)
case func(*QQClient, *GroupInfo): case func(*QQClient, *GroupInfo):
c.OnJoinGroup(f) c.OnJoinGroup(f)
case func(*QQClient, *GroupInfo, *GroupMemberInfo):
c.OnGroupMemberJoined(f)
default: default:
return ErrEventUndefined return ErrEventUndefined
} }
@ -59,6 +62,10 @@ func (c *QQClient) OnJoinGroup(f func(*QQClient, *GroupInfo)) {
c.eventHandlers.joinGroupHandlers = append(c.eventHandlers.joinGroupHandlers, f) 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)) { func (c *QQClient) OnGroupMessageRecalled(f func(*QQClient, *GroupMessageRecalledEvent)) {
c.eventHandlers.groupRecalledHandlers = append(c.eventHandlers.groupRecalledHandlers, f) 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) { func (c *QQClient) dispatchGroupMessageReceiptEvent(e *groupMessageReceiptEvent) {
c.eventHandlers.groupMessageReceiptHandlers.Range(func(_, f interface{}) bool { c.eventHandlers.groupMessageReceiptHandlers.Range(func(_, f interface{}) bool {
go f.(func(*QQClient, *groupMessageReceiptEvent))(c, e) go f.(func(*QQClient, *groupMessageReceiptEvent))(c, e)

View File

@ -4306,6 +4306,149 @@ func (x *SyncCookie) GetConst4() int64 {
return 0 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 protoreflect.FileDescriptor
var file_msg_proto_rawDesc = []byte{ 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, 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, 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, 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, 0x73, 0x74, 0x34, 0x22, 0x8e, 0x03, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4d, 0x73, 0x67,
0x09, 0x0a, 0x05, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x72, 0x6f, 0x6d, 0x55, 0x69, 0x6e, 0x18,
0x4e, 0x54, 0x49, 0x4e, 0x55, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x54, 0x4f, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x66, 0x72, 0x6f, 0x6d, 0x55, 0x69, 0x6e, 0x12, 0x14,
0x50, 0x10, 0x02, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x6d, 0x73, 0x67, 0x62, 0x06, 0x70, 0x72, 0x0a, 0x05, 0x74, 0x6f, 0x55, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x74,
0x6f, 0x74, 0x6f, 0x33, 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 ( var (
@ -5011,7 +5179,7 @@ func file_msg_proto_rawDescGZIP() []byte {
} }
var file_msg_proto_enumTypes = make([]protoimpl.EnumInfo, 1) 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{}{ var file_msg_proto_goTypes = []interface{}{
(SyncFlag)(0), // 0: SyncFlag (SyncFlag)(0), // 0: SyncFlag
(*GetMessageRequest)(nil), // 1: GetMessageRequest (*GetMessageRequest)(nil), // 1: GetMessageRequest
@ -5052,6 +5220,7 @@ var file_msg_proto_goTypes = []interface{}{
(*InstInfo)(nil), // 36: InstInfo (*InstInfo)(nil), // 36: InstInfo
(*ExtGroupKeyInfo)(nil), // 37: ExtGroupKeyInfo (*ExtGroupKeyInfo)(nil), // 37: ExtGroupKeyInfo
(*SyncCookie)(nil), // 38: SyncCookie (*SyncCookie)(nil), // 38: SyncCookie
(*TransMsgInfo)(nil), // 39: TransMsgInfo
} }
var file_msg_proto_depIdxs = []int32{ var file_msg_proto_depIdxs = []int32{
0, // 0: GetMessageRequest.syncFlag:type_name -> SyncFlag 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, // 37: InstCtrl.msgSendToInst:type_name -> InstInfo
36, // 38: InstCtrl.msgExcludeInst:type_name -> InstInfo 36, // 38: InstCtrl.msgExcludeInst:type_name -> InstInfo
36, // 39: InstCtrl.msgFromInst:type_name -> InstInfo 36, // 39: InstCtrl.msgFromInst:type_name -> InstInfo
40, // [40:40] is the sub-list for method output_type 37, // 40: TransMsgInfo.extGroupKeyInfo:type_name -> ExtGroupKeyInfo
40, // [40:40] is the sub-list for method input_type 41, // [41:41] is the sub-list for method output_type
40, // [40:40] is the sub-list for extension type_name 41, // [41:41] is the sub-list for method input_type
40, // [40:40] is the sub-list for extension extendee 41, // [41:41] is the sub-list for extension type_name
0, // [0:40] is the sub-list for field 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() } func init() { file_msg_proto_init() }
@ -5563,6 +5733,18 @@ func file_msg_proto_init() {
return nil 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{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -5570,7 +5752,7 @@ func file_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_msg_proto_rawDesc, RawDescriptor: file_msg_proto_rawDesc,
NumEnums: 1, NumEnums: 1,
NumMessages: 38, NumMessages: 39,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -526,6 +526,22 @@ message SyncCookie {
int64 const4 = 14; 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 { enum SyncFlag {
START = 0; START = 0;
CONTINUME = 1; CONTINUME = 1;