From d4bed8752fec5929480dbf7481bf50e57a29b2ac Mon Sep 17 00:00:00 2001 From: Ash Keel Date: Sat, 24 Dec 2022 14:34:46 +0100 Subject: [PATCH] fix: update the correct IRC bot instance so we don't keep more than one fixes #40 --- twitch/client.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/twitch/client.go b/twitch/client.go index e561780..018a299 100644 --- a/twitch/client.go +++ b/twitch/client.go @@ -98,17 +98,19 @@ func NewManager(db *database.LocalDBClient, server *http.Server, logger *zap.Log if manager.client.Bot != nil { err = manager.client.Bot.Close() 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 client.Config.Get().EnableBot { + if manager.client.Config.Get().EnableBot { + bot := newBot(manager.client, newBotConfig) go bot.Connect() + manager.client.Bot = bot + } else { + manager.client.Bot = nil } - client.Bot = bot - client.logger.Info("reloaded/restarted Twitch bot") + manager.client.logger.Info("reloaded/restarted Twitch bot") }) if err != nil { client.logger.Error("could not setup twitch bot config reload subscription", zap.Error(err))