Add global error handling for commands

This commit is contained in:
deadcade 2022-06-12 12:34:26 +02:00
parent 83b7f55399
commit 6940a194d0
1 changed files with 7 additions and 1 deletions

View File

@ -272,7 +272,13 @@ async def message_callback(room: nio.MatrixRoom, event: nio.RoomMessageText) ->
ratelimits[event.sender] = int(datetime.datetime.utcnow().timestamp()) + settings["ratelimit"]
if command in settings["command_list"] or (admin and command in settings["admin_command_list"]):
command_function = globals()[command]
await command_function(args, room, event)
if debug:
await command_function(args, room, event)
else:
try:
await command_function(args, room, event)
except Exception:
await send_text(room.room_id, "Something went wrong processing the command!")
return
if admin:
# If it is not a command, process regular message parsing.