fix(matrixbot): bring live ATM10 edits into the repo #70
+38
-17
@@ -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 <command>)")
|
||||
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)
|
||||
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 = ['<font color="#a855f7"><strong>🌸 LotusBot — Commands</strong></font>']
|
||||
|
||||
plain_lines = [f"LotusBot commands ({BOT_PREFIX}help <command> for details)"]
|
||||
html_parts = [
|
||||
'<font color="#a855f7"><strong>🌸 LotusBot — Commands</strong></font>'
|
||||
f"<br><sup><em>{BOT_PREFIX}help <command> for details</em></sup>"
|
||||
]
|
||||
for cat_name, cmd_names in categories:
|
||||
plain_lines.append(f"\n{cat_name}")
|
||||
html_parts.append(f"<br><strong>{cat_name}</strong><ul>")
|
||||
for name in cmd_names:
|
||||
if name in COMMANDS:
|
||||
_, desc = COMMANDS[name]
|
||||
plain_lines.append(f" {BOT_PREFIX}{name} — {desc}")
|
||||
html_parts.append(f"<li><strong>{BOT_PREFIX}{name}</strong> — {desc}</li>")
|
||||
html_parts.append("</ul>")
|
||||
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"<br><strong>{cat_name}:</strong> " + " ".join(f"<code>{n}</code>" 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"✅ <strong>{username}</strong> 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'<font color="#980000"><strong>✿ Minecraft — Lotus SMP ✿</strong></font><br>'
|
||||
f'<font color="#980000"><strong>✿ Lotus Minecraft Server ✿</strong></font><br>'
|
||||
f"<blockquote>"
|
||||
f"{status_line}<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>"
|
||||
)
|
||||
await send_html(client, room_id, plain, html)
|
||||
|
||||
Reference in new issue
Block a user