1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

fix: lz4 decode error

This commit is contained in:
Mrs4s 2021-12-04 17:43:00 +08:00
parent e043181fc1
commit 34bb74d1d1
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7

View File

@ -38,6 +38,10 @@ func decodeGuildEventFlowPacket(c *QQClient, _ *incomingPacketInfo, payload []by
press := new(channel.PressMsg) press := new(channel.PressMsg)
dst := make([]byte, len(push.CompressMsg)*2) dst := make([]byte, len(push.CompressMsg)*2)
i, err := lz4.UncompressBlock(push.CompressMsg, dst) i, err := lz4.UncompressBlock(push.CompressMsg, dst)
for times := 0; err != nil && err.Error() == "lz4: invalid source or destination buffer too short" && times < 5; times++ {
dst = append(dst, make([]byte, 1024)...)
i, err = lz4.UncompressBlock(push.CompressMsg, dst)
}
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to decompress guild event packet") return nil, errors.Wrap(err, "failed to decompress guild event packet")
} }
@ -83,10 +87,16 @@ func decodeGuildEventFlowPacket(c *QQClient, _ *incomingPacketInfo, payload []by
c.processGuildEventBody(m, eventBody) c.processGuildEventBody(m, eventBody)
continue continue
} }
if m.Head.ContentHead.GetType() == 3840 {
if m.Head.RoutingHead.GetDirectMessageFlag() == 1 {
// todo: direct message decode
continue
}
if cm := c.parseGuildChannelMessage(m); cm != nil { if cm := c.parseGuildChannelMessage(m); cm != nil {
c.dispatchGuildChannelMessage(cm) c.dispatchGuildChannelMessage(cm)
} }
} }
}
return nil, nil return nil, nil
} }