feat: bypass !ask cooldown for users with power level >= 50
Lint / Shell (shellcheck) (push) Successful in 8s
Lint / JS (eslint) (push) Successful in 7s
Lint / Python (ruff) (push) Successful in 4s
Lint / Python deps (pip-audit) (push) Successful in 41s
Lint / Secret scan (gitleaks) (push) Successful in 5s

Add is_elevated() helper that reads the room power level from the nio
client store. Users at PL50+ (Nerdy Council and above) skip the cooldown
check entirely. The timestamp is still recorded so cooldown applies
if their power level is later reduced below 50.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-28 21:39:44 -04:00
parent 37f5d2d70d
commit 66136ff2f7
+16 -4
View File
@@ -107,6 +107,14 @@ def check_cooldown(sender: str, cmd_name: str, seconds: int = COOLDOWN_SECONDS)
return 0
def is_elevated(client: AsyncClient, room_id: str, user_id: str, min_level: int = 50) -> bool:
"""Return True if the user has a power level >= min_level in the room."""
room = client.rooms.get(room_id)
if not room:
return False
return room.power_levels.get_user_level(user_id) >= min_level
# ==================== COMMANDS ====================
@@ -1216,10 +1224,14 @@ async def cmd_ask(client: AsyncClient, room_id: str, sender: str, args: str):
return
model = resolved
remaining = check_cooldown(sender, "ask")
if remaining:
await send_text(client, room_id, f"Command on cooldown. Try again in {remaining}s.")
return
if not is_elevated(client, room_id, sender):
remaining = check_cooldown(sender, "ask")
if remaining:
await send_text(client, room_id, f"Command on cooldown. Try again in {remaining}s.")
return
else:
# Still record the timestamp so cooldown kicks in if they drop below PL50
check_cooldown(sender, "ask")
question = sanitize_input(args)
if not question: