Added the ability to selectively enable Discord integration for when GambaSesh wigs out and manually control the bet feed given there's no obvious signal when Bossman is live (I might tie in the stage notifications as an alternative tho)

This commit is contained in:
barelyprofessional
2024-08-23 12:32:51 +08:00
parent a717224ee4
commit f81a2f5a42
2 changed files with 85 additions and 4 deletions

View File

@@ -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<SentMessageTrackerModel> _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,6 +568,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
@@ -677,6 +698,13 @@ public class ChatBot
sentMessage.Status = SentMessageTrackerStatus.ResponseReceived;
}
}
if (message.Author.Id == settings[BuiltIn.Keys.GambaSeshUserId].ToType<int>() && 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<int>() && !GambaSeshPresent)
{
_logger.Info("Received a GambaSesh message after cooldown and while thinking he's not here. Setting the presence flag to avoid spamming chat");

View File

@@ -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<Regex> 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<Regex> 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<Regex> 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);
}
}