Skip to content

Commit

Permalink
fix: lz4 decode error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrs4s committed Dec 4, 2021
1 parent e043181 commit 34bb74d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions client/guild_eventflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func decodeGuildEventFlowPacket(c *QQClient, _ *incomingPacketInfo, payload []by
press := new(channel.PressMsg)
dst := make([]byte, len(push.CompressMsg)*2)
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 {
return nil, errors.Wrap(err, "failed to decompress guild event packet")
}
Expand Down Expand Up @@ -83,8 +87,14 @@ func decodeGuildEventFlowPacket(c *QQClient, _ *incomingPacketInfo, payload []by
c.processGuildEventBody(m, eventBody)
continue
}
if cm := c.parseGuildChannelMessage(m); cm != nil {
c.dispatchGuildChannelMessage(cm)
if m.Head.ContentHead.GetType() == 3840 {
if m.Head.RoutingHead.GetDirectMessageFlag() == 1 {
// todo: direct message decode
continue
}
if cm := c.parseGuildChannelMessage(m); cm != nil {
c.dispatchGuildChannelMessage(cm)
}
}
}
return nil, nil
Expand Down

0 comments on commit 34bb74d

Please sign in to comment.