mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Inverted cooldown cleanup behavior
This commit is contained in:
@@ -128,8 +128,7 @@ public class RakebackCommand : ICommand
|
||||
public RateLimitOptionsModel? RateLimitOptions => new RateLimitOptionsModel
|
||||
{
|
||||
MaxInvocations = 1,
|
||||
Window = TimeSpan.FromSeconds(30),
|
||||
Flags = RateLimitFlags.AutoDeleteCooldownResponse
|
||||
Window = TimeSpan.FromSeconds(30)
|
||||
};
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
@@ -182,8 +181,7 @@ public class LossbackCommand : ICommand
|
||||
public RateLimitOptionsModel? RateLimitOptions => new RateLimitOptionsModel
|
||||
{
|
||||
Window = TimeSpan.FromSeconds(30),
|
||||
MaxInvocations = 1,
|
||||
Flags = RateLimitFlags.AutoDeleteCooldownResponse
|
||||
MaxInvocations = 1
|
||||
};
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||
CancellationToken ctx)
|
||||
|
||||
@@ -76,8 +76,7 @@ public enum RateLimitFlags
|
||||
/// </summary>
|
||||
ExemptPrivilegedUsers,
|
||||
/// <summary>
|
||||
/// Automatically clean up the cooldown response sent to a user
|
||||
/// Mutually exclusive with NoResponse
|
||||
/// Do not automatically clean up the cooldown response sent to a user
|
||||
/// </summary>
|
||||
AutoDeleteCooldownResponse
|
||||
NoAutoDeleteCooldownResponse
|
||||
}
|
||||
@@ -158,7 +158,7 @@ internal class BotCommands
|
||||
if (options.Flags.HasFlag(RateLimitFlags.NoResponse)) return;
|
||||
var timeRemaining = oldestEntryExpires - DateTimeOffset.UtcNow;
|
||||
var message = await _bot.SendChatMessageAsync($"{user.FormatUsername()}, please wait {timeRemaining.Humanize(maxUnit: TimeUnit.Minute, minUnit: TimeUnit.Millisecond, precision: 2)} before attempting to run {commandName} again.", true);
|
||||
if (!options.Flags.HasFlag(RateLimitFlags.AutoDeleteCooldownResponse)) return;
|
||||
if (options.Flags.HasFlag(RateLimitFlags.NoAutoDeleteCooldownResponse)) return;
|
||||
var i = 0;
|
||||
while (message.ChatMessageId == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user