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:
@@ -3,7 +3,7 @@ from functools import wraps
|
||||
|
||||
from nio import AsyncClient
|
||||
|
||||
from config import BOT_PREFIX, MATRIX_USER_ID
|
||||
from config import BOT_PREFIX, COMMAND_ROOMS, MATRIX_USER_ID
|
||||
from commands import (
|
||||
COMMANDS,
|
||||
metrics,
|
||||
@@ -50,6 +50,12 @@ class Callbacks:
|
||||
if event.sender == MATRIX_USER_ID:
|
||||
return
|
||||
|
||||
# Only act in designated command rooms. This covers both prefixed
|
||||
# commands and the passive game-answer checks below, so the bot never
|
||||
# speaks in public rooms such as #general. "*" allows every room.
|
||||
if "*" not in COMMAND_ROOMS and room.room_id not in COMMAND_ROOMS:
|
||||
return
|
||||
|
||||
body = event.body.strip() if event.body else ""
|
||||
|
||||
# Check active non-command games that monitor all room messages
|
||||
|
||||
Reference in New Issue
Block a user