From 6940a194d00efc367d5aee4a157638695d7cfb19 Mon Sep 17 00:00:00 2001 From: deadcade Date: Sun, 12 Jun 2022 12:34:26 +0200 Subject: [PATCH] Add global error handling for commands --- main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 8c60670..0c06d63 100644 --- a/main.py +++ b/main.py @@ -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.