From 0fa5228d26e5f949d60135941f199e130c88900a Mon Sep 17 00:00:00 2001 From: Mrs4s <1844812067@qq.com> Date: Thu, 13 Aug 2020 16:54:30 +0800 Subject: [PATCH] supported short video message. --- README.md | 4 +- client/builders.go | 25 + client/client.go | 9 + client/decoders.go | 12 + client/pb/pttcenter/shortvideo.pb.go | 737 +++++++++++++++++++++++++++ client/pb/pttcenter/shortvideo.proto | 54 ++ message/elements.go | 10 + message/message.go | 11 +- 8 files changed, 859 insertions(+), 3 deletions(-) create mode 100644 client/pb/pttcenter/shortvideo.pb.go create mode 100644 client/pb/pttcenter/shortvideo.proto diff --git a/README.md b/README.md index 4f133ee5..b42ebd59 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ qq-android协议的golang实现 移植于mirai - [x] 长消息 - [x] 链接分享 - [x] 小程序(暂只支持RAW) -- [ ] 位置 +- [x] 短视频(仅接收信息) - [x] 合并转发 -- [x] 群文件(仅接受消息) +- [x] 群文件(仅接收信息) #### 事件 - [x] 好友消息 diff --git a/client/builders.go b/client/builders.go index 6dcdbb7d..b1a46b9b 100644 --- a/client/builders.go +++ b/client/builders.go @@ -10,6 +10,7 @@ import ( "github.com/Mrs4s/MiraiGo/client/pb/msg" "github.com/Mrs4s/MiraiGo/client/pb/multimsg" "github.com/Mrs4s/MiraiGo/client/pb/oidb" + "github.com/Mrs4s/MiraiGo/client/pb/pttcenter" "github.com/Mrs4s/MiraiGo/client/pb/structmsg" "github.com/Mrs4s/MiraiGo/message" "github.com/Mrs4s/MiraiGo/protocol/crypto" @@ -994,3 +995,27 @@ func (c *QQClient) buildGroupFileDownloadReqPacket(groupCode int64, fileId strin packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d6_2", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload) return seq, packet } + +func (c *QQClient) buildPttShortVideoDownReqPacket(uuid, md5 []byte) (uint16, []byte) { + seq := c.nextSeq() + body := &pttcenter.ShortVideoReqBody{ + Cmd: 400, + Seq: int32(seq), + PttShortVideoDownloadReq: &pttcenter.ShortVideoDownloadReq{ + FromUin: c.Uin, + ToUin: c.Uin, + ChatType: 1, + ClientType: 7, + FileId: string(uuid), + GroupCode: 1, + FileMd5: md5, + BusinessType: 1, + FileType: 2, + DownType: 2, + SceneType: 2, + }, + } + payload, _ := proto.Marshal(body) + packet := packets.BuildUniPacket(c.Uin, seq, "PttCenterSvr.ShortVideoDownReq", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload) + return seq, packet +} diff --git a/client/client.go b/client/client.go index e58c65bb..55bccf6a 100644 --- a/client/client.go +++ b/client/client.go @@ -124,6 +124,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient { "MultiMsg.ApplyUp": decodeMultiApplyUpResponse, "MultiMsg.ApplyDown": decodeMultiApplyDownResponse, "OidbSvc.0x6d6_2": decodeOIDB6d6Response, + "PttCenterSvr.ShortVideoDownReq": decodePttShortVideoDownResponse, }, sigInfo: &loginSigInfo{}, requestPacketRequestId: 1921334513, @@ -209,6 +210,14 @@ func (c *QQClient) GetFriendList() (*FriendListResponse, error) { return r, nil } +func (c *QQClient) GetShortVideoUrl(uuid, md5 []byte) string { + i, err := c.sendAndWait(c.buildPttShortVideoDownReqPacket(uuid, md5)) + if err != nil { + return "" + } + return i.(string) +} + func (c *QQClient) GetGroupFileUrl(groupCode int64, fileId string, busId int32) string { i, err := c.sendAndWait(c.buildGroupFileDownloadReqPacket(groupCode, fileId, busId)) if err != nil { diff --git a/client/decoders.go b/client/decoders.go index e1deda66..1128d39e 100644 --- a/client/decoders.go +++ b/client/decoders.go @@ -4,6 +4,7 @@ import ( "encoding/hex" "errors" "fmt" + "github.com/Mrs4s/MiraiGo/client/pb/pttcenter" "log" "strconv" "sync" @@ -816,3 +817,14 @@ func decodeOIDB6d6Response(c *QQClient, _ uint16, payload []byte) (interface{}, url := hex.EncodeToString(rsp.DownloadFileRsp.DownloadUrl) return fmt.Sprintf("http://%s/ftn_handler/%s/", ip, url), nil } + +func decodePttShortVideoDownResponse(c *QQClient, _ uint16, payload []byte) (interface{}, error) { + rsp := pttcenter.ShortVideoRspBody{} + if err := proto.Unmarshal(payload, &rsp); err != nil { + return nil, err + } + if rsp.PttShortVideoDownloadRsp == nil || rsp.PttShortVideoDownloadRsp.DownloadAddr == nil { + return nil, errors.New("resp error") + } + return rsp.PttShortVideoDownloadRsp.DownloadAddr.Host[0] + rsp.PttShortVideoDownloadRsp.DownloadAddr.UrlArgs, nil +} diff --git a/client/pb/pttcenter/shortvideo.pb.go b/client/pb/pttcenter/shortvideo.pb.go new file mode 100644 index 00000000..911eb516 --- /dev/null +++ b/client/pb/pttcenter/shortvideo.pb.go @@ -0,0 +1,737 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.11.4 +// source: shortvideo.proto + +package pttcenter + +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 ShortVideoReqBody struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Cmd int32 `protobuf:"varint,1,opt,name=cmd,proto3" json:"cmd,omitempty"` + Seq int32 `protobuf:"varint,2,opt,name=seq,proto3" json:"seq,omitempty"` + PttShortVideoDownloadReq *ShortVideoDownloadReq `protobuf:"bytes,4,opt,name=pttShortVideoDownloadReq,proto3" json:"pttShortVideoDownloadReq,omitempty"` +} + +func (x *ShortVideoReqBody) Reset() { + *x = ShortVideoReqBody{} + if protoimpl.UnsafeEnabled { + mi := &file_shortvideo_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ShortVideoReqBody) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ShortVideoReqBody) ProtoMessage() {} + +func (x *ShortVideoReqBody) ProtoReflect() protoreflect.Message { + mi := &file_shortvideo_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 ShortVideoReqBody.ProtoReflect.Descriptor instead. +func (*ShortVideoReqBody) Descriptor() ([]byte, []int) { + return file_shortvideo_proto_rawDescGZIP(), []int{0} +} + +func (x *ShortVideoReqBody) GetCmd() int32 { + if x != nil { + return x.Cmd + } + return 0 +} + +func (x *ShortVideoReqBody) GetSeq() int32 { + if x != nil { + return x.Seq + } + return 0 +} + +func (x *ShortVideoReqBody) GetPttShortVideoDownloadReq() *ShortVideoDownloadReq { + if x != nil { + return x.PttShortVideoDownloadReq + } + return nil +} + +type ShortVideoRspBody struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Cmd int32 `protobuf:"varint,1,opt,name=cmd,proto3" json:"cmd,omitempty"` + Seq int32 `protobuf:"varint,2,opt,name=seq,proto3" json:"seq,omitempty"` + PttShortVideoDownloadRsp *ShortVideoDownloadRsp `protobuf:"bytes,4,opt,name=pttShortVideoDownloadRsp,proto3" json:"pttShortVideoDownloadRsp,omitempty"` +} + +func (x *ShortVideoRspBody) Reset() { + *x = ShortVideoRspBody{} + if protoimpl.UnsafeEnabled { + mi := &file_shortvideo_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ShortVideoRspBody) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ShortVideoRspBody) ProtoMessage() {} + +func (x *ShortVideoRspBody) ProtoReflect() protoreflect.Message { + mi := &file_shortvideo_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 ShortVideoRspBody.ProtoReflect.Descriptor instead. +func (*ShortVideoRspBody) Descriptor() ([]byte, []int) { + return file_shortvideo_proto_rawDescGZIP(), []int{1} +} + +func (x *ShortVideoRspBody) GetCmd() int32 { + if x != nil { + return x.Cmd + } + return 0 +} + +func (x *ShortVideoRspBody) GetSeq() int32 { + if x != nil { + return x.Seq + } + return 0 +} + +func (x *ShortVideoRspBody) GetPttShortVideoDownloadRsp() *ShortVideoDownloadRsp { + if x != nil { + return x.PttShortVideoDownloadRsp + } + return nil +} + +type ShortVideoDownloadReq 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"` + ChatType int32 `protobuf:"varint,3,opt,name=chatType,proto3" json:"chatType,omitempty"` + ClientType int32 `protobuf:"varint,4,opt,name=clientType,proto3" json:"clientType,omitempty"` + FileId string `protobuf:"bytes,5,opt,name=fileId,proto3" json:"fileId,omitempty"` + GroupCode int64 `protobuf:"varint,6,opt,name=groupCode,proto3" json:"groupCode,omitempty"` + AgentType int32 `protobuf:"varint,7,opt,name=agentType,proto3" json:"agentType,omitempty"` + FileMd5 []byte `protobuf:"bytes,8,opt,name=fileMd5,proto3" json:"fileMd5,omitempty"` + BusinessType int32 `protobuf:"varint,9,opt,name=businessType,proto3" json:"businessType,omitempty"` + FileType int32 `protobuf:"varint,10,opt,name=fileType,proto3" json:"fileType,omitempty"` + DownType int32 `protobuf:"varint,11,opt,name=downType,proto3" json:"downType,omitempty"` + SceneType int32 `protobuf:"varint,12,opt,name=sceneType,proto3" json:"sceneType,omitempty"` +} + +func (x *ShortVideoDownloadReq) Reset() { + *x = ShortVideoDownloadReq{} + if protoimpl.UnsafeEnabled { + mi := &file_shortvideo_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ShortVideoDownloadReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ShortVideoDownloadReq) ProtoMessage() {} + +func (x *ShortVideoDownloadReq) ProtoReflect() protoreflect.Message { + mi := &file_shortvideo_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 ShortVideoDownloadReq.ProtoReflect.Descriptor instead. +func (*ShortVideoDownloadReq) Descriptor() ([]byte, []int) { + return file_shortvideo_proto_rawDescGZIP(), []int{2} +} + +func (x *ShortVideoDownloadReq) GetFromUin() int64 { + if x != nil { + return x.FromUin + } + return 0 +} + +func (x *ShortVideoDownloadReq) GetToUin() int64 { + if x != nil { + return x.ToUin + } + return 0 +} + +func (x *ShortVideoDownloadReq) GetChatType() int32 { + if x != nil { + return x.ChatType + } + return 0 +} + +func (x *ShortVideoDownloadReq) GetClientType() int32 { + if x != nil { + return x.ClientType + } + return 0 +} + +func (x *ShortVideoDownloadReq) GetFileId() string { + if x != nil { + return x.FileId + } + return "" +} + +func (x *ShortVideoDownloadReq) GetGroupCode() int64 { + if x != nil { + return x.GroupCode + } + return 0 +} + +func (x *ShortVideoDownloadReq) GetAgentType() int32 { + if x != nil { + return x.AgentType + } + return 0 +} + +func (x *ShortVideoDownloadReq) GetFileMd5() []byte { + if x != nil { + return x.FileMd5 + } + return nil +} + +func (x *ShortVideoDownloadReq) GetBusinessType() int32 { + if x != nil { + return x.BusinessType + } + return 0 +} + +func (x *ShortVideoDownloadReq) GetFileType() int32 { + if x != nil { + return x.FileType + } + return 0 +} + +func (x *ShortVideoDownloadReq) GetDownType() int32 { + if x != nil { + return x.DownType + } + return 0 +} + +func (x *ShortVideoDownloadReq) GetSceneType() int32 { + if x != nil { + return x.SceneType + } + return 0 +} + +type ShortVideoDownloadRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RetCode int32 `protobuf:"varint,1,opt,name=retCode,proto3" json:"retCode,omitempty"` + RetMsg string `protobuf:"bytes,2,opt,name=retMsg,proto3" json:"retMsg,omitempty"` + SameAreaOutAddr []*ShortVideoIpList `protobuf:"bytes,3,rep,name=sameAreaOutAddr,proto3" json:"sameAreaOutAddr,omitempty"` + DiffAreaOutAddr []*ShortVideoIpList `protobuf:"bytes,4,rep,name=diffAreaOutAddr,proto3" json:"diffAreaOutAddr,omitempty"` + DownloadKey []byte `protobuf:"bytes,5,opt,name=downloadKey,proto3" json:"downloadKey,omitempty"` + FileMd5 []byte `protobuf:"bytes,6,opt,name=fileMd5,proto3" json:"fileMd5,omitempty"` + SameAreaInnerAddr []*ShortVideoIpList `protobuf:"bytes,7,rep,name=sameAreaInnerAddr,proto3" json:"sameAreaInnerAddr,omitempty"` + DiffAreaInnerAddr []*ShortVideoIpList `protobuf:"bytes,8,rep,name=diffAreaInnerAddr,proto3" json:"diffAreaInnerAddr,omitempty"` + DownloadAddr *ShortVideoAddr `protobuf:"bytes,9,opt,name=downloadAddr,proto3" json:"downloadAddr,omitempty"` + EncryptKey []byte `protobuf:"bytes,10,opt,name=encryptKey,proto3" json:"encryptKey,omitempty"` +} + +func (x *ShortVideoDownloadRsp) Reset() { + *x = ShortVideoDownloadRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_shortvideo_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ShortVideoDownloadRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ShortVideoDownloadRsp) ProtoMessage() {} + +func (x *ShortVideoDownloadRsp) ProtoReflect() protoreflect.Message { + mi := &file_shortvideo_proto_msgTypes[3] + 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 ShortVideoDownloadRsp.ProtoReflect.Descriptor instead. +func (*ShortVideoDownloadRsp) Descriptor() ([]byte, []int) { + return file_shortvideo_proto_rawDescGZIP(), []int{3} +} + +func (x *ShortVideoDownloadRsp) GetRetCode() int32 { + if x != nil { + return x.RetCode + } + return 0 +} + +func (x *ShortVideoDownloadRsp) GetRetMsg() string { + if x != nil { + return x.RetMsg + } + return "" +} + +func (x *ShortVideoDownloadRsp) GetSameAreaOutAddr() []*ShortVideoIpList { + if x != nil { + return x.SameAreaOutAddr + } + return nil +} + +func (x *ShortVideoDownloadRsp) GetDiffAreaOutAddr() []*ShortVideoIpList { + if x != nil { + return x.DiffAreaOutAddr + } + return nil +} + +func (x *ShortVideoDownloadRsp) GetDownloadKey() []byte { + if x != nil { + return x.DownloadKey + } + return nil +} + +func (x *ShortVideoDownloadRsp) GetFileMd5() []byte { + if x != nil { + return x.FileMd5 + } + return nil +} + +func (x *ShortVideoDownloadRsp) GetSameAreaInnerAddr() []*ShortVideoIpList { + if x != nil { + return x.SameAreaInnerAddr + } + return nil +} + +func (x *ShortVideoDownloadRsp) GetDiffAreaInnerAddr() []*ShortVideoIpList { + if x != nil { + return x.DiffAreaInnerAddr + } + return nil +} + +func (x *ShortVideoDownloadRsp) GetDownloadAddr() *ShortVideoAddr { + if x != nil { + return x.DownloadAddr + } + return nil +} + +func (x *ShortVideoDownloadRsp) GetEncryptKey() []byte { + if x != nil { + return x.EncryptKey + } + return nil +} + +type ShortVideoIpList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ip int32 `protobuf:"varint,1,opt,name=ip,proto3" json:"ip,omitempty"` + Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` +} + +func (x *ShortVideoIpList) Reset() { + *x = ShortVideoIpList{} + if protoimpl.UnsafeEnabled { + mi := &file_shortvideo_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ShortVideoIpList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ShortVideoIpList) ProtoMessage() {} + +func (x *ShortVideoIpList) ProtoReflect() protoreflect.Message { + mi := &file_shortvideo_proto_msgTypes[4] + 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 ShortVideoIpList.ProtoReflect.Descriptor instead. +func (*ShortVideoIpList) Descriptor() ([]byte, []int) { + return file_shortvideo_proto_rawDescGZIP(), []int{4} +} + +func (x *ShortVideoIpList) GetIp() int32 { + if x != nil { + return x.Ip + } + return 0 +} + +func (x *ShortVideoIpList) GetPort() int32 { + if x != nil { + return x.Port + } + return 0 +} + +type ShortVideoAddr struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Host []string `protobuf:"bytes,10,rep,name=host,proto3" json:"host,omitempty"` + UrlArgs string `protobuf:"bytes,11,opt,name=urlArgs,proto3" json:"urlArgs,omitempty"` //repeated string domain = 13; +} + +func (x *ShortVideoAddr) Reset() { + *x = ShortVideoAddr{} + if protoimpl.UnsafeEnabled { + mi := &file_shortvideo_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ShortVideoAddr) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ShortVideoAddr) ProtoMessage() {} + +func (x *ShortVideoAddr) ProtoReflect() protoreflect.Message { + mi := &file_shortvideo_proto_msgTypes[5] + 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 ShortVideoAddr.ProtoReflect.Descriptor instead. +func (*ShortVideoAddr) Descriptor() ([]byte, []int) { + return file_shortvideo_proto_rawDescGZIP(), []int{5} +} + +func (x *ShortVideoAddr) GetHost() []string { + if x != nil { + return x.Host + } + return nil +} + +func (x *ShortVideoAddr) GetUrlArgs() string { + if x != nil { + return x.UrlArgs + } + return "" +} + +var File_shortvideo_proto protoreflect.FileDescriptor + +var file_shortvideo_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x8b, 0x01, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, + 0x6f, 0x52, 0x65, 0x71, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x63, 0x6d, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, + 0x71, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x65, 0x71, 0x12, 0x52, 0x0a, 0x18, + 0x70, 0x74, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x77, + 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x77, 0x6e, 0x6c, + 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x52, 0x18, 0x70, 0x74, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, + 0x56, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, + 0x22, 0x8b, 0x01, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, + 0x73, 0x70, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x03, 0x63, 0x6d, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x71, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x65, 0x71, 0x12, 0x52, 0x0a, 0x18, 0x70, 0x74, + 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x77, 0x6e, 0x6c, + 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x53, + 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, + 0x64, 0x52, 0x73, 0x70, 0x52, 0x18, 0x70, 0x74, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, + 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x22, 0xeb, + 0x02, 0x0a, 0x15, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x77, + 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 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, 0x1a, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x74, + 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x68, 0x61, 0x74, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x65, 0x49, 0x64, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, + 0x67, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x09, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x67, + 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x61, + 0x67, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x69, 0x6c, 0x65, + 0x4d, 0x64, 0x35, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x66, 0x69, 0x6c, 0x65, 0x4d, + 0x64, 0x35, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, + 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x64, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, + 0x0a, 0x09, 0x73, 0x63, 0x65, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x09, 0x73, 0x63, 0x65, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0xd6, 0x03, 0x0a, + 0x15, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x77, 0x6e, 0x6c, + 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x74, 0x43, 0x6f, 0x64, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x72, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x74, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x72, 0x65, 0x74, 0x4d, 0x73, 0x67, 0x12, 0x3b, 0x0a, 0x0f, 0x73, 0x61, 0x6d, 0x65, + 0x41, 0x72, 0x65, 0x61, 0x4f, 0x75, 0x74, 0x41, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x11, 0x2e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x70, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x0f, 0x73, 0x61, 0x6d, 0x65, 0x41, 0x72, 0x65, 0x61, 0x4f, 0x75, + 0x74, 0x41, 0x64, 0x64, 0x72, 0x12, 0x3b, 0x0a, 0x0f, 0x64, 0x69, 0x66, 0x66, 0x41, 0x72, 0x65, + 0x61, 0x4f, 0x75, 0x74, 0x41, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, + 0x2e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x70, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x0f, 0x64, 0x69, 0x66, 0x66, 0x41, 0x72, 0x65, 0x61, 0x4f, 0x75, 0x74, 0x41, 0x64, + 0x64, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x4b, 0x65, + 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, + 0x64, 0x4b, 0x65, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x69, 0x6c, 0x65, 0x4d, 0x64, 0x35, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x66, 0x69, 0x6c, 0x65, 0x4d, 0x64, 0x35, 0x12, 0x3f, + 0x0a, 0x11, 0x73, 0x61, 0x6d, 0x65, 0x41, 0x72, 0x65, 0x61, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x41, + 0x64, 0x64, 0x72, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x53, 0x68, 0x6f, 0x72, + 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x11, 0x73, 0x61, + 0x6d, 0x65, 0x41, 0x72, 0x65, 0x61, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, + 0x3f, 0x0a, 0x11, 0x64, 0x69, 0x66, 0x66, 0x41, 0x72, 0x65, 0x61, 0x49, 0x6e, 0x6e, 0x65, 0x72, + 0x41, 0x64, 0x64, 0x72, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x53, 0x68, 0x6f, + 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x11, 0x64, + 0x69, 0x66, 0x66, 0x41, 0x72, 0x65, 0x61, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, + 0x12, 0x33, 0x0a, 0x0c, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x64, 0x64, 0x72, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, + 0x64, 0x65, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x52, 0x0c, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, + 0x64, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, + 0x4b, 0x65, 0x79, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x65, 0x6e, 0x63, 0x72, 0x79, + 0x70, 0x74, 0x4b, 0x65, 0x79, 0x22, 0x36, 0x0a, 0x10, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, + 0x64, 0x65, 0x6f, 0x49, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x3e, 0x0a, + 0x0e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x12, + 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x68, + 0x6f, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x72, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x72, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x42, 0x0d, 0x5a, + 0x0b, 0x2e, 0x3b, 0x70, 0x74, 0x74, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_shortvideo_proto_rawDescOnce sync.Once + file_shortvideo_proto_rawDescData = file_shortvideo_proto_rawDesc +) + +func file_shortvideo_proto_rawDescGZIP() []byte { + file_shortvideo_proto_rawDescOnce.Do(func() { + file_shortvideo_proto_rawDescData = protoimpl.X.CompressGZIP(file_shortvideo_proto_rawDescData) + }) + return file_shortvideo_proto_rawDescData +} + +var file_shortvideo_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_shortvideo_proto_goTypes = []interface{}{ + (*ShortVideoReqBody)(nil), // 0: ShortVideoReqBody + (*ShortVideoRspBody)(nil), // 1: ShortVideoRspBody + (*ShortVideoDownloadReq)(nil), // 2: ShortVideoDownloadReq + (*ShortVideoDownloadRsp)(nil), // 3: ShortVideoDownloadRsp + (*ShortVideoIpList)(nil), // 4: ShortVideoIpList + (*ShortVideoAddr)(nil), // 5: ShortVideoAddr +} +var file_shortvideo_proto_depIdxs = []int32{ + 2, // 0: ShortVideoReqBody.pttShortVideoDownloadReq:type_name -> ShortVideoDownloadReq + 3, // 1: ShortVideoRspBody.pttShortVideoDownloadRsp:type_name -> ShortVideoDownloadRsp + 4, // 2: ShortVideoDownloadRsp.sameAreaOutAddr:type_name -> ShortVideoIpList + 4, // 3: ShortVideoDownloadRsp.diffAreaOutAddr:type_name -> ShortVideoIpList + 4, // 4: ShortVideoDownloadRsp.sameAreaInnerAddr:type_name -> ShortVideoIpList + 4, // 5: ShortVideoDownloadRsp.diffAreaInnerAddr:type_name -> ShortVideoIpList + 5, // 6: ShortVideoDownloadRsp.downloadAddr:type_name -> ShortVideoAddr + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_shortvideo_proto_init() } +func file_shortvideo_proto_init() { + if File_shortvideo_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_shortvideo_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShortVideoReqBody); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_shortvideo_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShortVideoRspBody); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_shortvideo_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShortVideoDownloadReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_shortvideo_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShortVideoDownloadRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_shortvideo_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShortVideoIpList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_shortvideo_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShortVideoAddr); 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_shortvideo_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_shortvideo_proto_goTypes, + DependencyIndexes: file_shortvideo_proto_depIdxs, + MessageInfos: file_shortvideo_proto_msgTypes, + }.Build() + File_shortvideo_proto = out.File + file_shortvideo_proto_rawDesc = nil + file_shortvideo_proto_goTypes = nil + file_shortvideo_proto_depIdxs = nil +} diff --git a/client/pb/pttcenter/shortvideo.proto b/client/pb/pttcenter/shortvideo.proto new file mode 100644 index 00000000..34794cb9 --- /dev/null +++ b/client/pb/pttcenter/shortvideo.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +option go_package = ".;pttcenter"; + +message ShortVideoReqBody { + int32 cmd = 1; + int32 seq = 2; + ShortVideoDownloadReq pttShortVideoDownloadReq = 4; +} + +message ShortVideoRspBody { + int32 cmd = 1; + int32 seq = 2; + ShortVideoDownloadRsp pttShortVideoDownloadRsp = 4; +} + +message ShortVideoDownloadReq { + int64 fromUin = 1; + int64 toUin = 2; + int32 chatType = 3; + int32 clientType = 4; + string fileId = 5; + int64 groupCode = 6; + int32 agentType = 7; + bytes fileMd5 = 8; + int32 businessType = 9; + int32 fileType = 10; + int32 downType = 11; + int32 sceneType = 12; +} + +message ShortVideoDownloadRsp { + int32 retCode = 1; + string retMsg = 2; + repeated ShortVideoIpList sameAreaOutAddr = 3; + repeated ShortVideoIpList diffAreaOutAddr = 4; + bytes downloadKey = 5; + bytes fileMd5 = 6; + repeated ShortVideoIpList sameAreaInnerAddr = 7; + repeated ShortVideoIpList diffAreaInnerAddr = 8; + ShortVideoAddr downloadAddr = 9; + bytes encryptKey = 10; +} + +message ShortVideoIpList { + int32 ip = 1; + int32 port = 2; +} + +message ShortVideoAddr { + repeated string host = 10; + string urlArgs = 11; + //repeated string domain = 13; +} \ No newline at end of file diff --git a/message/elements.go b/message/elements.go index a49b7824..086fe43d 100644 --- a/message/elements.go +++ b/message/elements.go @@ -72,6 +72,12 @@ type ReplyElement struct { //original []*msg.Elem } +type ShortVideoElement struct { + Uuid []byte + Size int32 + Md5 []byte +} + type ServiceElement struct { Id int32 Content string @@ -200,6 +206,10 @@ func (e *VoiceElement) Type() ElementType { return Voice } +func (e *ShortVideoElement) Type() ElementType { + return Video +} + var faceMap = map[int]string{ 14: "微笑", 1: "撇嘴", diff --git a/message/message.go b/message/message.go index c832bcb9..28536ffb 100644 --- a/message/message.go +++ b/message/message.go @@ -79,8 +79,9 @@ const ( Reply Service Forward - File // Voice? + File Voice + Video ) func (s *Sender) IsAnonymous() bool { @@ -425,6 +426,14 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement { return append(res, NewText(content)) } } + if elem.VideoFile != nil { + res = append(res, &ShortVideoElement{ + Uuid: elem.VideoFile.FileUuid, + Size: elem.VideoFile.FileSize, + Md5: elem.VideoFile.FileMd5, + }) + continue + } if elem.Text != nil { if len(elem.Text.Attr6Buf) == 0 { res = append(res, NewText(func() string {