From 3e033da6a6ab64d4e56560738f1337a861929a31 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Tue, 29 Sep 2020 20:18:03 +0800 Subject: [PATCH 1/6] feature word segmentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tx分词API --- client/builders.go | 18 ++ client/client.go | 16 ++ client/decoders.go | 16 ++ client/pb/oidb/oidb0xD79.proto | 25 +++ client/pb/oidb/oidb0xd79.pb.go | 369 +++++++++++++++++++++++++++++++++ 5 files changed, 444 insertions(+) create mode 100644 client/pb/oidb/oidb0xD79.proto create mode 100644 client/pb/oidb/oidb0xd79.pb.go diff --git a/client/builders.go b/client/builders.go index eb2e178d..bd9ddb18 100644 --- a/client/builders.go +++ b/client/builders.go @@ -1240,3 +1240,21 @@ func (c *QQClient) buildAppInfoRequestPacket(id string) (uint16, []byte) { packet := packets.BuildUniPacket(c.Uin, seq, "LightAppSvc.mini_app_info.GetAppInfoById", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload) return seq, packet } + +func (c *QQClient) buildWordSegmentationPacket(data []byte) (uint16, []byte) { + seq := c.nextSeq() + body := &oidb.D79ReqBody{ + Uin: uint64(c.Uin), + Content: data, + Qua: []byte("and_537065262_8.4.5"), + } + b, _ := proto.Marshal(body) + req := &oidb.OIDBSSOPkg{ + Command: 3449, + ServiceType: 1, + Bodybuffer: b, + } + payload, _ := proto.Marshal(req) + packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xd79", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload) + return seq, packet +} diff --git a/client/client.go b/client/client.go index fb07eb42..246ce5b3 100644 --- a/client/client.go +++ b/client/client.go @@ -146,6 +146,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient { "OidbSvc.0x6d6_2": decodeOIDB6d6Response, "OidbSvc.0x88d_0": decodeGroupInfoResponse, "OidbSvc.0xe07_0": decodeImageOcrResponse, + "OidbSvc.0xd79": decodeWordSegmentation, "SummaryCard.ReqSummaryCard": decodeSummaryCardResponse, "PttCenterSvr.ShortVideoDownReq": decodePttShortVideoDownResponse, "LightAppSvc.mini_app_info.GetAppInfoById": decodeAppInfoResponse, @@ -256,6 +257,21 @@ func (c *QQClient) GetGroupHonorInfo(groupCode int64, honorType HonorType) (*Gro return &ret, nil } +func (c *QQClient) GetWordSegmentation(text string) ([]string, error) { + rsp, err := c.sendAndWait(c.buildWordSegmentationPacket([]byte(text))) + if err != nil { + return nil, err + } + if data, ok := rsp.([][]byte); ok { + var ret []string + for _, val := range data { + ret = append(ret, string(val)) + } + return ret, nil + } + return nil, errors.New("decode error") +} + func (c *QQClient) GetSummaryInfo(target int64) (*SummaryCardInfo, error) { rsp, err := c.sendAndWait(c.buildSummaryCardRequestPacket(target)) if err != nil { diff --git a/client/decoders.go b/client/decoders.go index 963af379..29d3c0e0 100644 --- a/client/decoders.go +++ b/client/decoders.go @@ -1037,6 +1037,22 @@ func decodeMultiApplyDownResponse(c *QQClient, _ uint16, payload []byte) (interf return &mt, nil } +// OidbSvc.0xd79 +func decodeWordSegmentation(_ *QQClient, _ uint16, payload []byte) (interface{}, error) { + pkg := oidb.OIDBSSOPkg{} + rsp := &oidb.D79RspBody{} + if err := proto.Unmarshal(payload, &pkg); err != nil { + return nil, err + } + if err := proto.Unmarshal(pkg.Bodybuffer, rsp); err != nil { + return nil, err + } + if rsp.Content != nil { + return rsp.Content.SliceContent, nil + } + return nil, errors.New("no word receive") +} + // OidbSvc.0x6d6_2 func decodeOIDB6d6Response(c *QQClient, _ uint16, payload []byte) (interface{}, error) { pkg := oidb.OIDBSSOPkg{} diff --git a/client/pb/oidb/oidb0xD79.proto b/client/pb/oidb/oidb0xD79.proto new file mode 100644 index 00000000..4baf540c --- /dev/null +++ b/client/pb/oidb/oidb0xD79.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +option go_package = ".;oidb"; + +message D79ReqBody { + uint64 seq = 1; + uint64 uin = 2; + uint32 compress_flag = 3; + bytes content = 4; + uint64 sender_uin = 5; + bytes qua = 6; + bytes word_ext = 7; +} + +message D79RspBody { + uint32 ret = 1; + uint64 seq = 2; + uint64 uin = 3; + uint32 compress_flag = 4; + D79Content content = 5; +} + +message D79Content { + repeated bytes slice_content = 1; +} \ No newline at end of file diff --git a/client/pb/oidb/oidb0xd79.pb.go b/client/pb/oidb/oidb0xd79.pb.go new file mode 100644 index 00000000..18540289 --- /dev/null +++ b/client/pb/oidb/oidb0xd79.pb.go @@ -0,0 +1,369 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.13.0 +// source: oidb0xD79.proto + +package oidb + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type D79ReqBody struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Seq uint64 `protobuf:"varint,1,opt,name=seq,proto3" json:"seq,omitempty"` + Uin uint64 `protobuf:"varint,2,opt,name=uin,proto3" json:"uin,omitempty"` + CompressFlag uint32 `protobuf:"varint,3,opt,name=compress_flag,json=compressFlag,proto3" json:"compress_flag,omitempty"` + Content []byte `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"` + SenderUin uint64 `protobuf:"varint,5,opt,name=sender_uin,json=senderUin,proto3" json:"sender_uin,omitempty"` + Qua []byte `protobuf:"bytes,6,opt,name=qua,proto3" json:"qua,omitempty"` + WordExt []byte `protobuf:"bytes,7,opt,name=word_ext,json=wordExt,proto3" json:"word_ext,omitempty"` +} + +func (x *D79ReqBody) Reset() { + *x = D79ReqBody{} + if protoimpl.UnsafeEnabled { + mi := &file_oidb0xD79_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *D79ReqBody) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*D79ReqBody) ProtoMessage() {} + +func (x *D79ReqBody) ProtoReflect() protoreflect.Message { + mi := &file_oidb0xD79_proto_msgTypes[0] + 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 D79ReqBody.ProtoReflect.Descriptor instead. +func (*D79ReqBody) Descriptor() ([]byte, []int) { + return file_oidb0xD79_proto_rawDescGZIP(), []int{0} +} + +func (x *D79ReqBody) GetSeq() uint64 { + if x != nil { + return x.Seq + } + return 0 +} + +func (x *D79ReqBody) GetUin() uint64 { + if x != nil { + return x.Uin + } + return 0 +} + +func (x *D79ReqBody) GetCompressFlag() uint32 { + if x != nil { + return x.CompressFlag + } + return 0 +} + +func (x *D79ReqBody) GetContent() []byte { + if x != nil { + return x.Content + } + return nil +} + +func (x *D79ReqBody) GetSenderUin() uint64 { + if x != nil { + return x.SenderUin + } + return 0 +} + +func (x *D79ReqBody) GetQua() []byte { + if x != nil { + return x.Qua + } + return nil +} + +func (x *D79ReqBody) GetWordExt() []byte { + if x != nil { + return x.WordExt + } + return nil +} + +type D79RspBody struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ret uint32 `protobuf:"varint,1,opt,name=ret,proto3" json:"ret,omitempty"` + Seq uint64 `protobuf:"varint,2,opt,name=seq,proto3" json:"seq,omitempty"` + Uin uint64 `protobuf:"varint,3,opt,name=uin,proto3" json:"uin,omitempty"` + CompressFlag uint32 `protobuf:"varint,4,opt,name=compress_flag,json=compressFlag,proto3" json:"compress_flag,omitempty"` + Content *D79Content `protobuf:"bytes,5,opt,name=content,proto3" json:"content,omitempty"` +} + +func (x *D79RspBody) Reset() { + *x = D79RspBody{} + if protoimpl.UnsafeEnabled { + mi := &file_oidb0xD79_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *D79RspBody) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*D79RspBody) ProtoMessage() {} + +func (x *D79RspBody) ProtoReflect() protoreflect.Message { + mi := &file_oidb0xD79_proto_msgTypes[1] + 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 D79RspBody.ProtoReflect.Descriptor instead. +func (*D79RspBody) Descriptor() ([]byte, []int) { + return file_oidb0xD79_proto_rawDescGZIP(), []int{1} +} + +func (x *D79RspBody) GetRet() uint32 { + if x != nil { + return x.Ret + } + return 0 +} + +func (x *D79RspBody) GetSeq() uint64 { + if x != nil { + return x.Seq + } + return 0 +} + +func (x *D79RspBody) GetUin() uint64 { + if x != nil { + return x.Uin + } + return 0 +} + +func (x *D79RspBody) GetCompressFlag() uint32 { + if x != nil { + return x.CompressFlag + } + return 0 +} + +func (x *D79RspBody) GetContent() *D79Content { + if x != nil { + return x.Content + } + return nil +} + +type D79Content struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SliceContent [][]byte `protobuf:"bytes,1,rep,name=slice_content,json=sliceContent,proto3" json:"slice_content,omitempty"` +} + +func (x *D79Content) Reset() { + *x = D79Content{} + if protoimpl.UnsafeEnabled { + mi := &file_oidb0xD79_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *D79Content) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*D79Content) ProtoMessage() {} + +func (x *D79Content) ProtoReflect() protoreflect.Message { + mi := &file_oidb0xD79_proto_msgTypes[2] + 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 D79Content.ProtoReflect.Descriptor instead. +func (*D79Content) Descriptor() ([]byte, []int) { + return file_oidb0xD79_proto_rawDescGZIP(), []int{2} +} + +func (x *D79Content) GetSliceContent() [][]byte { + if x != nil { + return x.SliceContent + } + return nil +} + +var File_oidb0xD79_proto protoreflect.FileDescriptor + +var file_oidb0xD79_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x6f, 0x69, 0x64, 0x62, 0x30, 0x78, 0x44, 0x37, 0x39, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xbb, 0x01, 0x0a, 0x0a, 0x44, 0x37, 0x39, 0x52, 0x65, 0x71, 0x42, 0x6f, 0x64, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x73, + 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x03, 0x75, 0x69, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, + 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x63, 0x6f, 0x6d, + 0x70, 0x72, 0x65, 0x73, 0x73, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x75, 0x69, + 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x55, + 0x69, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x71, 0x75, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x03, 0x71, 0x75, 0x61, 0x12, 0x19, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x65, 0x78, 0x74, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x64, 0x45, 0x78, 0x74, 0x22, + 0x8e, 0x01, 0x0a, 0x0a, 0x44, 0x37, 0x39, 0x52, 0x73, 0x70, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x10, + 0x0a, 0x03, 0x72, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x72, 0x65, 0x74, + 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x71, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x73, + 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x03, 0x75, 0x69, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, + 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x63, 0x6f, 0x6d, + 0x70, 0x72, 0x65, 0x73, 0x73, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x25, 0x0a, 0x07, 0x63, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x44, 0x37, 0x39, + 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x22, 0x31, 0x0a, 0x0a, 0x44, 0x37, 0x39, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x23, + 0x0a, 0x0d, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0c, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x3b, 0x6f, 0x69, 0x64, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_oidb0xD79_proto_rawDescOnce sync.Once + file_oidb0xD79_proto_rawDescData = file_oidb0xD79_proto_rawDesc +) + +func file_oidb0xD79_proto_rawDescGZIP() []byte { + file_oidb0xD79_proto_rawDescOnce.Do(func() { + file_oidb0xD79_proto_rawDescData = protoimpl.X.CompressGZIP(file_oidb0xD79_proto_rawDescData) + }) + return file_oidb0xD79_proto_rawDescData +} + +var file_oidb0xD79_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_oidb0xD79_proto_goTypes = []interface{}{ + (*D79ReqBody)(nil), // 0: D79ReqBody + (*D79RspBody)(nil), // 1: D79RspBody + (*D79Content)(nil), // 2: D79Content +} +var file_oidb0xD79_proto_depIdxs = []int32{ + 2, // 0: D79RspBody.content:type_name -> D79Content + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_oidb0xD79_proto_init() } +func file_oidb0xD79_proto_init() { + if File_oidb0xD79_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_oidb0xD79_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*D79ReqBody); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_oidb0xD79_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*D79RspBody); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_oidb0xD79_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*D79Content); 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{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_oidb0xD79_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_oidb0xD79_proto_goTypes, + DependencyIndexes: file_oidb0xD79_proto_depIdxs, + MessageInfos: file_oidb0xD79_proto_msgTypes, + }.Build() + File_oidb0xD79_proto = out.File + file_oidb0xD79_proto_rawDesc = nil + file_oidb0xD79_proto_goTypes = nil + file_oidb0xD79_proto_depIdxs = nil +} From d7eb0b85f4bcf8f58f08d5d603e9659413e2ebc8 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Tue, 29 Sep 2020 21:49:08 +0800 Subject: [PATCH 2/6] feature sendGroupGift MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 赠送礼物,productID还没整出来 --- client/builders.go | 25 +++ client/client.go | 4 + client/pb/oidb/oidb0xdad.pb.go | 294 +++++++++++++++++++++++++++++++++ client/pb/oidb/oidb0xdad.proto | 20 +++ 4 files changed, 343 insertions(+) create mode 100644 client/pb/oidb/oidb0xdad.pb.go create mode 100644 client/pb/oidb/oidb0xdad.proto diff --git a/client/builders.go b/client/builders.go index bd9ddb18..2329c9be 100644 --- a/client/builders.go +++ b/client/builders.go @@ -1258,3 +1258,28 @@ func (c *QQClient) buildWordSegmentationPacket(data []byte) (uint16, []byte) { packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xd79", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload) return seq, packet } + +// OidbSvc.0xdad_1 +func (c *QQClient) sendGroupGiftPacket(groupCode, uin, productId uint64) (uint16, []byte) { + seq := c.nextSeq() + body := &oidb.DADReqBody{ + Client: 1, + ProductId: productId, + ToUin: uin, + Gc: groupCode, + Version: "V 8.4.5.4745", + Sig: &oidb.DADLoginSig{ + Type: 1, + Sig: c.sigInfo.sKey, + }, + } + b, _ := proto.Marshal(body) + req := &oidb.OIDBSSOPkg{ + Command: 3501, + ServiceType: 1, + Bodybuffer: b, + } + payload, _ := proto.Marshal(req) + packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xdad_1", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload) + return seq, packet +} diff --git a/client/client.go b/client/client.go index 13d41a25..7fa352dc 100644 --- a/client/client.go +++ b/client/client.go @@ -954,6 +954,10 @@ func (c *QQClient) SetCustomServer(servers []*net.TCPAddr) { c.servers = append(servers, c.servers...) } +func (c *QQClient) SendGroupGift(groupCode, uin, productId uint64) { + _, _ = c.sendAndWait(c.sendGroupGiftPacket(groupCode, uin, productId)) +} + func (c *QQClient) registerClient() { _, packet := c.buildClientRegisterPacket() _ = c.send(packet) diff --git a/client/pb/oidb/oidb0xdad.pb.go b/client/pb/oidb/oidb0xdad.pb.go new file mode 100644 index 00000000..6323f1d6 --- /dev/null +++ b/client/pb/oidb/oidb0xdad.pb.go @@ -0,0 +1,294 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.13.0 +// source: oidb0xdad.proto + +package oidb + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type DADReqBody struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Client int64 `protobuf:"varint,1,opt,name=client,proto3" json:"client,omitempty"` + ProductId uint64 `protobuf:"varint,2,opt,name=product_id,json=productId,proto3" json:"product_id,omitempty"` + Amount int64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` + ToUin uint64 `protobuf:"varint,4,opt,name=to_uin,json=toUin,proto3" json:"to_uin,omitempty"` + Gc uint64 `protobuf:"varint,5,opt,name=gc,proto3" json:"gc,omitempty"` + Ip string `protobuf:"bytes,6,opt,name=ip,proto3" json:"ip,omitempty"` + Version string `protobuf:"bytes,7,opt,name=version,proto3" json:"version,omitempty"` + Sig *DADLoginSig `protobuf:"bytes,8,opt,name=sig,proto3" json:"sig,omitempty"` +} + +func (x *DADReqBody) Reset() { + *x = DADReqBody{} + if protoimpl.UnsafeEnabled { + mi := &file_oidb0xdad_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DADReqBody) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DADReqBody) ProtoMessage() {} + +func (x *DADReqBody) ProtoReflect() protoreflect.Message { + mi := &file_oidb0xdad_proto_msgTypes[0] + 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 DADReqBody.ProtoReflect.Descriptor instead. +func (*DADReqBody) Descriptor() ([]byte, []int) { + return file_oidb0xdad_proto_rawDescGZIP(), []int{0} +} + +func (x *DADReqBody) GetClient() int64 { + if x != nil { + return x.Client + } + return 0 +} + +func (x *DADReqBody) GetProductId() uint64 { + if x != nil { + return x.ProductId + } + return 0 +} + +func (x *DADReqBody) GetAmount() int64 { + if x != nil { + return x.Amount + } + return 0 +} + +func (x *DADReqBody) GetToUin() uint64 { + if x != nil { + return x.ToUin + } + return 0 +} + +func (x *DADReqBody) GetGc() uint64 { + if x != nil { + return x.Gc + } + return 0 +} + +func (x *DADReqBody) GetIp() string { + if x != nil { + return x.Ip + } + return "" +} + +func (x *DADReqBody) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *DADReqBody) GetSig() *DADLoginSig { + if x != nil { + return x.Sig + } + return nil +} + +type DADLoginSig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type uint32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` + Sig []byte `protobuf:"bytes,2,opt,name=sig,proto3" json:"sig,omitempty"` + Appid uint32 `protobuf:"varint,3,opt,name=appid,proto3" json:"appid,omitempty"` +} + +func (x *DADLoginSig) Reset() { + *x = DADLoginSig{} + if protoimpl.UnsafeEnabled { + mi := &file_oidb0xdad_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DADLoginSig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DADLoginSig) ProtoMessage() {} + +func (x *DADLoginSig) ProtoReflect() protoreflect.Message { + mi := &file_oidb0xdad_proto_msgTypes[1] + 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 DADLoginSig.ProtoReflect.Descriptor instead. +func (*DADLoginSig) Descriptor() ([]byte, []int) { + return file_oidb0xdad_proto_rawDescGZIP(), []int{1} +} + +func (x *DADLoginSig) GetType() uint32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *DADLoginSig) GetSig() []byte { + if x != nil { + return x.Sig + } + return nil +} + +func (x *DADLoginSig) GetAppid() uint32 { + if x != nil { + return x.Appid + } + return 0 +} + +var File_oidb0xdad_proto protoreflect.FileDescriptor + +var file_oidb0xdad_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x6f, 0x69, 0x64, 0x62, 0x30, 0x78, 0x64, 0x61, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xcc, 0x01, 0x0a, 0x0a, 0x44, 0x41, 0x44, 0x52, 0x65, 0x71, 0x42, 0x6f, 0x64, 0x79, + 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x06, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x64, + 0x75, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x70, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x15, 0x0a, 0x06, 0x74, 0x6f, 0x5f, 0x75, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x05, 0x74, 0x6f, 0x55, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x63, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x02, 0x67, 0x63, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x1e, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, + 0x44, 0x41, 0x44, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x53, 0x69, 0x67, 0x52, 0x03, 0x73, 0x69, 0x67, + 0x22, 0x49, 0x0a, 0x0b, 0x44, 0x41, 0x44, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x53, 0x69, 0x67, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x03, 0x73, 0x69, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x42, 0x08, 0x5a, 0x06, 0x2e, + 0x3b, 0x6f, 0x69, 0x64, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_oidb0xdad_proto_rawDescOnce sync.Once + file_oidb0xdad_proto_rawDescData = file_oidb0xdad_proto_rawDesc +) + +func file_oidb0xdad_proto_rawDescGZIP() []byte { + file_oidb0xdad_proto_rawDescOnce.Do(func() { + file_oidb0xdad_proto_rawDescData = protoimpl.X.CompressGZIP(file_oidb0xdad_proto_rawDescData) + }) + return file_oidb0xdad_proto_rawDescData +} + +var file_oidb0xdad_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_oidb0xdad_proto_goTypes = []interface{}{ + (*DADReqBody)(nil), // 0: DADReqBody + (*DADLoginSig)(nil), // 1: DADLoginSig +} +var file_oidb0xdad_proto_depIdxs = []int32{ + 1, // 0: DADReqBody.sig:type_name -> DADLoginSig + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_oidb0xdad_proto_init() } +func file_oidb0xdad_proto_init() { + if File_oidb0xdad_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_oidb0xdad_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DADReqBody); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_oidb0xdad_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DADLoginSig); 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{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_oidb0xdad_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_oidb0xdad_proto_goTypes, + DependencyIndexes: file_oidb0xdad_proto_depIdxs, + MessageInfos: file_oidb0xdad_proto_msgTypes, + }.Build() + File_oidb0xdad_proto = out.File + file_oidb0xdad_proto_rawDesc = nil + file_oidb0xdad_proto_goTypes = nil + file_oidb0xdad_proto_depIdxs = nil +} diff --git a/client/pb/oidb/oidb0xdad.proto b/client/pb/oidb/oidb0xdad.proto new file mode 100644 index 00000000..4fb64cba --- /dev/null +++ b/client/pb/oidb/oidb0xdad.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +option go_package = ".;oidb"; + +message DADReqBody { + int64 client = 1; + uint64 product_id = 2; + int64 amount = 3; + uint64 to_uin = 4; + uint64 gc = 5; + string ip = 6; + string version = 7; + DADLoginSig sig = 8; +} + +message DADLoginSig { + uint32 type = 1; + bytes sig = 2; + uint32 appid = 3; +} \ No newline at end of file From e56dc8f3f69bee3248f6badb0480cfd2043eaca8 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Wed, 30 Sep 2020 13:38:41 +0800 Subject: [PATCH 3/6] fix groupGiftID enum --- client/builders.go | 4 ++-- client/client.go | 5 +++-- client/entities.go | 12 ++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/client/builders.go b/client/builders.go index 2329c9be..a9389cec 100644 --- a/client/builders.go +++ b/client/builders.go @@ -1260,11 +1260,11 @@ func (c *QQClient) buildWordSegmentationPacket(data []byte) (uint16, []byte) { } // OidbSvc.0xdad_1 -func (c *QQClient) sendGroupGiftPacket(groupCode, uin, productId uint64) (uint16, []byte) { +func (c *QQClient) sendGroupGiftPacket(groupCode, uin uint64, productId GroupGift) (uint16, []byte) { seq := c.nextSeq() body := &oidb.DADReqBody{ Client: 1, - ProductId: productId, + ProductId: uint64(productId), ToUin: uin, Gc: groupCode, Version: "V 8.4.5.4745", diff --git a/client/client.go b/client/client.go index 7fa352dc..acfb0cde 100644 --- a/client/client.go +++ b/client/client.go @@ -954,8 +954,9 @@ func (c *QQClient) SetCustomServer(servers []*net.TCPAddr) { c.servers = append(servers, c.servers...) } -func (c *QQClient) SendGroupGift(groupCode, uin, productId uint64) { - _, _ = c.sendAndWait(c.sendGroupGiftPacket(groupCode, uin, productId)) +func (c *QQClient) SendGroupGift(groupCode, uin uint64, gift GroupGift) { + _, packet := c.sendGroupGiftPacket(groupCode, uin, gift) + _ = c.send(packet) } func (c *QQClient) registerClient() { diff --git a/client/entities.go b/client/entities.go index ddbad763..ee299894 100644 --- a/client/entities.go +++ b/client/entities.go @@ -19,6 +19,8 @@ type ( ClientProtocol int + GroupGift int + LoginResponse struct { Success bool Error LoginError @@ -251,6 +253,16 @@ const ( AndroidPhone ClientProtocol = 537062845 AndroidPad ClientProtocol = 537062409 AndroidWatch ClientProtocol = 537061176 + + SweetWink GroupGift = 285 + HappyCola GroupGift = 289 + LuckyBracelet GroupGift = 290 + Cappuccino GroupGift = 299 + CatWatch GroupGift = 302 + FleeceGloves GroupGift = 302 + RainbowCandy GroupGift = 308 + Stronger GroupGift = 313 + LoveMicrophone GroupGift = 367 ) func (g *GroupInfo) UpdateName(newName string) { From c4b2436f964f665a0dc468adab60e0394995737c Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Wed, 30 Sep 2020 13:52:40 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/builders.go | 2 +- client/client.go | 2 +- client/entities.go | 11 ----------- message/message.go | 12 ++++++++++++ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/client/builders.go b/client/builders.go index a9389cec..b7bd6a74 100644 --- a/client/builders.go +++ b/client/builders.go @@ -1260,7 +1260,7 @@ func (c *QQClient) buildWordSegmentationPacket(data []byte) (uint16, []byte) { } // OidbSvc.0xdad_1 -func (c *QQClient) sendGroupGiftPacket(groupCode, uin uint64, productId GroupGift) (uint16, []byte) { +func (c *QQClient) sendGroupGiftPacket(groupCode, uin uint64, productId message.GroupGift) (uint16, []byte) { seq := c.nextSeq() body := &oidb.DADReqBody{ Client: 1, diff --git a/client/client.go b/client/client.go index acfb0cde..cd52577e 100644 --- a/client/client.go +++ b/client/client.go @@ -954,7 +954,7 @@ func (c *QQClient) SetCustomServer(servers []*net.TCPAddr) { c.servers = append(servers, c.servers...) } -func (c *QQClient) SendGroupGift(groupCode, uin uint64, gift GroupGift) { +func (c *QQClient) SendGroupGift(groupCode, uin uint64, gift message.GroupGift) { _, packet := c.sendGroupGiftPacket(groupCode, uin, gift) _ = c.send(packet) } diff --git a/client/entities.go b/client/entities.go index ee299894..2be8d755 100644 --- a/client/entities.go +++ b/client/entities.go @@ -19,8 +19,6 @@ type ( ClientProtocol int - GroupGift int - LoginResponse struct { Success bool Error LoginError @@ -254,15 +252,6 @@ const ( AndroidPad ClientProtocol = 537062409 AndroidWatch ClientProtocol = 537061176 - SweetWink GroupGift = 285 - HappyCola GroupGift = 289 - LuckyBracelet GroupGift = 290 - Cappuccino GroupGift = 299 - CatWatch GroupGift = 302 - FleeceGloves GroupGift = 302 - RainbowCandy GroupGift = 308 - Stronger GroupGift = 313 - LoveMicrophone GroupGift = 367 ) func (g *GroupInfo) UpdateName(newName string) { diff --git a/message/message.go b/message/message.go index a4eb863d..73f6989b 100644 --- a/message/message.go +++ b/message/message.go @@ -70,6 +70,8 @@ type ( } ElementType int + + GroupGift int ) const ( @@ -85,6 +87,16 @@ const ( Video LightApp RedBag + + SweetWink GroupGift = 285 + HappyCola GroupGift = 289 + LuckyBracelet GroupGift = 290 + Cappuccino GroupGift = 299 + CatWatch GroupGift = 302 + FleeceGloves GroupGift = 302 + RainbowCandy GroupGift = 308 + Stronger GroupGift = 313 + LoveMicrophone GroupGift = 367 ) func (s *Sender) IsAnonymous() bool { From 560b68a212269b040e757cb8643a6c8e7732223e Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Wed, 30 Sep 2020 19:14:51 +0800 Subject: [PATCH 5/6] fix tts --- client/tts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/tts.go b/client/tts.go index dc466520..9d3a217b 100644 --- a/client/tts.go +++ b/client/tts.go @@ -10,7 +10,7 @@ import ( func (c *QQClient) GetTts(text string) ([]byte, error) { url := "https://textts.qq.com/cgi-bin/tts" - data := "{\"appid\": \"201908021016\",\"text\": \"" + text + "\"}" + data := fmt.Sprintf("{\"appid\": \"201908021016\",\"sendUin\": %v,\"text\": \"%v\"}", c.Uin, text) rsp, err := utils.HttpPostBytesWithCookie(url, []byte(data), c.getCookies()) if err != nil { return nil, err From b73e07b0853f9b65e669ea5e78c96fedd370496b Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Wed, 30 Sep 2020 22:07:05 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=86=A8=E6=89=B9=EF=BC=8C=E6=89=93?= =?UTF-8?q?=E9=94=99=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- message/message.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/message/message.go b/message/message.go index 73f6989b..f1856b8d 100644 --- a/message/message.go +++ b/message/message.go @@ -93,7 +93,7 @@ const ( LuckyBracelet GroupGift = 290 Cappuccino GroupGift = 299 CatWatch GroupGift = 302 - FleeceGloves GroupGift = 302 + FleeceGloves GroupGift = 307 RainbowCandy GroupGift = 308 Stronger GroupGift = 313 LoveMicrophone GroupGift = 367