feat(matrixbot): stop auto-joining invites, restrict commands to two rooms
#general is now published to the public room directory, so the bot is reachable by strangers. Two hardening changes: - Invites are only accepted from INVITE_ALLOWED_USERS (defaults to ADMIN_USERS). Anything else is declined via room_leave so hostile invites do not accumulate as pending. Previously any invite from anyone was auto-joined. - Commands and the passive scramble/riddle answer checks only run in COMMAND_ROOMS (#commands and #management). The gate sits early in Callbacks.message, so the bot stays silent everywhere else, including #general. Set COMMAND_ROOMS="*" to restore the old behaviour. Reaction handlers are deliberately left ungated so the welcome flow keeps working; game votes elsewhere cannot match an active game. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+17
-1
@@ -16,12 +16,28 @@ BOT_PREFIX = os.getenv("BOT_PREFIX", "!")
|
||||
ADMIN_USERS = [u.strip() for u in os.getenv("ADMIN_USERS", "").split(",") if u.strip()]
|
||||
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
|
||||
|
||||
# Rooms where commands and interactive games are allowed. The bot stays silent
|
||||
# everywhere else, so it never responds in public rooms like #general.
|
||||
# Override with a comma-separated COMMAND_ROOMS; set to "*" to allow all rooms.
|
||||
DEFAULT_COMMAND_ROOMS = (
|
||||
"!ou56mVZQ8ZB7AhDYPmBV5_BR28WMZ4x5zwZkPCqjq1s", # #commands
|
||||
"!mEvR5fe3jMmzwd-FwNygD72OY_yu8H3UP_N-57oK7MI", # #management
|
||||
)
|
||||
_command_rooms = os.getenv("COMMAND_ROOMS", ",".join(DEFAULT_COMMAND_ROOMS))
|
||||
COMMAND_ROOMS = [r.strip() for r in _command_rooms.split(",") if r.strip()]
|
||||
|
||||
# Users whose invites the bot will accept. Invites from anyone else are
|
||||
# declined: the homeserver is publicly listed, so auto-joining any invite lets
|
||||
# a stranger pull the bot into an arbitrary room. Defaults to ADMIN_USERS.
|
||||
_invite_allowed = os.getenv("INVITE_ALLOWED_USERS", "")
|
||||
INVITE_ALLOWED_USERS = [u.strip() for u in _invite_allowed.split(",") if u.strip()] or list(ADMIN_USERS)
|
||||
|
||||
# Integrations
|
||||
OLLAMA_URL = os.getenv("OLLAMA_URL", "http://10.10.10.157:11434")
|
||||
OLLAMA_MODEL = os.getenv("OLLAMA_MODEL", "phi4-mini:latest")
|
||||
CREATIVE_MODEL = os.getenv("CREATIVE_MODEL", "huihui_ai/llama3.2-abliterate:3b")
|
||||
ASK_MODEL = os.getenv("ASK_MODEL", "phi4-mini:latest")
|
||||
MINECRAFT_RCON_HOST = os.getenv("MINECRAFT_RCON_HOST", "10.10.10.67")
|
||||
MINECRAFT_RCON_HOST = os.getenv("MINECRAFT_RCON_HOST", "10.10.10.68")
|
||||
MINECRAFT_RCON_PORT = int(os.getenv("MINECRAFT_RCON_PORT", "25575"))
|
||||
MINECRAFT_RCON_PASSWORD = os.getenv("MINECRAFT_RCON_PASSWORD", "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user