From 71054d2778d9167b69a83813db31549a9ca7d8cf Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Thu, 19 Nov 2026 20:49:15 -0500 Subject: [PATCH] fix(matrixbot): bring live ATM10 edits into the repo 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 for details, since the Discord bridge drops messages over 2000 characters Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KQ9u9cUsWuUQN791N3JzFG --- matrixbot/commands.py | 55 ++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/matrixbot/commands.py b/matrixbot/commands.py index 8490946..2ee7761 100644 --- a/matrixbot/commands.py +++ b/matrixbot/commands.py @@ -120,8 +120,19 @@ def is_elevated(client: AsyncClient, room_id: str, user_id: str, min_level: int # ==================== COMMANDS ==================== -@command("help", "Show all available commands") +@command("help", "Show all commands, or details for one (!help )") 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"{BOT_PREFIX}{query} — {desc}") + return + elevated = is_elevated(client, room_id, sender) categories = [ ("🤖 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", ])) - plain_lines = ["LotusBot Commands"] - html_parts = ['🌸 LotusBot — Commands'] - + plain_lines = [f"LotusBot commands ({BOT_PREFIX}help for details)"] + html_parts = [ + '🌸 LotusBot — Commands' + f"
{BOT_PREFIX}help <command> for details" + ] for cat_name, cmd_names in categories: - plain_lines.append(f"\n{cat_name}") - html_parts.append(f"
{cat_name}
    ") - for name in cmd_names: - if name in COMMANDS: - _, desc = COMMANDS[name] - plain_lines.append(f" {BOT_PREFIX}{name} — {desc}") - html_parts.append(f"
  • {BOT_PREFIX}{name} — {desc}
  • ") - html_parts.append("
") + names = [f"{BOT_PREFIX}{name}" for name in cmd_names if name in COMMANDS] + if not names: + continue + plain_lines.append(f"{cat_name}: " + " ".join(names)) + html_parts.append(f"
{cat_name}: " + " ".join(f"{n}" for n in names)) 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.") 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}...") try: @@ -1327,7 +1342,11 @@ async def cmd_minecraft(client: AsyncClient, room_id: str, sender: str, args: st loop = asyncio.get_running_loop() 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() status_line = ( @@ -1336,16 +1355,18 @@ async def cmd_minecraft(client: AsyncClient, room_id: str, sender: str, args: st else f"✅ {username} is whitelisted and ready to join." ) plain = ( - f"✿ Minecraft — Lotus SMP ✿\n" + f"✿ Lotus Minecraft Server ✿\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 = ( - f'✿ Minecraft — Lotus SMP ✿
' + f'✿ Lotus Minecraft Server ✿
' f"
" f"{status_line}
" f'Server: minecraft.lotusguild.org
' - f"fresh world · hard mode · no takebacks" + f'Modpack: All the Mods 10 (CurseForge), version 8.6
' + f"install the same pack version or the server won't let you in" f"
" ) await send_html(client, room_id, plain, html) -- 2.47.3