From f7b2235a99ea4e51c1cd0cf38a6cca9c613eee86 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Thu, 4 Mar 2021 08:56:55 +0800 Subject: [PATCH] fix url share. --- client/c2c_processor.go | 20 +++++++++++--------- message/elements.go | 11 ++++++++--- message/pack.go | 2 +- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/client/c2c_processor.go b/client/c2c_processor.go index 47664dfe..1e18a1b0 100644 --- a/client/c2c_processor.go +++ b/client/c2c_processor.go @@ -178,24 +178,26 @@ func privatePttDecoder(c *QQClient, pMsg *msg.Message, _ *c2cExtraOption) { return } if len(pMsg.Body.RichText.Ptt.Reserve) != 0 { - //m := binary.NewReader(pMsg.Body.RichText.Ptt.Reserve[1:]).ReadTlvMap(1) + // m := binary.NewReader(pMsg.Body.RichText.Ptt.Reserve[1:]).ReadTlvMap(1) // T3 -> timestamp T8 -> voiceType T9 -> voiceLength T10 -> PbReserveStruct } c.dispatchFriendMessage(c.parsePrivateMessage(pMsg)) } func tempSessionDecoder(c *QQClient, pMsg *msg.Message, _ *c2cExtraOption) { - if pMsg.Head.C2CTmpMsgHead == nil { + if pMsg.Head.C2CTmpMsgHead == nil || pMsg.Body == nil { return } - group := c.FindGroupByUin(pMsg.Head.C2CTmpMsgHead.GetGroupUin()) - if group == nil { - return + if pMsg.Head.GetMsgType() == 529 && pMsg.Head.GetC2CCmd() == 6 { + group := c.FindGroup(pMsg.Head.C2CTmpMsgHead.GetGroupCode()) + if group == nil { + return + } + if pMsg.Head.GetFromUin() == c.Uin { + return + } + c.dispatchTempMessage(c.parseTempMessage(pMsg)) } - if pMsg.Head.GetFromUin() == c.Uin { - return - } - c.dispatchTempMessage(c.parseTempMessage(pMsg)) } func troopAddMemberBroadcastDecoder(c *QQClient, pMsg *msg.Message, _ *c2cExtraOption) { diff --git a/message/elements.go b/message/elements.go index 324dbfbb..04647d03 100644 --- a/message/elements.go +++ b/message/elements.go @@ -253,11 +253,16 @@ func NewReply(m *GroupMessage) *ReplyElement { } func NewUrlShare(url, title, content, image string) *ServiceElement { - template := fmt.Sprintf(`%s%s`, - url, url, image, title, content, + template := fmt.Sprintf(`%v%v`, + title, url, image, title, content, ) + /* + template := fmt.Sprintf(`%s%s`, + url, url, image, title, content, + ) + */ return &ServiceElement{ - Id: 33, + Id: 1, Content: template, ResId: url, SubType: "UrlShare", diff --git a/message/pack.go b/message/pack.go index 2450cddf..b8a79232 100644 --- a/message/pack.go +++ b/message/pack.go @@ -128,7 +128,7 @@ func (e *FriendImageElement) Pack() (r []*msg.Elem) { func (e *ServiceElement) Pack() (r []*msg.Elem) { r = []*msg.Elem{} // id =35 已移至 ForwardElement - if e.Id == 33 { + if e.Id == 1 { r = append(r, &msg.Elem{ Text: &msg.Text{Str: &e.ResId}, })