using Robust.Shared.Player; namespace Content.Shared.Players.RateLimiting; /// /// General-purpose system to rate limit actions taken by clients, such as chat messages. /// /// /// /// Different categories of rate limits must be registered ahead of time by calling . /// Once registered, you can simply call to count a rate-limited action for a player. /// /// /// This system is intended for rate limiting player actions over short periods, /// to ward against spam that can cause technical issues such as admin client load. /// It should not be used for in-game actions or similar. /// /// /// Rate limits are reset when a client reconnects. /// This should not be an issue for the reasonably short rate limit periods this system is intended for. /// /// /// public abstract class SharedPlayerRateLimitManager { /// /// Count and validate an action performed by a player against rate limits. /// /// The player performing the action. /// The key string that was previously used to register a rate limit category. /// Whether the action counted should be blocked due to surpassing rate limits or not. /// /// is not a connected player /// OR is not a registered rate limit category. /// /// public abstract RateLimitStatus CountAction(ICommonSession player, string key); /// /// Register a new rate limit category. /// /// /// The key string that will be referred to later with . /// Must be unique and should probably just be a constant somewhere. /// /// The data specifying the rate limit's parameters. /// has already been registered. /// is invalid. public abstract void Register(string key, RateLimitRegistration registration); /// /// Initialize the manager's functionality at game startup. /// public abstract void Initialize(); }