diff --git a/KfChatDotNetBot/ChatBot.cs b/KfChatDotNetBot/ChatBot.cs index 9b334a2..dc9ab60 100644 --- a/KfChatDotNetBot/ChatBot.cs +++ b/KfChatDotNetBot/ChatBot.cs @@ -1,5 +1,6 @@ using System.Net; using System.Text.Json; +using Humanizer; using KfChatDotNetBot.Models; using KfChatDotNetBot.Models.DbModels; using KfChatDotNetBot.Services; @@ -46,6 +47,9 @@ public class ChatBot private Rainbet _rainbet; private Chipsgg _chipsgg; private List _sentMessages = []; + // lol + internal bool TemporarilyBypassGambaSeshForDiscord = false; + internal bool TemporarilySuppressGambaMessages = false; public ChatBot() { @@ -232,7 +236,7 @@ public class ChatBot BuiltIn.Keys.ChipsggBmjUsername, BuiltIn.Keys.TwitchBossmanJackUsername, BuiltIn.Keys.KiwiFarmsGreenColor, BuiltIn.Keys.KiwiFarmsRedColor ]).Result; - _logger.Debug("Chips.gg bet has arrived"); + _logger.Trace("Chips.gg bet has arrived"); if (bet.Username != settings[BuiltIn.Keys.ChipsggBmjUsername].Value) { return; @@ -252,6 +256,12 @@ public class ChatBot return; } + if (TemporarilySuppressGambaMessages) + { + _logger.Info("Ignoring as TemporarilySuppressGambaMessages is true"); + return; + } + // Only check once because the bot should be tracking the Twitch stream // This is just in case he's already live while the bot starts // He was schizo betting on Dice, so I want to avoid a lot of API requests to Twitch in case they rate limit @@ -271,7 +281,7 @@ public class ChatBot SendChatMessage( $"🚨🚨 CHIPS BROS 🚨🚨 {bet.Username} just bet {bet.Amount:N} {bet.Currency!.ToUpper()} " + $"({bet.Amount * bet.CurrencyPrice:C}) which paid out [color={payoutColor}]{bet.Winnings:N} {bet.Currency.ToUpper()} " + - $"({bet.Winnings * bet.CurrencyPrice:C})[/color] ({bet.Multiplier:N}x) on {bet.GameTitle} 💰💰[br][i]Please note this feature is not well tested and may be off by an order of magnitude.", + $"({bet.Winnings * bet.CurrencyPrice:C})[/color] ({bet.Multiplier:N}x) on {bet.GameTitle} 💰💰", true); } @@ -337,6 +347,11 @@ public class ChatBot _logger.Info("Ignoring as BMJ is live"); return; } + if (TemporarilySuppressGambaMessages) + { + _logger.Info("Ignoring as TemporarilySuppressGambaMessages is true"); + return; + } // Only check once because the bot should be tracking the Twitch stream // This is just in case he's already live while the bot starts @@ -526,7 +541,8 @@ public class ChatBot { result += $"[br]Attachment: {attachment.GetProperty("filename").GetString()} {attachment.GetProperty("url").GetString()}"; } - SendChatMessage(result); + + SendChatMessage(result, TemporarilyBypassGambaSeshForDiscord); } private void DiscordOnInvalidCredentials(object sender, DiscordPacketReadModel packet) @@ -552,7 +568,12 @@ public class ChatBot _logger.Info("Ignoring as BMJ is live"); return; } - + if (TemporarilySuppressGambaMessages) + { + _logger.Info("Ignoring as TemporarilySuppressGambaMessages is true"); + return; + } + // Only check once because the bot should be tracking the Twitch stream // This is just in case he's already live while the bot starts // He was schizo betting on Dice, so I want to avoid a lot of API requests to Twitch in case they rate limit @@ -677,6 +698,13 @@ public class ChatBot sentMessage.Status = SentMessageTrackerStatus.ResponseReceived; } } + + if (message.Author.Id == settings[BuiltIn.Keys.GambaSeshUserId].ToType() && TemporarilyBypassGambaSeshForDiscord && + message.MessageRaw.Contains("discord16")) + { + _logger.Info("GambaSesh fixed itself, turning off bypass"); + TemporarilyBypassGambaSeshForDiscord = false; + } if (settings[BuiltIn.Keys.GambaSeshDetectEnabled].ToBoolean() && !_initialStartCooldown && message.Author.Id == settings[BuiltIn.Keys.GambaSeshUserId].ToType() && !GambaSeshPresent) { _logger.Info("Received a GambaSesh message after cooldown and while thinking he's not here. Setting the presence flag to avoid spamming chat"); diff --git a/KfChatDotNetBot/Commands/UtilityCommands.cs b/KfChatDotNetBot/Commands/UtilityCommands.cs new file mode 100644 index 0000000..34a8ceb --- /dev/null +++ b/KfChatDotNetBot/Commands/UtilityCommands.cs @@ -0,0 +1,53 @@ +using System.Text.RegularExpressions; +using KfChatDotNetBot.Models.DbModels; +using KfChatDotNetWsClient.Models.Events; + +namespace KfChatDotNetBot.Commands; + +public class TempEnableDiscordRelayingCommand : ICommand +{ + public List Patterns => [ + new Regex("^tempenable discord$") + ]; + + public string? HelpText => null; + public UserRight RequiredRight => UserRight.Guest; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + botInstance.TemporarilyBypassGambaSeshForDiscord = true; + botInstance.SendChatMessage("Enjoy Discord messages, stalker child", true); + } +} + +public class TempSuppressGambaMessages : ICommand +{ + public List Patterns => [ + new Regex("^nogamba$") + ]; + + public string? HelpText => null; + public UserRight RequiredRight => UserRight.Guest; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + botInstance.TemporarilySuppressGambaMessages = true; + botInstance.SendChatMessage("No more gamba notifs", true); + } +} + +public class EnableGambaMessages : ICommand +{ + public List Patterns => [ + new Regex("^yesgamba") + ]; + + public string? HelpText => null; + public UserRight RequiredRight => UserRight.Guest; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + botInstance.TemporarilySuppressGambaMessages = false; + botInstance.SendChatMessage("Gamba notifs back on the menu", true); + } +} \ No newline at end of file