]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
Powerbot: fix crash when a user is entirely unknown but has a managed PL.
authorRudolf Polzer <divVerent@gmail.com>
Thu, 19 Oct 2023 14:19:39 +0000 (16:19 +0200)
committerRudolf Polzer <divVerent@gmail.com>
Thu, 19 Oct 2023 14:19:59 +0000 (16:19 +0200)
misc/infrastructure/powerbot/powerlevels.go

index ef40fd8cac9a693940cf50be0de75c456163dd3e..42a33c1ed7a21c6e61971513477b9261e69ee8f3 100644 (file)
@@ -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)