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
|
public RateLimitOptionsModel? RateLimitOptions => new RateLimitOptionsModel
|
||||||
{
|
{
|
||||||
MaxInvocations = 1,
|
MaxInvocations = 1,
|
||||||
Window = TimeSpan.FromSeconds(30),
|
Window = TimeSpan.FromSeconds(30)
|
||||||
Flags = RateLimitFlags.AutoDeleteCooldownResponse
|
|
||||||
};
|
};
|
||||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||||
CancellationToken ctx)
|
CancellationToken ctx)
|
||||||
@@ -182,8 +181,7 @@ public class LossbackCommand : ICommand
|
|||||||
public RateLimitOptionsModel? RateLimitOptions => new RateLimitOptionsModel
|
public RateLimitOptionsModel? RateLimitOptions => new RateLimitOptionsModel
|
||||||
{
|
{
|
||||||
Window = TimeSpan.FromSeconds(30),
|
Window = TimeSpan.FromSeconds(30),
|
||||||
MaxInvocations = 1,
|
MaxInvocations = 1
|
||||||
Flags = RateLimitFlags.AutoDeleteCooldownResponse
|
|
||||||
};
|
};
|
||||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||||
CancellationToken ctx)
|
CancellationToken ctx)
|
||||||
|
|||||||
@@ -76,8 +76,7 @@ public enum RateLimitFlags
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
ExemptPrivilegedUsers,
|
ExemptPrivilegedUsers,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Automatically clean up the cooldown response sent to a user
|
/// Do not automatically clean up the cooldown response sent to a user
|
||||||
/// Mutually exclusive with NoResponse
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
AutoDeleteCooldownResponse
|
NoAutoDeleteCooldownResponse
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ internal class BotCommands
|
|||||||
if (options.Flags.HasFlag(RateLimitFlags.NoResponse)) return;
|
if (options.Flags.HasFlag(RateLimitFlags.NoResponse)) return;
|
||||||
var timeRemaining = oldestEntryExpires - DateTimeOffset.UtcNow;
|
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);
|
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;
|
var i = 0;
|
||||||
while (message.ChatMessageId == null)
|
while (message.ChatMessageId == null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user