diff --git a/KfChatDotNetBot/Commands/AdminCommands.cs b/KfChatDotNetBot/Commands/AdminCommands.cs index b8eeac3..448c1f6 100644 --- a/KfChatDotNetBot/Commands/AdminCommands.cs +++ b/KfChatDotNetBot/Commands/AdminCommands.cs @@ -127,6 +127,96 @@ public class GmKasinoListCommand : ICommand } } +public class GnKasinoAddCommand : ICommand +{ + public List Patterns => [ + new Regex(@"^admin gnkasino add (?.+)$") + ]; + + public string? HelpText => "Add an image to the gnkasino image list"; + public UserRight RequiredRight => UserRight.TrueAndHonest; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + var images = (await Helpers.GetValue(BuiltIn.Keys.BotGnKasinoImageRotation)).JsonDeserialize>(); + if (images == null) + { + await botInstance.SendChatMessageAsync("Images list was null", true); + return; + } + var newImage = arguments["image"].Value; + if (images.Contains(newImage)) + { + await botInstance.SendChatMessageAsync("Image is already in the list", true); + return; + } + + images.Add(newImage); + await Helpers.SetValueAsJsonObject(BuiltIn.Keys.BotGnKasinoImageRotation, images); + await botInstance.SendChatMessageAsync("Updated list of images", true); + } +} + +public class GnKasinoRemoveCommand : ICommand +{ + public List Patterns => [ + new Regex(@"^admin gnkasino remove (?.+)$") + ]; + + public string? HelpText => "Remove an image in the gnkasino image list"; + public UserRight RequiredRight => UserRight.TrueAndHonest; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + var images = (await Helpers.GetValue(BuiltIn.Keys.BotGnKasinoImageRotation)).JsonDeserialize>(); + if (images == null) + { + await botInstance.SendChatMessageAsync("Images list was null", true); + return; + } + var targetImage = arguments["image"].Value; + if (!images.Contains(targetImage)) + { + await botInstance.SendChatMessageAsync("Image is not in the list", true); + return; + } + + images.Remove(targetImage); + await Helpers.SetValueAsJsonObject(BuiltIn.Keys.BotGnKasinoImageRotation, images); + await botInstance.SendChatMessageAsync("Updated list of images", true); + } +} + +public class GnKasinoListCommand : ICommand +{ + public List Patterns => [ + new Regex(@"^admin gnkasino list$") + ]; + + public string? HelpText => "Dump out the list of images for gnkasino"; + public UserRight RequiredRight => UserRight.TrueAndHonest; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + var images = (await Helpers.GetValue(BuiltIn.Keys.BotGnKasinoImageRotation)).JsonDeserialize>(); + if (images == null) + { + await botInstance.SendChatMessageAsync("Images list was null", true); + return; + } + + var result = "List of images:"; + var i = 0; + foreach (var image in images) + { + i++; + result += $"[br]{i}: {image}"; + } + + await botInstance.SendChatMessageAsync(result, true); + } +} + public class ToggleLiveStatusAdminCommand : ICommand { public List Patterns => [ diff --git a/KfChatDotNetBot/Commands/MemeCommands.cs b/KfChatDotNetBot/Commands/MemeCommands.cs index b10abc0..e95f0b0 100644 --- a/KfChatDotNetBot/Commands/MemeCommands.cs +++ b/KfChatDotNetBot/Commands/MemeCommands.cs @@ -1,4 +1,5 @@ using System.Text.RegularExpressions; +using Humanizer; using KfChatDotNetBot.Models.DbModels; using KfChatDotNetBot.Settings; using KfChatDotNetWsClient.Models.Events; @@ -75,6 +76,22 @@ public class GmKasinoCommand : ICommand } } +public class GnKasinoCommand : ICommand +{ + public List Patterns => [new Regex("^gnkasino")]; + public string? HelpText => "Good Night, Kasino"; + public UserRight RequiredRight => UserRight.Loser; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + var images = (await Helpers.GetValue(BuiltIn.Keys.BotGnKasinoImageRotation)).JsonDeserialize>(); + if (images == null) return; + var random = new Random(); + var image = images[random.Next(images.Count)]; + await botInstance.SendChatMessageAsync($"[img]{image}[/img]", true); + } +} + public class CrackedCommand : ICommand { public List Patterns => [ @@ -111,4 +128,55 @@ public class WinmanjackCommand : ICommand var image = await Helpers.GetValue(BuiltIn.Keys.WinmanjackImgUrl); await botInstance.SendChatMessageAsync($"[img]{image.Value}[/img]", true); } +} + +public class PraygeCommand : ICommand +{ + public List Patterns => [ + new Regex("^prayge") + ]; + public string? HelpText => "prayge.jpg"; + public UserRight RequiredRight => UserRight.Loser; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + var image = await Helpers.GetValue(BuiltIn.Keys.BotPraygeImgUrl); + await botInstance.SendChatMessageAsync($"[img]{image.Value}[/img]", true); + } +} + +public class CrackpipeCommand : ICommand +{ + public List Patterns => [ + new Regex("^crackpipe") + ]; + public string? HelpText => "crackpipe.gif"; + public UserRight RequiredRight => UserRight.Loser; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + var image = await Helpers.GetValue(BuiltIn.Keys.BotCrackpipeImgUrl); + await botInstance.SendChatMessageAsync($"[img]{image.Value}[/img]", true); + } +} + +public class CleanCommand : ICommand +{ + public List Patterns => [ + new Regex("^clean") + ]; + public string? HelpText => "How long has Bossman been clean?"; + public UserRight RequiredRight => UserRight.Loser; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + var start = await Helpers.GetValue(BuiltIn.Keys.BotCleanStartTime); + if (start.Value == null) + { + await botInstance.SendChatMessageAsync("Bossman's sobriety start date was null", true); + return; + } + var timespan = DateTimeOffset.UtcNow - DateTimeOffset.Parse(start.Value); + await botInstance.SendChatMessageAsync($"Bossman has been clean {timespan.Humanize(precision:5)}", true); + } } \ No newline at end of file diff --git a/KfChatDotNetBot/Settings/BuiltIn.cs b/KfChatDotNetBot/Settings/BuiltIn.cs index b20bb48..3e2ecf9 100644 --- a/KfChatDotNetBot/Settings/BuiltIn.cs +++ b/KfChatDotNetBot/Settings/BuiltIn.cs @@ -452,6 +452,16 @@ public static class BuiltIn CacheDuration = TimeSpan.FromHours(1) }, new BuiltInSettingsModel + { + Key = Keys.BotGnKasinoImageRotation, + Regex = ".+", + Description = "Rotation of images for the !gnkasino command", + // It's a JSON array + Default = "[\"https://kiwifarms.st/attachments/sleepyjack-gif.5342620/\"]", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1) + }, + new BuiltInSettingsModel { Key = Keys.TwitchShillRestreamOnCommercial, Regex = "(true|false)", @@ -543,6 +553,33 @@ public static class BuiltIn Default = "[]", IsSecret = false, CacheDuration = TimeSpan.FromHours(1) + }, + new BuiltInSettingsModel + { + Key = Keys.BotPraygeImgUrl, + Regex = ".+", + Description = "Image URL for the prayge command", + Default = "https://uploads.kiwifarms.st/data/attachments/5962/5962565-2485292e69a4ccc23505826f88ecdab1.jpg", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1) + }, + new BuiltInSettingsModel + { + Key = Keys.BotCrackpipeImgUrl, + Regex = ".+", + Description = "Image URL for the crackpipe command", + Default = "https://kiwifarms.st/attachments/crack-smoke-gif.6449901/", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1) + }, + new BuiltInSettingsModel + { + Key = Keys.BotCleanStartTime, + Regex = ".+", + Description = "ISO8601 date of Bossman's sobriety", + Default = "2024-09-19T13:33:00-04:00", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1) } ]; @@ -585,6 +622,7 @@ public static class BuiltIn public static string RestreamUrl = "RestreamUrl"; public static string KiwiFarmsCookies = "KiwiFarms.Cookies"; public static string BotGmKasinoImageRotation = "Bot.GmKasinoImageRotation"; + public static string BotGnKasinoImageRotation = "Bot.GnKasino.ImageRotation"; public static string TwitchShillRestreamOnCommercial = "Twitch.ShillRestreamOnCommercial"; public static string KiwiFarmsInactivityTimeout = "KiwiFarms.InactivityTimeout"; public static string KiwiFarmsPingInterval = "KiwiFarms.PingInterval"; @@ -595,5 +633,8 @@ public static class BuiltIn public static string BotDisconnectReplayLimit = "Bot.DisconnectReplayLimit"; public static string KiwiFarmsJoinFailLimit = "KiwiFarms.JoinFailLimit"; public static string KickChannels = "Kick.Channels"; + public static string BotPraygeImgUrl = "Bot.Prayge.ImgUrl"; + public static string BotCrackpipeImgUrl = "Bot.Crackpipe.ImgUrl"; + public static string BotCleanStartTime = "Bot.Clean.StartTime"; } } \ No newline at end of file