From 96fd4d32e7ef415c3875551c46f8d254f81973e9 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Thu, 2 Dec 2021 12:00:17 +0800 Subject: [PATCH] fix: nil pointer panic on guild event flow decoder --- client/guild_eventflow.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/guild_eventflow.go b/client/guild_eventflow.go index fadf43e4..02275603 100644 --- a/client/guild_eventflow.go +++ b/client/guild_eventflow.go @@ -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 }