diff --git a/matrix/buffer.py b/matrix/buffer.py index 3b588c5..57ff631 100644 --- a/matrix/buffer.py +++ b/matrix/buffer.py @@ -33,6 +33,7 @@ from nio import ( RoomMessage, RoomMessageEmote, RoomMessageMedia, + RoomEncryptedMedia, RoomMessageNotice, RoomMessageText, RoomMessageUnknown, @@ -1151,6 +1152,31 @@ class RoomBuffer(object): nick, data, date, self.get_event_tags(event), extra_prefix ) + elif isinstance(event, RoomEncryptedMedia): + nick = self.find_nick(event.sender) + date = server_ts_to_weechat(event.server_timestamp) + http_url = Api.encrypted_mxc_to_plumb( + event.url, + event.key["k"], + event.hashes["sha256"], + event.iv + ) + url = http_url if http_url else event.url + + description = "{}".format(event.body) if event.body else "file" + data = ("{del_color}<{ncolor}{desc}{del_color}>{ncolor} " + "{del_color}[{ncolor}{url}{del_color}]{ncolor}").format( + del_color=W.color("chat_delimiters"), + ncolor=W.color("reset"), + desc=description, url=url) + + extra_prefix = (self.warning_prefix if event.decrypted + and not event.verified else "") + + self.weechat_buffer.message( + nick, data, date, self.get_event_tags(event), extra_prefix + ) + elif isinstance(event, RoomMessageUnknown): nick = self.find_nick(event.sender) date = server_ts_to_weechat(event.server_timestamp)