1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-20 02:00:49 +00:00

fix: update the correct IRC bot instance so we don't keep more than one

fixes #40
This commit is contained in:
Ash Keel 2022-12-24 14:34:46 +01:00
parent 7e7b796450
commit d4bed8752f
No known key found for this signature in database
GPG key ID: BAD8D93E7314ED3E

View file

@ -98,17 +98,19 @@ func NewManager(db *database.LocalDBClient, server *http.Server, logger *zap.Log
if manager.client.Bot != nil { if manager.client.Bot != nil {
err = manager.client.Bot.Close() err = manager.client.Bot.Close()
if err != nil { if err != nil {
client.logger.Warn("failed to disconnect old bot from Twitch IRC", zap.Error(err)) manager.client.logger.Warn("failed to disconnect old bot from Twitch IRC", zap.Error(err))
} }
} }
bot := newBot(manager.client, newBotConfig) if manager.client.Config.Get().EnableBot {
if client.Config.Get().EnableBot { bot := newBot(manager.client, newBotConfig)
go bot.Connect() go bot.Connect()
manager.client.Bot = bot
} else {
manager.client.Bot = nil
} }
client.Bot = bot manager.client.logger.Info("reloaded/restarted Twitch bot")
client.logger.Info("reloaded/restarted Twitch bot")
}) })
if err != nil { if err != nil {
client.logger.Error("could not setup twitch bot config reload subscription", zap.Error(err)) client.logger.Error("could not setup twitch bot config reload subscription", zap.Error(err))