diff --git a/client/builders.go b/client/builders.go index be40c32a..2b0ce1b3 100644 --- a/client/builders.go +++ b/client/builders.go @@ -386,7 +386,10 @@ func (c *QQClient) buildDeleteOnlinePushPacket(uin int64, seq uint16, delMsg []j func (c *QQClient) buildGroupSendingPacket(groupCode int64, r int32, forward bool, m *message.SendingMessage) (uint16, []byte) { seq := c.nextSeq() var ptt *message.GroupVoiceElement - if i := m.FirstOrNil(func(e message.IMessageElement) bool { return e.Type() == message.Voice }); i != nil { + if i := m.FirstOrNil(func(e message.IMessageElement) bool { + _, ok := e.(*message.GroupVoiceElement) + return ok + }); i != nil { ptt = i.(*message.GroupVoiceElement) m.Elements = []message.IMessageElement{} } diff --git a/client/global.go b/client/global.go index 878d08e7..81acd80d 100644 --- a/client/global.go +++ b/client/global.go @@ -269,6 +269,16 @@ func (c *QQClient) parseGroupMessage(m *msg.Message) *message.GroupMessage { Elements: message.ParseMessageElems(m.Body.RichText.Elems), //OriginalElements: m.Body.RichText.Elems, } + if m.Body.RichText.Ptt != nil { + g.Elements = []message.IMessageElement{ + &message.VoiceElement{ + Name: m.Body.RichText.Ptt.FileName, + Md5: m.Body.RichText.Ptt.FileMd5, + Size: m.Body.RichText.Ptt.FileSize, + DownloadPara: string(m.Body.RichText.Ptt.DownPara), + }, + } + } if m.Body.RichText.Attr != nil { g.InternalId = m.Body.RichText.Attr.Random } diff --git a/message/elements.go b/message/elements.go index cfcc7d8b..a9139b63 100644 --- a/message/elements.go +++ b/message/elements.go @@ -25,6 +25,16 @@ type GroupImageElement struct { Url string } +type VoiceElement struct { + Name string + Md5 []byte + Size int32 + DownloadPara string + + // --- sending --- + Data []byte +} + type GroupVoiceElement struct { Data []byte Ptt *msg.Ptt @@ -186,6 +196,10 @@ func (e *GroupVoiceElement) Type() ElementType { return Voice } +func (e *VoiceElement) Type() ElementType { + return Voice +} + var faceMap = map[int]string{ 14: "微笑", 1: "撇嘴",