From 44c73b7cadec2db5b55a24c7e5848e856efa6ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Fri, 12 Jan 2018 16:38:02 +0100 Subject: [PATCH] Error messages for the /redact command. --- weechat-matrix.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/weechat-matrix.py b/weechat-matrix.py index e8dceae..7a09463 100644 --- a/weechat-matrix.py +++ b/weechat-matrix.py @@ -1826,7 +1826,6 @@ def matrix_command_topic_cb(data, buffer, command): if len(split_command) == 2: topic = split_command[1] - # TODO print out topic in channel if not topic: room = server.rooms[room_id] if room.topic: @@ -1941,6 +1940,10 @@ def matrix_redact_command_cb(data, buffer, args): matches = re.match(r"(\d+)(:\".*\")? ?(.*)?", args) if not matches: + message = ("{prefix}matrix: Invalid command arguments (see " + "the help for the command /help redact)").format( + prefix=W.prefix("error")) + W.prnt("", message) return W.WEECHAT_RC_ERROR line_string, _, reason = matches.groups() @@ -1952,7 +1955,12 @@ def matrix_redact_command_cb(data, buffer, args): event_id = event_id_from_line(buffer, line) if not event_id: - print("EERRRRRORRRR") + message = ("{prefix}matrix: No such message with number " + "{number} found").format( + prefix=W.prefix("error"), + number=line) + W.prnt("", message) + return W.WEECHAT_RC_OK message = MatrixMessage( server, @@ -1963,13 +1971,13 @@ def matrix_redact_command_cb(data, buffer, args): ) send_or_queue(server, message) - return W.WEECHAT_RC_OK_EAT + return W.WEECHAT_RC_OK elif buffer == server.server_buffer: message = ("{prefix}matrix: command \"redact\" must be " "executed on a Matrix channel buffer").format( prefix=W.prefix("error")) - W.prnt(buffer, message) + W.prnt("", message) return W.WEECHAT_RC_OK return W.WEECHAT_RC_OK