commands: Add redaction support back.
This commit is contained in:
parent
166ff3b2e3
commit
607aad655b
2 changed files with 29 additions and 24 deletions
|
@ -91,23 +91,23 @@ def hook_commands():
|
||||||
'matrix_command_cb',
|
'matrix_command_cb',
|
||||||
'')
|
'')
|
||||||
|
|
||||||
# W.hook_command(
|
W.hook_command(
|
||||||
# # Command name and short description
|
# Command name and short description
|
||||||
# 'redact',
|
'redact',
|
||||||
# 'redact messages',
|
'redact messages',
|
||||||
# # Synopsis
|
# Synopsis
|
||||||
# ('<message-number>[:"<message-part>"] [<reason>]'),
|
('<message-number>[:"<message-part>"] [<reason>]'),
|
||||||
# # Description
|
# Description
|
||||||
# ("message-number: number of message to redact (starting from 1 for\n"
|
("message-number: number of message to redact (starting from 1 for\n"
|
||||||
# " the last message received, counting up)\n"
|
" the last message received, counting up)\n"
|
||||||
# " message-part: an initial part of the message (ignored, only used\n"
|
" message-part: an initial part of the message (ignored, only used\n"
|
||||||
# " as visual feedback when using completion)\n"
|
" as visual feedback when using completion)\n"
|
||||||
# " reason: the redaction reason\n"),
|
" reason: the redaction reason\n"),
|
||||||
# # Completions
|
# Completions
|
||||||
# ('%(matrix_messages)'),
|
('%(matrix_messages)'),
|
||||||
# # Function name
|
# Function name
|
||||||
# 'matrix_redact_command_cb',
|
'matrix_redact_command_cb',
|
||||||
# '')
|
'')
|
||||||
|
|
||||||
W.hook_command(
|
W.hook_command(
|
||||||
# Command name and short description
|
# Command name and short description
|
||||||
|
@ -434,12 +434,13 @@ def event_id_from_line(buf, target_number):
|
||||||
def matrix_redact_command_cb(data, buffer, args):
|
def matrix_redact_command_cb(data, buffer, args):
|
||||||
for server in SERVERS.values():
|
for server in SERVERS.values():
|
||||||
if buffer in server.buffers.values():
|
if buffer in server.buffers.values():
|
||||||
room_id = key_from_value(server.buffers, buffer)
|
room_buffer = server.find_room_from_ptr(buffer)
|
||||||
|
|
||||||
matches = re.match(r"(\d+)(:\".*\")? ?(.*)?", args)
|
matches = re.match(r"(\d+)(:\".*\")? ?(.*)?", args)
|
||||||
|
|
||||||
if not matches:
|
if not matches:
|
||||||
message = ("{prefix}matrix: Invalid command arguments (see /help redact)"
|
message = ("{prefix}matrix: Invalid command "
|
||||||
|
"arguments (see /help redact)"
|
||||||
).format(prefix=W.prefix("error"))
|
).format(prefix=W.prefix("error"))
|
||||||
W.prnt("", message)
|
W.prnt("", message)
|
||||||
return W.WEECHAT_RC_ERROR
|
return W.WEECHAT_RC_ERROR
|
||||||
|
@ -456,7 +457,7 @@ def matrix_redact_command_cb(data, buffer, args):
|
||||||
W.prnt("", message)
|
W.prnt("", message)
|
||||||
return W.WEECHAT_RC_OK
|
return W.WEECHAT_RC_OK
|
||||||
|
|
||||||
raise NotImplementedError
|
server.room_send_redaction(room_buffer, event_id, reason)
|
||||||
|
|
||||||
return W.WEECHAT_RC_OK
|
return W.WEECHAT_RC_OK
|
||||||
|
|
||||||
|
|
|
@ -508,6 +508,13 @@ class MatrixServer(object):
|
||||||
)
|
)
|
||||||
self.send_or_queue(request)
|
self.send_or_queue(request)
|
||||||
|
|
||||||
|
def room_send_redaction(self, room_buffer, event_id, reason=None):
|
||||||
|
_, request = self.client.room_redact(
|
||||||
|
room_buffer.room.room_id,
|
||||||
|
event_id,
|
||||||
|
reason)
|
||||||
|
self.send_or_queue(request)
|
||||||
|
|
||||||
def room_send_message(self, room_buffer, formatted, msgtype="m.text"):
|
def room_send_message(self, room_buffer, formatted, msgtype="m.text"):
|
||||||
# type: (RoomBuffer, Formatted, str) -> None
|
# type: (RoomBuffer, Formatted, str) -> None
|
||||||
if room_buffer.room.encrypted:
|
if room_buffer.room.encrypted:
|
||||||
|
@ -654,9 +661,6 @@ class MatrixServer(object):
|
||||||
elif isinstance(response, RoomSendResponse):
|
elif isinstance(response, RoomSendResponse):
|
||||||
self.handle_own_messages(response)
|
self.handle_own_messages(response)
|
||||||
|
|
||||||
elif isinstance(response, RoomPutStateResponse):
|
|
||||||
pass
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def create_room_buffer(self, room_id):
|
def create_room_buffer(self, room_id):
|
||||||
|
|
Loading…
Add table
Reference in a new issue