mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
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:
@@ -1,5 +1,6 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using Humanizer;
|
||||||
using KfChatDotNetBot.Models;
|
using KfChatDotNetBot.Models;
|
||||||
using KfChatDotNetBot.Models.DbModels;
|
using KfChatDotNetBot.Models.DbModels;
|
||||||
using KfChatDotNetBot.Services;
|
using KfChatDotNetBot.Services;
|
||||||
@@ -46,6 +47,9 @@ public class ChatBot
|
|||||||
private Rainbet _rainbet;
|
private Rainbet _rainbet;
|
||||||
private Chipsgg _chipsgg;
|
private Chipsgg _chipsgg;
|
||||||
private List<SentMessageTrackerModel> _sentMessages = [];
|
private List<SentMessageTrackerModel> _sentMessages = [];
|
||||||
|
// lol
|
||||||
|
internal bool TemporarilyBypassGambaSeshForDiscord = false;
|
||||||
|
internal bool TemporarilySuppressGambaMessages = false;
|
||||||
|
|
||||||
public ChatBot()
|
public ChatBot()
|
||||||
{
|
{
|
||||||
@@ -232,7 +236,7 @@ public class ChatBot
|
|||||||
BuiltIn.Keys.ChipsggBmjUsername, BuiltIn.Keys.TwitchBossmanJackUsername,
|
BuiltIn.Keys.ChipsggBmjUsername, BuiltIn.Keys.TwitchBossmanJackUsername,
|
||||||
BuiltIn.Keys.KiwiFarmsGreenColor, BuiltIn.Keys.KiwiFarmsRedColor
|
BuiltIn.Keys.KiwiFarmsGreenColor, BuiltIn.Keys.KiwiFarmsRedColor
|
||||||
]).Result;
|
]).Result;
|
||||||
_logger.Debug("Chips.gg bet has arrived");
|
_logger.Trace("Chips.gg bet has arrived");
|
||||||
if (bet.Username != settings[BuiltIn.Keys.ChipsggBmjUsername].Value)
|
if (bet.Username != settings[BuiltIn.Keys.ChipsggBmjUsername].Value)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -252,6 +256,12 @@ public class ChatBot
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TemporarilySuppressGambaMessages)
|
||||||
|
{
|
||||||
|
_logger.Info("Ignoring as TemporarilySuppressGambaMessages is true");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Only check once because the bot should be tracking the Twitch stream
|
// 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
|
// 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
|
// 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(
|
SendChatMessage(
|
||||||
$"🚨🚨 CHIPS BROS 🚨🚨 {bet.Username} just bet {bet.Amount:N} {bet.Currency!.ToUpper()} " +
|
$"🚨🚨 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.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);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,6 +347,11 @@ public class ChatBot
|
|||||||
_logger.Info("Ignoring as BMJ is live");
|
_logger.Info("Ignoring as BMJ is live");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (TemporarilySuppressGambaMessages)
|
||||||
|
{
|
||||||
|
_logger.Info("Ignoring as TemporarilySuppressGambaMessages is true");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Only check once because the bot should be tracking the Twitch stream
|
// 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
|
// 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()}";
|
result += $"[br]Attachment: {attachment.GetProperty("filename").GetString()} {attachment.GetProperty("url").GetString()}";
|
||||||
}
|
}
|
||||||
SendChatMessage(result);
|
|
||||||
|
SendChatMessage(result, TemporarilyBypassGambaSeshForDiscord);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DiscordOnInvalidCredentials(object sender, DiscordPacketReadModel packet)
|
private void DiscordOnInvalidCredentials(object sender, DiscordPacketReadModel packet)
|
||||||
@@ -552,7 +568,12 @@ public class ChatBot
|
|||||||
_logger.Info("Ignoring as BMJ is live");
|
_logger.Info("Ignoring as BMJ is live");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (TemporarilySuppressGambaMessages)
|
||||||
|
{
|
||||||
|
_logger.Info("Ignoring as TemporarilySuppressGambaMessages is true");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Only check once because the bot should be tracking the Twitch stream
|
// 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
|
// 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
|
// 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;
|
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)
|
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");
|
_logger.Info("Received a GambaSesh message after cooldown and while thinking he's not here. Setting the presence flag to avoid spamming chat");
|
||||||
|
|||||||
53
KfChatDotNetBot/Commands/UtilityCommands.cs
Normal file
53
KfChatDotNetBot/Commands/UtilityCommands.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user