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

fix: nil pointer panic on guild event flow decoder

This commit is contained in:
Mrs4s 2021-12-02 12:00:17 +08:00
parent c0713ba75d
commit 96fd4d32e7
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7

View File

@ -133,6 +133,15 @@ func (c *QQClient) processGuildEventBody(m *channel.ChannelMsgContent, eventBody
updateChanLock.Lock()
defer updateChanLock.Unlock()
oldInfo := guild.FindChannel(eventBody.ChangeChanInfo.GetChanId())
if oldInfo == nil {
info, err := c.GuildService.FetchChannelInfo(m.Head.RoutingHead.GetGuildId(), eventBody.ChangeChanInfo.GetChanId())
if err != nil {
c.Error("error to decode channel info updated event: fetch channel info failed: %v", err)
return
}
guild.Channels = append(guild.Channels, info)
oldInfo = info
}
if time.Now().Unix()-oldInfo.fetchTime <= 2 {
return
}