using Content.Shared.Database;
using Robust.Shared.Configuration;
using Robust.Shared.Player;
namespace Content.Shared.Players.RateLimiting;
///
/// Contains all data necessary to register a rate limit with .
///
public sealed class RateLimitRegistration(
CVarDef cVarLimitPeriodLength,
CVarDef cVarLimitCount,
Action? playerLimitedAction,
CVarDef? cVarAdminAnnounceDelay = null,
Action? adminAnnounceAction = null,
LogType adminLogType = LogType.RateLimited)
{
///
/// CVar that controls the period over which the rate limit is counted, measured in seconds.
///
public readonly CVarDef CVarLimitPeriodLength = cVarLimitPeriodLength;
///
/// CVar that controls how many actions are allowed in a single rate limit period.
///
public readonly CVarDef CVarLimitCount = cVarLimitCount;
///
/// An action that gets invoked when this rate limit has been breached by a player.
///
///
/// This can be used for informing players or taking administrative action.
///
public readonly Action? PlayerLimitedAction = playerLimitedAction;
///
/// CVar that controls the minimum delay between admin notifications, measured in seconds.
/// This can be omitted to have no admin notification system.
/// If the cvar is set to 0, there every breach will be reported.
/// If the cvar is set to a negative number, admin announcements are disabled.
///
///
/// If set, must be set too.
///
public readonly CVarDef? CVarAdminAnnounceDelay = cVarAdminAnnounceDelay;
///
/// An action that gets invoked when a rate limit was breached and admins should be notified.
///
///
/// If set, must be set too.
///
public readonly Action? AdminAnnounceAction = adminAnnounceAction;
///
/// Log type used to log rate limit violations to the admin logs system.
///
public readonly LogType AdminLogType = adminLogType;
}
///
/// Result of a rate-limited operation.
///
///
public enum RateLimitStatus : byte
{
///
/// The action was not blocked by the rate limit.
///
Allowed,
///
/// The action was blocked by the rate limit.
///
Blocked,
}