From 1780a6414c30739162b1bc11cf60a6822768b581 Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Mon, 17 Feb 2025 01:49:59 +0800 Subject: [PATCH 1/4] code ... --- client/message.go | 36 +++++------ client/packets/message/multi_msg_upload.go | 2 +- message/build.go | 4 +- message/message.go | 74 +++++++++++----------- 4 files changed, 57 insertions(+), 59 deletions(-) diff --git a/client/message.go b/client/message.go index c1d6435..978c38d 100644 --- a/client/message.go +++ b/client/message.go @@ -68,12 +68,12 @@ func (c *QQClient) SendGroupMessage(groupUin uint32, elements []message2.IMessag GroupUin: groupUin, GroupName: group.GroupName, Sender: &message2.Sender{ - Uin: c.Uin, - UID: c.GetUID(c.Uin), - Nickname: c.NickName(), - CardName: minfo.MemberCard, - AnonymousInfo: nil, - IsFriend: true, + Uin: c.Uin, + UID: c.GetUID(c.Uin), + Nickname: c.NickName(), + CardName: minfo.MemberCard, + //AnonymousInfo: nil, + IsFriend: true, }, Time: ret.Timestamp1, Elements: elements, @@ -106,11 +106,11 @@ func (c *QQClient) SendPrivateMessage(uin uint32, elements []message2.IMessageEl Target: uin, Time: ret.Timestamp1, Sender: &message2.Sender{ - Uin: c.Uin, - UID: c.GetUID(c.Uin), - Nickname: c.NickName(), - AnonymousInfo: nil, - IsFriend: true, + Uin: c.Uin, + UID: c.GetUID(c.Uin), + Nickname: c.NickName(), + //AnonymousInfo: nil, + IsFriend: true, }, Elements: elements, } @@ -137,11 +137,11 @@ func (c *QQClient) SendTempMessage(groupUin uint32, uin uint32, elements []messa GroupName: group.GroupName, Self: c.Uin, Sender: &message2.Sender{ - Uin: c.Uin, - UID: c.GetUID(c.Uin), - Nickname: c.NickName(), - AnonymousInfo: nil, - IsFriend: true, + Uin: c.Uin, + UID: c.GetUID(c.Uin), + Nickname: c.NickName(), + //AnonymousInfo: nil, + IsFriend: true, }, Elements: elements, } @@ -159,7 +159,7 @@ func (c *QQClient) BuildFakeMessage(msgElems []*message2.ForwardNode) []*message FromUin: elem.SenderID, }, ContentHead: &message.ContentHead{ - Type: uint32(utils.Ternary(elem.GroupID != 0, 82, 9)), + Type: utils.Ternary[uint32](elem.GroupID != 0, 82, 9), MsgId: proto.Uint32(crypto.RandU32()), Sequence: proto.Uint32(crypto.RandU32()), TimeStamp: proto.Uint32(uint32(utils.TimeStamp())), @@ -169,7 +169,7 @@ func (c *QQClient) BuildFakeMessage(msgElems []*message2.ForwardNode) []*message Foward: &message.ForwardHead{ Field1: proto.Uint32(0), Field2: proto.Uint32(0), - Field3: utils.Ternary(elem.GroupID != 0, proto.Uint32(0), proto.Uint32(2)), + Field3: proto.Uint32(utils.Ternary[uint32](elem.GroupID != 0, 0, 2)), UnknownBase64: proto.String(avatar), Avatar: proto.String(avatar), }, diff --git a/client/packets/message/multi_msg_upload.go b/client/packets/message/multi_msg_upload.go index 12782dc..726ca2b 100644 --- a/client/packets/message/multi_msg_upload.go +++ b/client/packets/message/multi_msg_upload.go @@ -24,7 +24,7 @@ func BuildMultiMsgUploadReq(selfUID string, groupUin uint32, msg []*message.Push Info: &message.SendLongMsgInfo{ Type: utils.Ternary[uint32](groupUin == 0, 1, 3), Uid: &message.LongMsgUid{ - Uid: utils.Ternary(groupUin == 0, proto.String(selfUID), proto.String(strconv.Itoa(int(groupUin)))), + Uid: proto.String(utils.Ternary(groupUin == 0, selfUID, strconv.Itoa(int(groupUin)))), }, GroupUin: proto.Uint32(groupUin), Payload: payload, diff --git a/message/build.go b/message/build.go index d1b43c5..04202f9 100644 --- a/message/build.go +++ b/message/build.go @@ -21,7 +21,7 @@ func (e *TextElement) BuildElement() []*message.Elem { func (e *AtElement) BuildElement() []*message.Elem { reserveData, _ := proto.Marshal(&message.MentionExtra{ - Type: proto.Some(int32(utils.Ternary(e.TargetUin == 0, 1, 2))), // atAll + Type: proto.Some(utils.Ternary[int32](e.TargetUin == 0, 1, 2)), // atAll Uin: proto.Some(uint32(0)), Field5: proto.Some(int32(0)), Uid: proto.Some(e.TargetUID), @@ -75,7 +75,7 @@ func (e *ImageElement) BuildElement() []*message.Elem { CommonElem: &message.CommonElem{ ServiceType: 48, PbElem: common, - BusinessType: utils.Ternary(e.IsGroup, uint32(20), uint32(10)), + BusinessType: utils.Ternary[uint32](e.IsGroup, 20, 10), }, }} if e.CompatFace != nil { diff --git a/message/message.go b/message/message.go index f6f5728..68b8cf4 100644 --- a/message/message.go +++ b/message/message.go @@ -77,19 +77,19 @@ type ( } Sender struct { - Uin uint32 - UID string - Nickname string - CardName string - AnonymousInfo *AnonymousInfo - IsFriend bool + Uin uint32 + UID string + Nickname string + CardName string + //AnonymousInfo *AnonymousInfo + IsFriend bool } - - AnonymousInfo struct { - AnonymousID string - AnonymousNick string - } - + /* + AnonymousInfo struct { + AnonymousID string + AnonymousNick string + } + */ IMessageElement interface { Type() ElementType } @@ -97,9 +97,11 @@ type ( ElementType int ) +/* func (s *Sender) IsAnonymous() bool { return s.Uin == 80000000 } +*/ func ParsePrivateMessage(msg *message.PushMsgBody) *PrivateMessage { prvMsg := &PrivateMessage{ @@ -161,14 +163,13 @@ func ParseMessageElements(msg []*message.Elem) []IMessageElement { continue } if elem.SrcMsg != nil && len(elem.SrcMsg.OrigSeqs) != 0 { - r := &ReplyElement{ + res = append(res, &ReplyElement{ ReplySeq: elem.SrcMsg.OrigSeqs[0], Time: uint32(elem.SrcMsg.Time.Unwrap()), SenderUin: uint32(elem.SrcMsg.SenderUin), GroupUin: uint32(elem.SrcMsg.ToUin.Unwrap()), Elements: ParseMessageElements(elem.SrcMsg.Elems), - } - res = append(res, r) + }) } if elem.Text != nil { @@ -191,24 +192,25 @@ func ParseMessageElements(msg []*message.Elem) []IMessageElement { } if elem.Face != nil { - switch { - case len(elem.Face.Old) > 0: + if len(elem.Face.Old) > 0 { faceID := elem.Face.Index if faceID.IsSome() { res = append(res, &FaceElement{FaceID: uint32(faceID.Unwrap())}) } - case elem.CommonElem != nil && elem.CommonElem.ServiceType == 37 && elem.CommonElem.PbElem != nil: - qFace := message.QFaceExtra{} - if err := proto.Unmarshal(elem.CommonElem.PbElem, &qFace); err == nil { - if qFace.Qsid.IsSome() { - res = append(res, &FaceElement{FaceID: uint32(qFace.Qsid.Unwrap()), isLargeFace: true}) + } else if elem.CommonElem != nil && elem.CommonElem.PbElem != nil { + if elem.CommonElem.ServiceType == 37 { + qFace := message.QFaceExtra{} + if err := proto.Unmarshal(elem.CommonElem.PbElem, &qFace); err == nil { + if qFace.Qsid.IsSome() { + res = append(res, &FaceElement{FaceID: uint32(qFace.Qsid.Unwrap()), isLargeFace: true}) + } + } + } else if elem.CommonElem.ServiceType == 33 { + qFace := message.QSmallFaceExtra{} + err := proto.Unmarshal(elem.CommonElem.PbElem, &qFace) + if err == nil { + res = append(res, &FaceElement{FaceID: qFace.FaceId, isLargeFace: false}) } - } - case elem.CommonElem != nil && elem.CommonElem.ServiceType == 33 && elem.CommonElem.PbElem != nil: - qFace := message.QSmallFaceExtra{} - err := proto.Unmarshal(elem.CommonElem.PbElem, &qFace) - if err == nil { - res = append(res, &FaceElement{FaceID: qFace.FaceId, isLargeFace: false}) } } } @@ -328,7 +330,7 @@ func ParseMessageElements(msg []*message.Elem) []IMessageElement { }) case 11, 21: // video var thumb = new(VideoThumb) - if !(len(extra.MsgInfoBody) < 2) { + if len(extra.MsgInfoBody) > 1 { info := extra.MsgInfoBody[1].Index thumb.Size = info.Info.FileSize thumb.Width = info.Info.Width @@ -408,7 +410,7 @@ func ParseMessageElements(msg []*message.Elem) []IMessageElement { } else { res = append(res, &XMLElement{ ServiceID: 35, - Content: utils.B2S(binary.ZlibUncompress(elem.RichMsg.Template1[1:])), + Content: utils.B2S(xmlData), }) } } @@ -654,11 +656,9 @@ func PackElementsToBody(msgElems []IMessageElement) (msgBody *message.MessageBod RichText: &message.RichText{Elems: PackElements(msgElems)}, } for _, elem := range msgElems { - bd, ok := elem.(MsgContentBuilder) - if !ok { - continue + if bd, ok := elem.(MsgContentBuilder); ok { + msgBody.MsgContent = bd.BuildContent() } - msgBody.MsgContent = bd.BuildContent() } return } @@ -669,11 +669,9 @@ func PackElements(msgElems []IMessageElement) []*message.Elem { } elems := make([]*message.Elem, 0, len(msgElems)) for _, elem := range msgElems { - bd, ok := elem.(ElementBuilder) - if !ok { - continue + if bd, ok := elem.(ElementBuilder); ok { + elems = append(elems, bd.BuildElement()...) } - elems = append(elems, bd.BuildElement()...) } return elems } From 58a6b3f841605c5462e67788b0a37a01978b6dd6 Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Mon, 17 Feb 2025 01:53:20 +0800 Subject: [PATCH 2/4] code ... --- client/packets/pb/action/action.pb.go | 3 +- client/packets/pb/message/element.pb.go | 50 ++++++++----------- client/packets/pb/message/element.proto | 4 +- client/packets/pb/message/message.pb.go | 3 +- .../packets/pb/service/highway/highway.pb.go | 3 +- 5 files changed, 26 insertions(+), 37 deletions(-) diff --git a/client/packets/pb/action/action.pb.go b/client/packets/pb/action/action.pb.go index 1149e0e..b565bb7 100644 --- a/client/packets/pb/action/action.pb.go +++ b/client/packets/pb/action/action.pb.go @@ -4,9 +4,8 @@ package action import ( - proto "github.com/RomiChan/protobuf/proto" - message "github.com/LagrangeDev/LagrangeGo/client/packets/pb/message" + proto "github.com/RomiChan/protobuf/proto" ) type FaceRoamRequest struct { diff --git a/client/packets/pb/message/element.pb.go b/client/packets/pb/message/element.pb.go index 152b641..4b7152b 100644 --- a/client/packets/pb/message/element.pb.go +++ b/client/packets/pb/message/element.pb.go @@ -8,36 +8,26 @@ import ( ) type Elem struct { - Text *Text `protobuf:"bytes,1,opt"` - Face *Face `protobuf:"bytes,2,opt"` - OnlineImage *OnlineImage `protobuf:"bytes,3,opt"` - NotOnlineImage *NotOnlineImage `protobuf:"bytes,4,opt"` - TransElem *TransElem `protobuf:"bytes,5,opt"` - MarketFace *MarketFace `protobuf:"bytes,6,opt"` - CustomFace *CustomFace `protobuf:"bytes,8,opt"` - ElemFlags2 *ElemFlags2 `protobuf:"bytes,9,opt"` - RichMsg *RichMsg `protobuf:"bytes,12,opt"` - GroupFile *GroupFile `protobuf:"bytes,13,opt"` - ExtraInfo *ExtraInfo `protobuf:"bytes,16,opt"` - VideoFile *VideoFile `protobuf:"bytes,19,opt"` - AnonymousGroupMessage *AnonymousGroupMessage `protobuf:"bytes,21,opt"` - QQWalletMsg *QQWalletMsg `protobuf:"bytes,24,opt"` - CustomElem *CustomElem `protobuf:"bytes,31,opt"` - GeneralFlags *GeneralFlags `protobuf:"bytes,37,opt"` - SrcMsg *SrcMsg `protobuf:"bytes,45,opt"` - LightAppElem *LightAppElem `protobuf:"bytes,51,opt"` - CommonElem *CommonElem `protobuf:"bytes,53,opt"` - _ [0]func() -} - -type AnonymousGroupMessage struct { - Flags int32 `protobuf:"varint,1,opt"` - AnonId []byte `protobuf:"bytes,2,opt"` - AnonNick []byte `protobuf:"bytes,3,opt"` - HeadPortrait int32 `protobuf:"varint,4,opt"` - ExpireTime int32 `protobuf:"varint,5,opt"` - BubbleId int32 `protobuf:"varint,6,opt"` - RankColor []byte `protobuf:"bytes,7,opt"` + Text *Text `protobuf:"bytes,1,opt"` + Face *Face `protobuf:"bytes,2,opt"` + OnlineImage *OnlineImage `protobuf:"bytes,3,opt"` + NotOnlineImage *NotOnlineImage `protobuf:"bytes,4,opt"` + TransElem *TransElem `protobuf:"bytes,5,opt"` + MarketFace *MarketFace `protobuf:"bytes,6,opt"` + CustomFace *CustomFace `protobuf:"bytes,8,opt"` + ElemFlags2 *ElemFlags2 `protobuf:"bytes,9,opt"` + RichMsg *RichMsg `protobuf:"bytes,12,opt"` + GroupFile *GroupFile `protobuf:"bytes,13,opt"` + ExtraInfo *ExtraInfo `protobuf:"bytes,16,opt"` + VideoFile *VideoFile `protobuf:"bytes,19,opt"` + // optional AnonymousGroupMessage AnonymousGroupMessage = 21; + QQWalletMsg *QQWalletMsg `protobuf:"bytes,24,opt"` + CustomElem *CustomElem `protobuf:"bytes,31,opt"` + GeneralFlags *GeneralFlags `protobuf:"bytes,37,opt"` + SrcMsg *SrcMsg `protobuf:"bytes,45,opt"` + LightAppElem *LightAppElem `protobuf:"bytes,51,opt"` + CommonElem *CommonElem `protobuf:"bytes,53,opt"` + _ [0]func() } type CommonElem struct { diff --git a/client/packets/pb/message/element.proto b/client/packets/pb/message/element.proto index cb0d863..634b631 100644 --- a/client/packets/pb/message/element.proto +++ b/client/packets/pb/message/element.proto @@ -15,7 +15,7 @@ message Elem { optional GroupFile GroupFile = 13; optional ExtraInfo ExtraInfo = 16; optional VideoFile VideoFile = 19; - optional AnonymousGroupMessage AnonymousGroupMessage = 21; + //optional AnonymousGroupMessage AnonymousGroupMessage = 21; optional QQWalletMsg QQWalletMsg = 24; optional CustomElem CustomElem = 31; optional GeneralFlags GeneralFlags = 37; @@ -24,6 +24,7 @@ message Elem { optional CommonElem CommonElem = 53; } +/* message AnonymousGroupMessage { int32 Flags = 1; bytes AnonId = 2; @@ -33,6 +34,7 @@ message AnonymousGroupMessage { int32 BubbleId = 6; bytes RankColor = 7; } +*/ message CommonElem { int32 ServiceType = 1; diff --git a/client/packets/pb/message/message.pb.go b/client/packets/pb/message/message.pb.go index 86bc6a6..c6eb214 100644 --- a/client/packets/pb/message/message.pb.go +++ b/client/packets/pb/message/message.pb.go @@ -4,9 +4,8 @@ package message import ( - proto "github.com/RomiChan/protobuf/proto" - system "github.com/LagrangeDev/LagrangeGo/client/packets/pb/system" + proto "github.com/RomiChan/protobuf/proto" ) type ContentHead struct { diff --git a/client/packets/pb/service/highway/highway.pb.go b/client/packets/pb/service/highway/highway.pb.go index aa70de3..2304724 100644 --- a/client/packets/pb/service/highway/highway.pb.go +++ b/client/packets/pb/service/highway/highway.pb.go @@ -4,9 +4,8 @@ package highway import ( - proto "github.com/RomiChan/protobuf/proto" - oidb "github.com/LagrangeDev/LagrangeGo/client/packets/pb/service/oidb" + proto "github.com/RomiChan/protobuf/proto" ) type DataHighwayHead struct { From ee5d35d285e6f38d201aa602e46ede9345bfd807 Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Mon, 17 Feb 2025 09:49:24 +0800 Subject: [PATCH 3/4] code ... --- client/message.go | 3 -- client/operation.go | 15 ++++++ client/packets/pb/action/action.pb.go | 3 +- client/packets/pb/message/element.pb.go | 50 +++++++++++-------- client/packets/pb/message/element.proto | 4 +- client/packets/pb/message/message.pb.go | 3 +- .../packets/pb/service/highway/highway.pb.go | 3 +- message/message.go | 24 ++------- 8 files changed, 57 insertions(+), 48 deletions(-) diff --git a/client/message.go b/client/message.go index 978c38d..f41e397 100644 --- a/client/message.go +++ b/client/message.go @@ -72,7 +72,6 @@ func (c *QQClient) SendGroupMessage(groupUin uint32, elements []message2.IMessag UID: c.GetUID(c.Uin), Nickname: c.NickName(), CardName: minfo.MemberCard, - //AnonymousInfo: nil, IsFriend: true, }, Time: ret.Timestamp1, @@ -109,7 +108,6 @@ func (c *QQClient) SendPrivateMessage(uin uint32, elements []message2.IMessageEl Uin: c.Uin, UID: c.GetUID(c.Uin), Nickname: c.NickName(), - //AnonymousInfo: nil, IsFriend: true, }, Elements: elements, @@ -140,7 +138,6 @@ func (c *QQClient) SendTempMessage(groupUin uint32, uin uint32, elements []messa Uin: c.Uin, UID: c.GetUID(c.Uin), Nickname: c.NickName(), - //AnonymousInfo: nil, IsFriend: true, }, Elements: elements, diff --git a/client/operation.go b/client/operation.go index 4281d3f..51acd51 100644 --- a/client/operation.go +++ b/client/operation.go @@ -477,6 +477,21 @@ func (c *QQClient) GetGroupRecordURL(groupUin uint32, node *oidb.IndexNode) (str return oidb2.ParseGroupRecordDownloadResp(resp) } +/* king bug ? +func (c *QQClient) GetVideoNode() *oidb.IndexNode { + return &oidb.IndexNode{ + Info: &oidb2.FileInfo{ + FileName: video.FileName, + FileSize: video.FileSize, + FileSha1: video.FileSha1, + FileHash: video.FileMd5, + }, + FileUuid: video.FileUuid, + StoreId : 1, // 0旧服务器 1为nt服务器 + }, +} +*/ + // GetPrivateVideoURL 获取私聊视频下载链接 func (c *QQClient) GetPrivateVideoURL(node *oidb.IndexNode) (string, error) { pkt, err := oidb2.BuildPrivateVideoDownloadReq(c.Sig().UID, node) diff --git a/client/packets/pb/action/action.pb.go b/client/packets/pb/action/action.pb.go index b565bb7..1149e0e 100644 --- a/client/packets/pb/action/action.pb.go +++ b/client/packets/pb/action/action.pb.go @@ -4,8 +4,9 @@ package action import ( - message "github.com/LagrangeDev/LagrangeGo/client/packets/pb/message" proto "github.com/RomiChan/protobuf/proto" + + message "github.com/LagrangeDev/LagrangeGo/client/packets/pb/message" ) type FaceRoamRequest struct { diff --git a/client/packets/pb/message/element.pb.go b/client/packets/pb/message/element.pb.go index 4b7152b..152b641 100644 --- a/client/packets/pb/message/element.pb.go +++ b/client/packets/pb/message/element.pb.go @@ -8,26 +8,36 @@ import ( ) type Elem struct { - Text *Text `protobuf:"bytes,1,opt"` - Face *Face `protobuf:"bytes,2,opt"` - OnlineImage *OnlineImage `protobuf:"bytes,3,opt"` - NotOnlineImage *NotOnlineImage `protobuf:"bytes,4,opt"` - TransElem *TransElem `protobuf:"bytes,5,opt"` - MarketFace *MarketFace `protobuf:"bytes,6,opt"` - CustomFace *CustomFace `protobuf:"bytes,8,opt"` - ElemFlags2 *ElemFlags2 `protobuf:"bytes,9,opt"` - RichMsg *RichMsg `protobuf:"bytes,12,opt"` - GroupFile *GroupFile `protobuf:"bytes,13,opt"` - ExtraInfo *ExtraInfo `protobuf:"bytes,16,opt"` - VideoFile *VideoFile `protobuf:"bytes,19,opt"` - // optional AnonymousGroupMessage AnonymousGroupMessage = 21; - QQWalletMsg *QQWalletMsg `protobuf:"bytes,24,opt"` - CustomElem *CustomElem `protobuf:"bytes,31,opt"` - GeneralFlags *GeneralFlags `protobuf:"bytes,37,opt"` - SrcMsg *SrcMsg `protobuf:"bytes,45,opt"` - LightAppElem *LightAppElem `protobuf:"bytes,51,opt"` - CommonElem *CommonElem `protobuf:"bytes,53,opt"` - _ [0]func() + Text *Text `protobuf:"bytes,1,opt"` + Face *Face `protobuf:"bytes,2,opt"` + OnlineImage *OnlineImage `protobuf:"bytes,3,opt"` + NotOnlineImage *NotOnlineImage `protobuf:"bytes,4,opt"` + TransElem *TransElem `protobuf:"bytes,5,opt"` + MarketFace *MarketFace `protobuf:"bytes,6,opt"` + CustomFace *CustomFace `protobuf:"bytes,8,opt"` + ElemFlags2 *ElemFlags2 `protobuf:"bytes,9,opt"` + RichMsg *RichMsg `protobuf:"bytes,12,opt"` + GroupFile *GroupFile `protobuf:"bytes,13,opt"` + ExtraInfo *ExtraInfo `protobuf:"bytes,16,opt"` + VideoFile *VideoFile `protobuf:"bytes,19,opt"` + AnonymousGroupMessage *AnonymousGroupMessage `protobuf:"bytes,21,opt"` + QQWalletMsg *QQWalletMsg `protobuf:"bytes,24,opt"` + CustomElem *CustomElem `protobuf:"bytes,31,opt"` + GeneralFlags *GeneralFlags `protobuf:"bytes,37,opt"` + SrcMsg *SrcMsg `protobuf:"bytes,45,opt"` + LightAppElem *LightAppElem `protobuf:"bytes,51,opt"` + CommonElem *CommonElem `protobuf:"bytes,53,opt"` + _ [0]func() +} + +type AnonymousGroupMessage struct { + Flags int32 `protobuf:"varint,1,opt"` + AnonId []byte `protobuf:"bytes,2,opt"` + AnonNick []byte `protobuf:"bytes,3,opt"` + HeadPortrait int32 `protobuf:"varint,4,opt"` + ExpireTime int32 `protobuf:"varint,5,opt"` + BubbleId int32 `protobuf:"varint,6,opt"` + RankColor []byte `protobuf:"bytes,7,opt"` } type CommonElem struct { diff --git a/client/packets/pb/message/element.proto b/client/packets/pb/message/element.proto index 634b631..cb0d863 100644 --- a/client/packets/pb/message/element.proto +++ b/client/packets/pb/message/element.proto @@ -15,7 +15,7 @@ message Elem { optional GroupFile GroupFile = 13; optional ExtraInfo ExtraInfo = 16; optional VideoFile VideoFile = 19; - //optional AnonymousGroupMessage AnonymousGroupMessage = 21; + optional AnonymousGroupMessage AnonymousGroupMessage = 21; optional QQWalletMsg QQWalletMsg = 24; optional CustomElem CustomElem = 31; optional GeneralFlags GeneralFlags = 37; @@ -24,7 +24,6 @@ message Elem { optional CommonElem CommonElem = 53; } -/* message AnonymousGroupMessage { int32 Flags = 1; bytes AnonId = 2; @@ -34,7 +33,6 @@ message AnonymousGroupMessage { int32 BubbleId = 6; bytes RankColor = 7; } -*/ message CommonElem { int32 ServiceType = 1; diff --git a/client/packets/pb/message/message.pb.go b/client/packets/pb/message/message.pb.go index c6eb214..86bc6a6 100644 --- a/client/packets/pb/message/message.pb.go +++ b/client/packets/pb/message/message.pb.go @@ -4,8 +4,9 @@ package message import ( - system "github.com/LagrangeDev/LagrangeGo/client/packets/pb/system" proto "github.com/RomiChan/protobuf/proto" + + system "github.com/LagrangeDev/LagrangeGo/client/packets/pb/system" ) type ContentHead struct { diff --git a/client/packets/pb/service/highway/highway.pb.go b/client/packets/pb/service/highway/highway.pb.go index 2304724..aa70de3 100644 --- a/client/packets/pb/service/highway/highway.pb.go +++ b/client/packets/pb/service/highway/highway.pb.go @@ -4,8 +4,9 @@ package highway import ( - oidb "github.com/LagrangeDev/LagrangeGo/client/packets/pb/service/oidb" proto "github.com/RomiChan/protobuf/proto" + + oidb "github.com/LagrangeDev/LagrangeGo/client/packets/pb/service/oidb" ) type DataHighwayHead struct { diff --git a/message/message.go b/message/message.go index 68b8cf4..0ee1dff 100644 --- a/message/message.go +++ b/message/message.go @@ -81,15 +81,9 @@ type ( UID string Nickname string CardName string - //AnonymousInfo *AnonymousInfo IsFriend bool } - /* - AnonymousInfo struct { - AnonymousID string - AnonymousNick string - } - */ + IMessageElement interface { Type() ElementType } @@ -97,12 +91,6 @@ type ( ElementType int ) -/* -func (s *Sender) IsAnonymous() bool { - return s.Uin == 80000000 -} -*/ - func ParsePrivateMessage(msg *message.PushMsgBody) *PrivateMessage { prvMsg := &PrivateMessage{ ID: msg.ContentHead.Sequence.Unwrap(), @@ -173,15 +161,14 @@ func ParseMessageElements(msg []*message.Elem) []IMessageElement { } if elem.Text != nil { - switch { - case len(elem.Text.Attr6Buf) > 0: + if len(elem.Text.Attr6Buf) > 0 { att6 := binary.NewReader(elem.Text.Attr6Buf) att6.SkipBytes(7) target := att6.ReadU32() at := NewAt(target, elem.Text.Str.Unwrap()) at.SubType = AtTypeGroupMember res = append(res, at) - default: + } else { res = append(res, NewText(func() string { if strings.Contains(elem.Text.Str.Unwrap(), "\r") && !strings.Contains(elem.Text.Str.Unwrap(), "\r\n") { return strings.ReplaceAll(elem.Text.Str.Unwrap(), "\r", "\r\n") @@ -452,8 +439,7 @@ func ParseMessageBody(body *message.MessageBody, isGroup bool) []IMessageElement if body != nil { if body.RichText != nil && body.RichText.Ptt != nil { ptt := body.RichText.Ptt - switch { - case isGroup && ptt.FileId != 0: + if isGroup && ptt.FileId != 0 { res = append(res, &VoiceElement{ Name: ptt.FileName, UUID: ptt.FileUuid, @@ -462,7 +448,7 @@ func ParseMessageBody(body *message.MessageBody, isGroup bool) []IMessageElement FileUuid: ptt.GroupFileKey, }, }) - case !isGroup: + } else if !isGroup { res = append(res, &VoiceElement{ Name: ptt.FileName, UUID: ptt.FileUuid, From c0b7c8e2e48fbc01bdfd94004e3b7230fc1cac06 Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Mon, 17 Feb 2025 10:02:15 +0800 Subject: [PATCH 4/4] code ... --- client/operation.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/client/operation.go b/client/operation.go index 51acd51..faef086 100644 --- a/client/operation.go +++ b/client/operation.go @@ -477,20 +477,18 @@ func (c *QQClient) GetGroupRecordURL(groupUin uint32, node *oidb.IndexNode) (str return oidb2.ParseGroupRecordDownloadResp(resp) } -/* king bug ? -func (c *QQClient) GetVideoNode() *oidb.IndexNode { +func (c *QQClient) GenFileNode(name, md5, sha1, uuid string, size uint32, isnt bool) *oidb.IndexNode { return &oidb.IndexNode{ - Info: &oidb2.FileInfo{ - FileName: video.FileName, - FileSize: video.FileSize, - FileSha1: video.FileSha1, - FileHash: video.FileMd5, + Info: &oidb.FileInfo{ + FileName: name, + FileSize: size, + FileSha1: sha1, + FileHash: md5, }, - FileUuid: video.FileUuid, - StoreId : 1, // 0旧服务器 1为nt服务器 - }, + FileUuid: uuid, + StoreId: utils.Ternary[uint32](isnt, 1, 0), // 0旧服务器 1为nt服务器 + } } -*/ // GetPrivateVideoURL 获取私聊视频下载链接 func (c *QQClient) GetPrivateVideoURL(node *oidb.IndexNode) (string, error) {