From 6c8ee91ad6a1bef0167be384e96b4415993f1448 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Thu, 18 Jul 2024 12:46:12 +1000 Subject: [PATCH] Put in a hacked up feature to disable Kick Pusher as the API is having massive issues (again) --- KfChatDotNetKickBot/KickBot.cs | 23 ++++++++++++++++------- KfChatDotNetKickBot/Settings/BuiltIn.cs | 9 +++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/KfChatDotNetKickBot/KickBot.cs b/KfChatDotNetKickBot/KickBot.cs index b18fcdf..7419a88 100644 --- a/KfChatDotNetKickBot/KickBot.cs +++ b/KfChatDotNetKickBot/KickBot.cs @@ -37,6 +37,7 @@ public class KickBot private BotCommands _botCommands; private string _bmjTwitchUsername; private Howlgg _howlgg; + private bool _kickDisabled = true; public KickBot() { @@ -46,7 +47,7 @@ public class KickBot BuiltIn.Keys.KiwiFarmsWsEndpoint, BuiltIn.Keys.KiwiFarmsDomain, BuiltIn.Keys.PusherEndpoint, BuiltIn.Keys.Proxy, BuiltIn.Keys.PusherReconnectTimeout, BuiltIn.Keys.PusherChannels, BuiltIn.Keys.TwitchBossmanJackId, BuiltIn.Keys.DiscordToken, BuiltIn.Keys.KiwiFarmsWsReconnectTimeout, - BuiltIn.Keys.KiwiFarmsToken + BuiltIn.Keys.KiwiFarmsToken, BuiltIn.Keys.KickEnabled ]).Result; _xfSessionToken = settings[BuiltIn.Keys.KiwiFarmsToken].Value ?? "unset"; @@ -82,14 +83,19 @@ public class KickBot _kickClient.OnWsReconnect += OnPusherWsReconnected; _kickClient.OnPusherSubscriptionSucceeded += OnPusherSubscriptionSucceeded; _kickClient.OnStopStreamBroadcast += OnStopStreamBroadcast; - + KfClient.StartWsClient().Wait(_cancellationToken); - _kickClient.StartWsClient().Wait(_cancellationToken); - var pusherChannels = settings[BuiltIn.Keys.PusherChannels].Value ?? ""; - foreach (var channel in pusherChannels.Split(',')) + if (settings[BuiltIn.Keys.KickEnabled].ToBoolean()) { - _kickClient.SendPusherSubscribe(channel); + _kickClient.StartWsClient().Wait(_cancellationToken); + var pusherChannels = settings[BuiltIn.Keys.PusherChannels].Value ?? ""; + foreach (var channel in pusherChannels.Split(',')) + { + _kickClient.SendPusherSubscribe(channel); + } + + _kickDisabled = false; } _logger.Debug("Creating ping thread and starting it"); @@ -308,7 +314,10 @@ public class KickBot Thread.Sleep(TimeSpan.FromSeconds(15)); _logger.Debug("Pinging KF"); KfClient.SendMessage("/ping"); - _kickClient.SendPusherPing(); + if (!_kickDisabled) + { + _kickClient.SendPusherPing(); + } if (_initialStartCooldown) _initialStartCooldown = false; var inactivityTime = DateTime.Now - _lastKfEvent; _logger.Debug($"Last KF event was {inactivityTime:g} ago"); diff --git a/KfChatDotNetKickBot/Settings/BuiltIn.cs b/KfChatDotNetKickBot/Settings/BuiltIn.cs index 4995120..0fe1fd4 100644 --- a/KfChatDotNetKickBot/Settings/BuiltIn.cs +++ b/KfChatDotNetKickBot/Settings/BuiltIn.cs @@ -312,6 +312,14 @@ public static class BuiltIn Description = "Last successfully retrieved forum token (will be refreshed automatically if expired)", Default = null, IsSecret = true + }, + new BuiltInSettingsModel + { + Key = Keys.KickEnabled, + Regex = "true|false", + Description = "Whether to enable Kick functionality (Pusher websocket mainly)", + Default = "true", + IsSecret = false } ]; @@ -342,5 +350,6 @@ public static class BuiltIn public static string JuiceCooldown = "Juice.Cooldown"; public static string JuiceAmount = "Juice.Amount"; public static string KiwiFarmsToken = "KiwiFarms.Token"; + public static string KickEnabled = "Kick.Enabled"; } } \ No newline at end of file