From: Rudolf Polzer Date: Thu, 19 Oct 2023 14:19:39 +0000 (+0200) Subject: Powerbot: fix crash when a user is entirely unknown but has a managed PL. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=de42e2b770a60ed0aeae037916e50e11e7d92c74;p=xonotic%2Fxonotic.git Powerbot: fix crash when a user is entirely unknown but has a managed PL. --- diff --git a/misc/infrastructure/powerbot/powerlevels.go b/misc/infrastructure/powerbot/powerlevels.go index ef40fd8c..42a33c1e 100644 --- a/misc/infrastructure/powerbot/powerlevels.go +++ b/misc/infrastructure/powerbot/powerlevels.go @@ -114,7 +114,7 @@ func syncPowerLevels(client *mautrix.Client, room id.RoomID, roomGroup []Room, s } // TODO: Also skip users who aren't in the room for ages. score := scores[room][user] - if level >= minPowerLevel && level <= maxPowerLevel && score.CurrentState == NotActive && time.Now().After(score.LastEvent.Add(powerExpireTime)) { + if level >= minPowerLevel && level <= maxPowerLevel && (score == nil || (score.CurrentState == NotActive && time.Now().After(score.LastEvent.Add(powerExpireTime)))) { // User is inactive - prune them from the power level list. Saves space. // But this doesn't mark the list dirty as there is no need to send an update. log.Printf("room %v user %v power level: PRUNE %v (%v)", room, user, level, score)