diff --git a/KfChatDotNetBot/Services/BotServices.cs b/KfChatDotNetBot/Services/BotServices.cs index 56fd44e..094f7d7 100644 --- a/KfChatDotNetBot/Services/BotServices.cs +++ b/KfChatDotNetBot/Services/BotServices.cs @@ -121,8 +121,13 @@ public class BotServices private async Task BuildChipsgg() { - var proxy = await Helpers.GetValue(BuiltIn.Keys.Proxy); - _chipsgg = new Chipsgg(proxy.Value, _cancellationToken); + var settings = await Helpers.GetMultipleValues([BuiltIn.Keys.Proxy, BuiltIn.Keys.ChipsggEnabled]); + if (!settings[BuiltIn.Keys.ChipsggEnabled].ToBoolean()) + { + _logger.Debug("Chips.gg is disabled"); + return; + } + _chipsgg = new Chipsgg(settings[BuiltIn.Keys.Proxy].Value, _cancellationToken); _chipsgg.OnChipsggRecentBet += OnChipsggRecentBet; await _chipsgg.StartWsClient(); _logger.Info("Built Chips.gg Websocket connection"); @@ -155,8 +160,13 @@ public class BotServices private async Task BuildHowlgg() { - var proxy = await Helpers.GetValue(BuiltIn.Keys.Proxy); - _howlgg = new Howlgg(proxy.Value, _cancellationToken); + var settings = await Helpers.GetMultipleValues([BuiltIn.Keys.Proxy, BuiltIn.Keys.HowlggEnabled]); + if (!settings[BuiltIn.Keys.HowlggEnabled].ToBoolean()) + { + _logger.Debug("Howlgg is disabled"); + return; + } + _howlgg = new Howlgg(settings[BuiltIn.Keys.Proxy].Value, _cancellationToken); _howlgg.OnHowlggBetHistory += OnHowlggBetHistory; await _howlgg.StartWsClient(); _logger.Info("Built Howl.gg Websocket connection"); @@ -217,7 +227,7 @@ public class BotServices while (await timer.WaitForNextTickAsync(_cancellationToken)) { if (_chatBot.InitialStartCooldown) continue; - var settings = await Helpers.GetMultipleValues([BuiltIn.Keys.KickEnabled]); + var settings = await Helpers.GetMultipleValues([BuiltIn.Keys.KickEnabled, BuiltIn.Keys.HowlggEnabled, BuiltIn.Keys.ChipsggEnabled]); try { if (!_shuffle.IsConnected()) @@ -252,7 +262,7 @@ public class BotServices await BuildTwitchChat(); } - if (!_howlgg.IsConnected()) + if (settings[BuiltIn.Keys.HowlggEnabled].ToBoolean() && !_howlgg.IsConnected()) { _logger.Error("Howl.gg died, recreating it"); _howlgg.Dispose(); @@ -268,7 +278,7 @@ public class BotServices await BuildJackpot(); } - if (!_chipsgg.IsConnected()) + if (settings[BuiltIn.Keys.ChipsggEnabled].ToBoolean() && !_chipsgg.IsConnected()) { _logger.Error("Chips died, recreating it"); _chipsgg.Dispose(); diff --git a/KfChatDotNetBot/Services/Rainbet.cs b/KfChatDotNetBot/Services/Rainbet.cs index 7622dc8..729b29a 100644 --- a/KfChatDotNetBot/Services/Rainbet.cs +++ b/KfChatDotNetBot/Services/Rainbet.cs @@ -36,6 +36,12 @@ public class Rainbet : IDisposable using var timer = new PeriodicTimer(_gameHistoryInterval); while (await timer.WaitForNextTickAsync(_gameHistoryCts.Token)) { + var enabled = await Helpers.GetValue(BuiltIn.Keys.RainbetEnabled); + if (!enabled.ToBoolean()) + { + _logger.Debug("Rainbet is disabled"); + continue; + }; try { _logger.Info($"Retrieving game history from Rainbet, last success: {LastSuccessfulRefresh:yyyy-MM-dd HH:mm:ss}"); diff --git a/KfChatDotNetBot/Settings/BuiltIn.cs b/KfChatDotNetBot/Settings/BuiltIn.cs index 8ac437c..fe6c966 100644 --- a/KfChatDotNetBot/Settings/BuiltIn.cs +++ b/KfChatDotNetBot/Settings/BuiltIn.cs @@ -625,6 +625,33 @@ public static class BuiltIn Default = "[]", IsSecret = false, CacheDuration = TimeSpan.Zero + }, + new BuiltInSettingsModel + { + Key = Keys.HowlggEnabled, + Regex = "(true|false)", + Description = "Whether the Howl.gg integration is enabled at all", + Default = "false", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1) + }, + new BuiltInSettingsModel + { + Key = Keys.ChipsggEnabled, + Regex = "(true|false)", + Description = "Whether the Chips.gg integration is enabled at all", + Default = "false", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1) + }, + new BuiltInSettingsModel + { + Key = Keys.RainbetEnabled, + Regex = "(true|false)", + Description = "Whether the Rainbet integration is enabled at all", + Default = "false", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1) } ]; @@ -686,5 +713,8 @@ public static class BuiltIn public static string BotNextCourtHearing = "Bot.Court.NextHearing"; public static string BotJailStartTime = "Bot.Jail.StartTime"; public static string BotCourtCalendar = "Bot.Court.Calendar"; + public static string HowlggEnabled = "Howlgg.Enabled"; + public static string ChipsggEnabled = "Chipsgg.Enabled"; + public static string RainbetEnabled = "Rainbet.Enabled"; } } \ No newline at end of file