chatops.ratelimit module

Rate-limit utilities for sensitive ChatOps commands.

  • Cooldown (seconds) per user+command, defaults to 5 seconds

  • Configured via ENV SENSITIVE_COMMAND_COOLDOWN_SEC

  • Decorator: limit_sensitive(command_name)

class chatops.ratelimit.SensitiveCommandRateLimiter(cooldown_sec=5)[source]

Bases: object

Parameters:

cooldown_sec (int)

__init__(cooldown_sec=5)[source]
Parameters:

cooldown_sec (int)

Return type:

None

property cooldown_sec: int
async should_allow(user_id, command_name)[source]
Return type:

Tuple[bool, int]

Parameters:
  • user_id (int)

  • command_name (str)

chatops.ratelimit.limit_sensitive(command_name)[source]

Decorator to throttle sensitive command handlers per user.

Return type:

Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]

Parameters:

command_name (str)