fix(matrixbot): bring live ATM10 edits into the repo
Lint / Shell (shellcheck) (pull_request) Successful in 8s
Lint / JS (eslint) (pull_request) Successful in 8s
Lint / No Hookshot webhook IDs in README (pull_request) Successful in 7s
Lint / No secrets in webhook configs (pull_request) Successful in 5s
Lint / Landing page is rendered (matrix (pull_request) Successful in 4s
Lint / Python (ruff) (pull_request) Successful in 5s
Lint / Python deps (pip-audit) (pull_request) Successful in 1m2s
Lint / Secret scan (gitleaks) (pull_request) Successful in 13s
Lint / JS (eslint) (push) Successful in 8s
Lint / Shell (shellcheck) (push) Successful in 11s
Lint / No Hookshot webhook IDs in README (push) Successful in 6s
Lint / No secrets in webhook configs (push) Successful in 6s
Lint / Landing page is rendered (matrix (push) Successful in 10s
Lint / Python (ruff) (push) Successful in 10s
Lint / Secret scan (gitleaks) (push) Successful in 12s
Lint / Python deps (pip-audit) (push) Successful in 38s

These changes were made directly on CT151 (2026-10-30 to 11-01) and never
committed, so the auto-deploy triggered by b18aae8 on 2026-11-18 overwrote
them. Restored live on 2026-11-19; this commits them so the next deploy
keeps them.

- !minecraft: 60 s per-user cooldown, audit log line, clear message when the
  Minecraft account doesn't exist
- !minecraft reply: Lotus Minecraft Server / All the Mods 10 8.6 (was the
  old Paper "Lotus SMP, fresh world, hard mode" text)
- !help: compact list with !help <command> for details, since the Discord
  bridge drops messages over 2000 characters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQ9u9cUsWuUQN791N3JzFG
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-19 20:49:15 -05:00
1 parent 7c497d2a0a
commit 71054d2778
1 file changed
+38 -17
+38 -17
View File
@@ -120,8 +120,19 @@ def is_elevated(client: AsyncClient, room_id: str, user_id: str, min_level: int
# ==================== COMMANDS ==================== # ==================== COMMANDS ====================
@command("help", "Show all available commands") @command("help", "Show all commands, or details for one (!help <command>)")
async def cmd_help(client: AsyncClient, room_id: str, sender: str, args: str): async def cmd_help(client: AsyncClient, room_id: str, sender: str, args: str):
# Compact on purpose: the Discord bridge drops messages over 2000 characters.
query = args.strip().lstrip(BOT_PREFIX).lower()
if query:
entry = COMMANDS.get(query)
if entry is None:
await send_text(client, room_id, f"Unknown command: {BOT_PREFIX}{query}. Try {BOT_PREFIX}help for the list.")
return
_, desc = entry
await send_html(client, room_id, f"{BOT_PREFIX}{query} — {desc}", f"<strong>{BOT_PREFIX}{query}</strong> — {desc}")
return
elevated = is_elevated(client, room_id, sender) elevated = is_elevated(client, room_id, sender)
categories = [ categories = [
("🤖 AI / Fun", ["ask", "fortune", "8ball", "roast", "story", "debate"]), ("🤖 AI / Fun", ["ask", "fortune", "8ball", "roast", "story", "debate"]),
@@ -148,18 +159,17 @@ async def cmd_help(client: AsyncClient, room_id: str, sender: str, args: str):
"setpl", "kick", "purge", "members", "whois", "announce", "syncspace", "setpl", "kick", "purge", "members", "whois", "announce", "syncspace",
])) ]))
plain_lines = ["LotusBot Commands"] plain_lines = [f"LotusBot commands ({BOT_PREFIX}help <command> for details)"]
html_parts = ['<font color="#a855f7"><strong>🌸 LotusBot — Commands</strong></font>'] html_parts = [
'<font color="#a855f7"><strong>🌸 LotusBot — Commands</strong></font>'
f"<br><sup><em>{BOT_PREFIX}help &lt;command&gt; for details</em></sup>"
]
for cat_name, cmd_names in categories: for cat_name, cmd_names in categories:
plain_lines.append(f"\n{cat_name}") names = [f"{BOT_PREFIX}{name}" for name in cmd_names if name in COMMANDS]
html_parts.append(f"<br><strong>{cat_name}</strong><ul>") if not names:
for name in cmd_names: continue
if name in COMMANDS: plain_lines.append(f"{cat_name}: " + " ".join(names))
_, desc = COMMANDS[name] html_parts.append(f"<br><strong>{cat_name}:</strong> " + " ".join(f"<code>{n}</code>" for n in names))
plain_lines.append(f" {BOT_PREFIX}{name} — {desc}")
html_parts.append(f"<li><strong>{BOT_PREFIX}{name}</strong> — {desc}</li>")
html_parts.append("</ul>")
await send_html(client, room_id, "\n".join(plain_lines), "".join(html_parts)) await send_html(client, room_id, "\n".join(plain_lines), "".join(html_parts))
@@ -1313,6 +1323,11 @@ async def cmd_minecraft(client: AsyncClient, room_id: str, sender: str, args: st
await send_text(client, room_id, "Minecraft server is not configured.") await send_text(client, room_id, "Minecraft server is not configured.")
return return
remaining = check_cooldown(sender, "minecraft", 60)
if remaining:
await send_text(client, room_id, f"Command on cooldown. Try again in {remaining}s.")
return
await send_text(client, room_id, f"Whitelisting {username}...") await send_text(client, room_id, f"Whitelisting {username}...")
try: try:
@@ -1327,7 +1342,11 @@ async def cmd_minecraft(client: AsyncClient, room_id: str, sender: str, args: st
loop = asyncio.get_running_loop() loop = asyncio.get_running_loop()
response = await asyncio.wait_for(loop.run_in_executor(None, _rcon), timeout=RCON_TIMEOUT) response = await asyncio.wait_for(loop.run_in_executor(None, _rcon), timeout=RCON_TIMEOUT)
logger.info(f"RCON response: {response}") logger.info(f"Minecraft whitelist: sender={sender} room={room_id} username={username} response={response!r}")
if "does not exist" in response.lower() or "unknown player" in response.lower():
await send_text(client, room_id, f"No Minecraft account named {username} exists. Check the spelling (Java Edition username).")
return
already = "already whitelisted" in response.lower() already = "already whitelisted" in response.lower()
status_line = ( status_line = (
@@ -1336,16 +1355,18 @@ async def cmd_minecraft(client: AsyncClient, room_id: str, sender: str, args: st
else f"✅ <strong>{username}</strong> is whitelisted and ready to join." else f"✅ <strong>{username}</strong> is whitelisted and ready to join."
) )
plain = ( plain = (
f"✿ Minecraft — Lotus SMP ✿\n" f"✿ Lotus Minecraft Server ✿\n"
f"{'Already whitelisted' if already else 'Whitelisted'}: {username}\n" f"{'Already whitelisted' if already else 'Whitelisted'}: {username}\n"
f"Server: minecraft.lotusguild.org" f"Server: minecraft.lotusguild.org\n"
f"Modpack: All the Mods 10 (CurseForge), version 8.6"
) )
html = ( html = (
f'<font color="#980000"><strong>✿ Minecraft — Lotus SMP ✿</strong></font><br>' f'<font color="#980000"><strong>✿ Lotus Minecraft Server ✿</strong></font><br>'
f"<blockquote>" f"<blockquote>"
f"{status_line}<br>" f"{status_line}<br>"
f'<strong>Server:</strong> <code>minecraft.lotusguild.org</code><br>' f'<strong>Server:</strong> <code>minecraft.lotusguild.org</code><br>'
f"<sup><em>fresh world · hard mode · no takebacks</em></sup>" f'<strong>Modpack:</strong> All the Mods 10 (CurseForge), version <code>8.6</code><br>'
f"<sup><em>install the same pack version or the server won't let you in</em></sup>"
f"</blockquote>" f"</blockquote>"
) )
await send_html(client, room_id, plain, html) await send_html(client, room_id, plain, html)