Put in a hacked up feature to disable Kick Pusher as the API is having massive issues (again)

This commit is contained in:
barelyprofessional
2024-07-18 12:46:12 +10:00
parent 76b4a750a7
commit 6c8ee91ad6
2 changed files with 25 additions and 7 deletions

View File

@@ -37,6 +37,7 @@ public class KickBot
private BotCommands _botCommands; private BotCommands _botCommands;
private string _bmjTwitchUsername; private string _bmjTwitchUsername;
private Howlgg _howlgg; private Howlgg _howlgg;
private bool _kickDisabled = true;
public KickBot() public KickBot()
{ {
@@ -46,7 +47,7 @@ public class KickBot
BuiltIn.Keys.KiwiFarmsWsEndpoint, BuiltIn.Keys.KiwiFarmsDomain, BuiltIn.Keys.PusherEndpoint, BuiltIn.Keys.KiwiFarmsWsEndpoint, BuiltIn.Keys.KiwiFarmsDomain, BuiltIn.Keys.PusherEndpoint,
BuiltIn.Keys.Proxy, BuiltIn.Keys.PusherReconnectTimeout, BuiltIn.Keys.PusherChannels, BuiltIn.Keys.Proxy, BuiltIn.Keys.PusherReconnectTimeout, BuiltIn.Keys.PusherChannels,
BuiltIn.Keys.TwitchBossmanJackId, BuiltIn.Keys.DiscordToken, BuiltIn.Keys.KiwiFarmsWsReconnectTimeout, BuiltIn.Keys.TwitchBossmanJackId, BuiltIn.Keys.DiscordToken, BuiltIn.Keys.KiwiFarmsWsReconnectTimeout,
BuiltIn.Keys.KiwiFarmsToken BuiltIn.Keys.KiwiFarmsToken, BuiltIn.Keys.KickEnabled
]).Result; ]).Result;
_xfSessionToken = settings[BuiltIn.Keys.KiwiFarmsToken].Value ?? "unset"; _xfSessionToken = settings[BuiltIn.Keys.KiwiFarmsToken].Value ?? "unset";
@@ -85,11 +86,16 @@ public class KickBot
KfClient.StartWsClient().Wait(_cancellationToken); KfClient.StartWsClient().Wait(_cancellationToken);
_kickClient.StartWsClient().Wait(_cancellationToken); if (settings[BuiltIn.Keys.KickEnabled].ToBoolean())
var pusherChannels = settings[BuiltIn.Keys.PusherChannels].Value ?? "";
foreach (var channel in pusherChannels.Split(','))
{ {
_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"); _logger.Debug("Creating ping thread and starting it");
@@ -308,7 +314,10 @@ public class KickBot
Thread.Sleep(TimeSpan.FromSeconds(15)); Thread.Sleep(TimeSpan.FromSeconds(15));
_logger.Debug("Pinging KF"); _logger.Debug("Pinging KF");
KfClient.SendMessage("/ping"); KfClient.SendMessage("/ping");
_kickClient.SendPusherPing(); if (!_kickDisabled)
{
_kickClient.SendPusherPing();
}
if (_initialStartCooldown) _initialStartCooldown = false; if (_initialStartCooldown) _initialStartCooldown = false;
var inactivityTime = DateTime.Now - _lastKfEvent; var inactivityTime = DateTime.Now - _lastKfEvent;
_logger.Debug($"Last KF event was {inactivityTime:g} ago"); _logger.Debug($"Last KF event was {inactivityTime:g} ago");

View File

@@ -312,6 +312,14 @@ public static class BuiltIn
Description = "Last successfully retrieved forum token (will be refreshed automatically if expired)", Description = "Last successfully retrieved forum token (will be refreshed automatically if expired)",
Default = null, Default = null,
IsSecret = true 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 JuiceCooldown = "Juice.Cooldown";
public static string JuiceAmount = "Juice.Amount"; public static string JuiceAmount = "Juice.Amount";
public static string KiwiFarmsToken = "KiwiFarms.Token"; public static string KiwiFarmsToken = "KiwiFarms.Token";
public static string KickEnabled = "Kick.Enabled";
} }
} }