Skip to content

Commit 697e4e9

Browse files
committed
Make sure command aliases respect is_enabled_for as well
1 parent 7b9af88 commit 697e4e9

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

mautrix/bridge/commands/handler.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -395,20 +395,16 @@ async def handle(self, room_id: RoomID, event_id: EventID, sender: BaseUser,
395395
is_management=is_management, has_bridge_bot=has_bridge_bot)
396396
orig_command = command
397397
command = command.lower()
398-
try:
399-
handler = command_handlers[command]
400-
if not handler.is_enabled_for(evt):
401-
raise KeyError()
402-
except KeyError:
403-
try:
404-
handler = command_aliases[command]
405-
except KeyError:
406-
if sender.command_status and "next" in sender.command_status:
407-
args.insert(0, orig_command)
408-
evt.command = ""
409-
handler = sender.command_status["next"]
410-
else:
411-
handler = command_handlers["unknown-command"]
398+
399+
handler = command_handlers.get(command) or command_aliases.get(command)
400+
if handler is None or not handler.is_enabled_for(evt):
401+
if sender.command_status and "next" in sender.command_status:
402+
args.insert(0, orig_command)
403+
evt.command = ""
404+
handler = sender.command_status["next"]
405+
else:
406+
handler = command_handlers["unknown-command"]
407+
412408
try:
413409
await self._run_handler(handler, evt)
414410
except Exception:

0 commit comments

Comments
 (0)