Compare commits

..

6 Commits

Author SHA1 Message Date
barelyprofessional
cf62274b4b Added option to disable DLive since it has shutdown 2026-05-01 21:13:26 -05:00
barelyprofessional
972e880aa9 Added missing balance format to Krash 2026-05-01 19:53:59 -05:00
barelyprofessional
f5f0ba6323 Added an option to get your exact balance to help deal with rounding issues 2026-05-01 19:53:43 -05:00
barelyprofessional
ab94098dd2 Remove dodgy reference to Redis connection string 2026-05-01 18:20:58 -05:00
barelyprofessional
c79105bb44 Redis client never has a chance to initiate so added that to the start of the bot 2026-05-01 18:12:54 -05:00
barelyprofessional
000c87266e Fix infinite loop on scaled bet 2026-05-01 11:57:20 -05:00
7 changed files with 33 additions and 9 deletions

View File

@@ -18,7 +18,8 @@ public class GetBalanceCommand : ICommand
{ {
public List<Regex> Patterns => [ public List<Regex> Patterns => [
new Regex("^balance", RegexOptions.IgnoreCase), new Regex("^balance", RegexOptions.IgnoreCase),
new Regex("^bal$", RegexOptions.IgnoreCase) new Regex("^bal$", RegexOptions.IgnoreCase),
new Regex("^bal exact$", RegexOptions.IgnoreCase)
]; ];
public string? HelpText => "Get your gamba balance"; public string? HelpText => "Get your gamba balance";
public UserRight RequiredRight => UserRight.Loser; public UserRight RequiredRight => UserRight.Loser;
@@ -30,8 +31,17 @@ public class GetBalanceCommand : ICommand
CancellationToken ctx) CancellationToken ctx)
{ {
var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx); var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx);
if (message.MessageRawHtmlDecoded.EndsWith("exact"))
{
await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance is {gambler!.Balance}", true);
}
else
{
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance is {await gambler!.Balance.FormatKasinoCurrencyAsync()}", true); $"{user.FormatUsername()}, your balance is {await gambler!.Balance.FormatKasinoCurrencyAsync()}", true);
}
if (botInstance.BotServices.KasinoShop != null) if (botInstance.BotServices.KasinoShop != null)
{ {

View File

@@ -81,7 +81,7 @@ public class KrashBetCommand : ICommand
if (wager > gambler.Balance) if (wager > gambler.Balance)
{ {
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {gambler.Balance} is not enough to bet {wager} on krash.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} is not enough to bet {wager} on krash.",
true, autoDeleteAfter: TimeSpan.FromSeconds(5)); true, autoDeleteAfter: TimeSpan.FromSeconds(5));
return; return;
} }

View File

@@ -76,7 +76,7 @@ public class RouletteCommand : ICommand
return; return;
} }
if (string.IsNullOrEmpty(settings[BuiltIn.Keys.BotRedisConnectionString].Value)) if (!Redis.IsAvailable)
{ {
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, roulette is not available at this time", true, await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, roulette is not available at this time", true,
autoDeleteAfter: TimeSpan.FromSeconds(15)); autoDeleteAfter: TimeSpan.FromSeconds(15));

View File

@@ -20,6 +20,7 @@
*/ */
using System.Text; using System.Text;
using KfChatDotNetBot.Services;
using KfChatDotNetBot.Settings; using KfChatDotNetBot.Settings;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NLog; using NLog;
@@ -38,9 +39,19 @@ namespace KfChatDotNetBot
await BuiltIn.SyncSettingsWithDb(); await BuiltIn.SyncSettingsWithDb();
logger.Info("Migrating settings from config.json (if needed)"); logger.Info("Migrating settings from config.json (if needed)");
await BuiltIn.MigrateJsonSettingsToDb(); await BuiltIn.MigrateJsonSettingsToDb();
logger.Info("Attempting to grab the Redis connection multiplexer so it's built");
try
{
_ = Redis.Multiplexer;
}
catch (Exception e)
{
logger.Error("Caught an error when attempting to grab the Redis multiplexer");
logger.Error(e);
}
logger.Info("Handing over to bot now"); logger.Info("Handing over to bot now");
Console.OutputEncoding = Encoding.UTF8; Console.OutputEncoding = Encoding.UTF8;
new ChatBot(); _ = new ChatBot();
} }
} }
} }

View File

@@ -390,12 +390,13 @@ public class BotServices
_logger.Info("Built the almanac shill task"); _logger.Info("Built the almanac shill task");
} }
private Task BuildDLiveStatusCheck() private async Task BuildDLiveStatusCheck()
{ {
var enabled = (await SettingsProvider.GetValueAsync(BuiltIn.Keys.DLiveEnabled)).ToBoolean();
if (!enabled) return;
_dliveStatusCheck = new DLive(_chatBot); _dliveStatusCheck = new DLive(_chatBot);
_dliveStatusCheck.StartLiveStatusCheck(); _dliveStatusCheck.StartLiveStatusCheck();
_logger.Info("Built the DLive livestream status check task"); _logger.Info("Built the DLive livestream status check task");
return Task.CompletedTask;
} }
private Task BuildPeerTubeLiveStatusCheck() private Task BuildPeerTubeLiveStatusCheck()

View File

@@ -202,7 +202,6 @@ public class KasinoKrash : IDisposable
await _kfChatBot.SendChatMessageAsync( await _kfChatBot.SendChatMessageAsync(
$"{bet.Gambler.User.FormatUsername()}, due to your poor gambling skills, your bet was scaled down to {await bet.Wager.FormatKasinoCurrencyAsync()} to match your remaining balance.", $"{bet.Gambler.User.FormatUsername()}, due to your poor gambling skills, your bet was scaled down to {await bet.Wager.FormatKasinoCurrencyAsync()} to match your remaining balance.",
true, autoDeleteAfter: TimeSpan.FromSeconds(10)); true, autoDeleteAfter: TimeSpan.FromSeconds(10));
continue;
} }
} }
else if (bet.Multi <= TheGame.FinalMulti && bet.Multi != -1) else if (bet.Multi <= TheGame.FinalMulti && bet.Multi != -1)

View File

@@ -586,6 +586,9 @@ public static class BuiltIn
public static string WinnaBmjUsername = "Winna.BmjUsername"; public static string WinnaBmjUsername = "Winna.BmjUsername";
[BuiltInSetting("Array of cookies as a shitty hack to get Winna going", SettingValueType.Array, "[]")] [BuiltInSetting("Array of cookies as a shitty hack to get Winna going", SettingValueType.Array, "[]")]
public static string WinnaCookies = "Winna.Cookies"; public static string WinnaCookies = "Winna.Cookies";
[BuiltInSetting("Whether the DLive livestream check is enabled", SettingValueType.Boolean, "false",
BooleanRegex)]
public static string DLiveEnabled = "DLive.Enabled";
} }
} }