Files
KfChatDotNet/KfChatDotNetBot/Commands/UtilityCommands.cs
barelyprofessional e4b1821a5b All the ancillary services have been moved out of the chatbot's class and relocated to a separate file. THe code is still very messy but at least it'll make the main bot easier to navigate.
Also refactored a bunch of shit
* Removed the thread used for pinging, now an async timer
* Kick will no longer block the bot from starting
* Twitch initialization follows the same rules as other services where everything is contained to its build method
* Fixed a bug where the bot's heartbeat logic would get messed up by the machine timezone if it wasn't UTC
2024-09-01 00:53:44 +08:00

53 lines
1.9 KiB
C#

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.BotServices.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.BotServices.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.BotServices.TemporarilySuppressGambaMessages = false;
botInstance.SendChatMessage("Gamba notifs back on the menu", true);
}
}