From: Rudolf Polzer Date: Thu, 5 Oct 2023 20:41:24 +0000 (+0200) Subject: powerbot: Fix re-saving. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2fc7d0fefe6c7cb00b4b31fa121278a1966bbd63;p=xonotic%2Fxonotic.git powerbot: Fix re-saving. --- diff --git a/misc/infrastructure/powerbot/bot.go b/misc/infrastructure/powerbot/bot.go index 9557685f..b373c826 100644 --- a/misc/infrastructure/powerbot/bot.go +++ b/misc/infrastructure/powerbot/bot.go @@ -19,8 +19,8 @@ const ( ) type Room struct { - ID id.RoomID - Name string + ID id.RoomID `json:"id"` + Name string `json:"name",omitempty` } type Config struct { @@ -207,12 +207,16 @@ func Run() (err error) { return } for _, group := range config.Rooms { - for _, room := range group { + for i := range group { + room := &group[i] if room.ID == evt.RoomID { configMu.Lock() defer configMu.Unlock() room.ID = tomb.ReplacementRoom - config.Save() + err := config.Save() + if err != nil { + log.Printf("failed to save config: %v", err) + } log.Fatalf("room upgrade for %v handled from %v to %v - need restart", room.Name, evt.RoomID, tomb.ReplacementRoom) } }