Add global error handling for commands

This commit is contained in:
deadcade 2022-06-12 12:34:26 +02:00
parent 83b7f55399
commit 6940a194d0

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"] 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"]): if command in settings["command_list"] or (admin and command in settings["admin_command_list"]):
command_function = globals()[command] command_function = globals()[command]
if debug:
await command_function(args, room, event) 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 return
if admin: if admin:
# If it is not a command, process regular message parsing. # If it is not a command, process regular message parsing.