mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 12:32:03 -04:00
Completely untested and totally experimental rate limit feature
This commit is contained in:
@@ -20,6 +20,8 @@ public class SetRoleCommand : ICommand
|
||||
public string? HelpText => "Set a user's role";
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
await using var db = new ApplicationDbContext();
|
||||
@@ -47,6 +49,7 @@ public class CacheClearAdminCommand : ICommand
|
||||
public string? HelpText => null;
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
@@ -69,6 +72,7 @@ public class NewKickChannelCommand : ICommand
|
||||
public string? HelpText => "Add a Kick channel to the bot's database";
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var autoCapture = false;
|
||||
@@ -115,6 +119,7 @@ public class RemoveStreamChannelCommand : ICommand
|
||||
public string? HelpText => "Remove a Kick channel from the bot's database";
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
await using var db = new ApplicationDbContext();
|
||||
@@ -140,6 +145,7 @@ public class ReconnectKickCommand : ICommand
|
||||
public string? HelpText => "Disconnect from Kick so the watchdog can reconnect it";
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
if (botInstance.BotServices.KickClient == null)
|
||||
@@ -163,6 +169,7 @@ public class NewPartiChannelCommand : ICommand
|
||||
public string? HelpText => "Add a Parti channel to the bot's database";
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var autoCapture = false;
|
||||
@@ -210,6 +217,7 @@ public class NewDLiveChannelCommand : ICommand
|
||||
public string? HelpText => "Add a DLive channel to the bot's database";
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var autoCapture = false;
|
||||
@@ -251,6 +259,7 @@ public class AddCourtHearingCommand : ICommand
|
||||
public string? HelpText => "Add a court hearing to the bot's calendar";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var hearings = (await SettingsProvider.GetValueAsync(BuiltIn.Keys.BotCourtCalendar)).JsonDeserialize<List<CourtHearingModel>>();
|
||||
@@ -281,6 +290,7 @@ public class RemoveCourtHearingCommand : ICommand
|
||||
public string? HelpText => "Remove a hearing from the bot's calendar";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var hearings = (await SettingsProvider.GetValueAsync(BuiltIn.Keys.BotCourtCalendar)).JsonDeserialize<List<CourtHearingModel>>();
|
||||
@@ -312,7 +322,7 @@ public class DeleteMessagesCommand : ICommand
|
||||
public string? HelpText => "Delete the most recent x number of messages";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -345,7 +355,7 @@ public class IgnoreCommand : ICommand
|
||||
public string? HelpText => "Ignore a user by ID";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -379,7 +389,7 @@ public class UnignoreCommand : ICommand
|
||||
public string? HelpText => "Unignore a user by ID";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -413,7 +423,7 @@ public class SetAlmanacTextCommand : ICommand
|
||||
public string? HelpText => "Set the almanac text to whatever";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -431,7 +441,7 @@ public class SetAlmanacIntervalCommand : ICommand
|
||||
public string? HelpText => "Set the almanac interval to whatever in seconds";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -461,7 +471,7 @@ public class StopAlmanacCommand : ICommand
|
||||
public string? HelpText => "Stop the almanac reminder";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -490,7 +500,7 @@ public class StartAlmanacCommand : ICommand
|
||||
public string? HelpText => "Start the almanac reminder";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Humanizer;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetBot.Settings;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
@@ -15,6 +16,7 @@ public class HowlggStatsCommand : ICommand
|
||||
public string? HelpText => "Get betting statistics in the given window";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var window = Convert.ToInt32(arguments["window"].Value);
|
||||
@@ -42,6 +44,7 @@ public class HowlggRecentBetCommand : ICommand
|
||||
public string? HelpText => "Get the most recent 3 bets";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
|
||||
namespace KfChatDotNetBot.Commands;
|
||||
|
||||
internal interface ICommand
|
||||
public interface ICommand
|
||||
{
|
||||
List<Regex> Patterns { get; }
|
||||
// Set to null to disable help for a given command
|
||||
string? HelpText { get; }
|
||||
UserRight RequiredRight { get; }
|
||||
TimeSpan Timeout { get; }
|
||||
RateLimitOptionsModel? RateLimitOptions { get; }
|
||||
|
||||
Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class AddImageCommand : ICommand
|
||||
public string? HelpText => "Add an image to the image rotation specified";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ public class RemoveImageCommand : ICommand
|
||||
public string? HelpText => "Remove an image from the image rotation specified";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -99,7 +99,7 @@ public class ListImageCommand : ICommand
|
||||
public string? HelpText => "Remove an image from the image rotation specified";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -138,7 +138,12 @@ public class GetRandomImage : ICommand
|
||||
public string? HelpText => "Get a random image";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromMinutes(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => new()
|
||||
{
|
||||
Window = TimeSpan.FromSeconds(10),
|
||||
MaxInvocations = 3,
|
||||
Flags = RateLimitFlags.NoResponse | RateLimitFlags.UseEntireMessage
|
||||
};
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ public class JuiceCommand : ICommand
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(60);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
await using var db = new ApplicationDbContext();
|
||||
@@ -81,6 +82,7 @@ public class JuiceStatsCommand : ICommand
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
int top;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Humanizer;
|
||||
using Humanizer.Localisation;
|
||||
using KfChatDotNetBot.Extensions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetBot.Services;
|
||||
using KfChatDotNetBot.Settings;
|
||||
@@ -20,7 +21,7 @@ public class GetBalanceCommand : ICommand
|
||||
public string? HelpText => "Get your gamba balance";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -39,7 +40,7 @@ public class GetExclusionCommand : ICommand
|
||||
public string? HelpText => "Get your exclusion status";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -72,7 +73,7 @@ public class SendJuiceCommand : ICommand
|
||||
public string? HelpText => "Send juice to somebody";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -118,7 +119,12 @@ public class RakebackCommand : ICommand
|
||||
public string? HelpText => "Collect your rakeback";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => new RateLimitOptionsModel
|
||||
{
|
||||
MaxInvocations = 1,
|
||||
Window = TimeSpan.FromSeconds(30),
|
||||
Flags = RateLimitFlags.AutoDeleteCooldownResponse
|
||||
};
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -167,7 +173,12 @@ public class LossbackCommand : ICommand
|
||||
public string? HelpText => "Collect your lossback";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => new RateLimitOptionsModel
|
||||
{
|
||||
Window = TimeSpan.FromSeconds(30),
|
||||
MaxInvocations = 1,
|
||||
Flags = RateLimitFlags.AutoDeleteCooldownResponse
|
||||
};
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -213,12 +224,11 @@ public class AbandonKasinoCommand : ICommand
|
||||
public List<Regex> Patterns => [
|
||||
new Regex(@"^abandon$", RegexOptions.IgnoreCase),
|
||||
new Regex(@"^abandon confirm$", RegexOptions.IgnoreCase)
|
||||
|
||||
];
|
||||
public string? HelpText => "Abandon your Keno Kasino gambler account";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ public class InsanityCommand : ICommand
|
||||
public string? HelpText => "Insanity";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
@@ -29,6 +30,7 @@ public class TwistedCommand : ICommand
|
||||
public string? HelpText => "Get it twisted";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
@@ -45,6 +47,7 @@ public class CrackedCommand : ICommand
|
||||
public string? HelpText => "Crackhead Zalgo text";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var logger = LogManager.GetCurrentClassLogger();
|
||||
@@ -67,6 +70,7 @@ public class CleanCommand : ICommand
|
||||
public string? HelpText => "How long has Bossman been clean?";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var settings =
|
||||
@@ -90,6 +94,7 @@ public class RehabCommand : ICommand
|
||||
public string? HelpText => "How long until rehab is over?";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var settings =
|
||||
@@ -121,6 +126,7 @@ public class NextPoVisitCommand : ICommand
|
||||
public string? HelpText => "How long until the next PO visit?";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(120);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var time = await SettingsProvider.GetValueAsync(BuiltIn.Keys.BotPoNextVisit);
|
||||
@@ -160,6 +166,7 @@ public class NextCourtHearingCommand : ICommand
|
||||
public string? HelpText => "How long until the next court hearing?";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(120);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var hearings = (await SettingsProvider.GetValueAsync(BuiltIn.Keys.BotCourtCalendar)).JsonDeserialize<List<CourtHearingModel>>();
|
||||
@@ -215,6 +222,7 @@ public class JailCommand : ICommand
|
||||
public string? HelpText => "How long has Bossman been in jail?";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var settings = await SettingsProvider.GetMultipleValuesAsync([BuiltIn.Keys.BotJailStartTime, BuiltIn.Keys.TwitchBossmanJackUsername]);
|
||||
@@ -235,6 +243,7 @@ public class LastStreamCommand : ICommand
|
||||
public string? HelpText => "How long ago did Austin Gambles last stream (on Twitch)?";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
||||
@@ -270,6 +279,7 @@ public class AlmanacCommand : ICommand
|
||||
public string? HelpText => "Return details on how to submit almanac entries";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var text = await SettingsProvider.GetValueAsync(BuiltIn.Keys.BotAlmanacText);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Humanizer;
|
||||
using Humanizer.Localisation;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetBot.Settings;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
@@ -15,6 +16,7 @@ public class MomCommand : ICommand
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(60);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Humanizer;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetBot.Settings;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
@@ -15,6 +16,7 @@ public class RainbetStatsCommand : ICommand
|
||||
public string? HelpText => "Get betting statistics in the given window";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var window = Convert.ToInt32(arguments["window"].Value);
|
||||
@@ -41,6 +43,7 @@ public class RainbetRecentBetCommand : ICommand
|
||||
public string? HelpText => "Get the most recent 3 bets";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var settings = await SettingsProvider.GetMultipleValuesAsync([
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetBot.Settings;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
@@ -15,7 +16,7 @@ public class GetRestreamCommand : ICommand
|
||||
public string? HelpText => "Grab restream URL";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class SetRestreamCommand : ICommand
|
||||
public string? HelpText => "Set restream URL";
|
||||
public UserRight RequiredRight => UserRight.TrueAndHonest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -51,7 +52,7 @@ public class SelfPromoCommand : ICommand
|
||||
public string? HelpText => "Promote your shit";
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
@@ -80,7 +81,7 @@ public class GetRestreamPlainCommand : ICommand
|
||||
public string? HelpText => "Grab restream URL with plain prefixed";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ public class EditTestCommand : ICommand
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
// Increased timeout as it has to wait for Sneedchat to echo the message and that can be slow sometimes
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(60);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var logger = LogManager.GetCurrentClassLogger();
|
||||
@@ -63,6 +64,7 @@ public class TimeoutTestCommand : ICommand
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
// Increased timeout as it has to wait for Sneedchat to echo the message and that can be slow sometimes
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(15);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMinutes(1), ctx);
|
||||
@@ -79,6 +81,7 @@ public class ExceptionTestCommand : ICommand
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
// Increased timeout as it has to wait for Sneedchat to echo the message and that can be slow sometimes
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(15);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
throw new Exception("Caused by the test exception command");
|
||||
@@ -95,6 +98,7 @@ public class LengthLimitTestCommand : ICommand
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
// Increased timeout as it has to wait for Sneedchat to echo the message and that can be slow sometimes
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(15);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var logger = LogManager.GetCurrentClassLogger();
|
||||
@@ -110,13 +114,34 @@ public class LengthLimitTestCommand : ICommand
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), ctx);
|
||||
logger.Info($"niceTruncation => {niceTruncation.Status}; exactTruncation => {exactTruncation.Status}; doNothing => {doNothing.Status}; refuseToSend => {refuseToSend.Status}");
|
||||
if (niceTruncation.ChatMessageId != null)
|
||||
botInstance.KfClient.DeleteMessage(niceTruncation.ChatMessageId.Value);
|
||||
await botInstance.KfClient.DeleteMessageAsync(niceTruncation.ChatMessageId.Value);
|
||||
if (exactTruncation.ChatMessageId != null)
|
||||
botInstance.KfClient.DeleteMessage(exactTruncation.ChatMessageId.Value);
|
||||
await botInstance.KfClient.DeleteMessageAsync(exactTruncation.ChatMessageId.Value);
|
||||
if (doNothing.ChatMessageId != null)
|
||||
botInstance.KfClient.DeleteMessage(doNothing.ChatMessageId.Value);
|
||||
await botInstance.KfClient.DeleteMessageAsync(doNothing.ChatMessageId.Value);
|
||||
// Should never happen
|
||||
if (refuseToSend.ChatMessageId != null)
|
||||
botInstance.KfClient.DeleteMessage(refuseToSend.ChatMessageId.Value);
|
||||
await botInstance.KfClient.DeleteMessageAsync(refuseToSend.ChatMessageId.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public class RateLimitTestCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [
|
||||
new Regex("^test ratelimit$")
|
||||
];
|
||||
|
||||
public string? HelpText => null;
|
||||
public UserRight RequiredRight => UserRight.Admin;
|
||||
// Increased timeout as it has to wait for Sneedchat to echo the message and that can be slow sometimes
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(15);
|
||||
public RateLimitOptionsModel? RateLimitOptions => new RateLimitOptionsModel
|
||||
{
|
||||
MaxInvocations = 1,
|
||||
Window = TimeSpan.FromSeconds(60)
|
||||
};
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
await botInstance.SendChatMessageAsync("Nigger", true);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
|
||||
@@ -7,9 +8,10 @@ namespace KfChatDotNetBot.Commands;
|
||||
public class TimeCommand : ICommand
|
||||
{
|
||||
public List<Regex> Patterns => [new Regex("^time")];
|
||||
public string? HelpText => "Get current time in AGT";
|
||||
public string? HelpText => "Get current time in BMT";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var bmt = new DateTimeOffset(TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
|
||||
@@ -14,6 +15,7 @@ public class TempEnableDiscordRelayingCommand : ICommand
|
||||
public string? HelpText => null;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
botInstance.BotServices.TemporarilyBypassGambaSeshForDiscord = true;
|
||||
@@ -30,6 +32,7 @@ public class TempSuppressGambaMessages : ICommand
|
||||
public string? HelpText => null;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
botInstance.BotServices.TemporarilySuppressGambaMessages = true;
|
||||
@@ -46,6 +49,7 @@ public class EnableGambaMessages : ICommand
|
||||
public string? HelpText => null;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
botInstance.BotServices.TemporarilySuppressGambaMessages = false;
|
||||
@@ -62,6 +66,7 @@ public class GetVersionCommand : ICommand
|
||||
public string? HelpText => null;
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
var version = Assembly.GetEntryAssembly()?
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetWsClient.Models.Events;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -15,6 +16,7 @@ public class WhoisCommand : ICommand
|
||||
public string? HelpText => "Lookup user IDs by username";
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public RateLimitOptionsModel? RateLimitOptions => null;
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
await using var db = new ApplicationDbContext();
|
||||
|
||||
Reference in New Issue
Block a user