diff --git a/matrix/buffer.py b/matrix/buffer.py index 1c2a9ba..c94723a 100644 --- a/matrix/buffer.py +++ b/matrix/buffer.py @@ -22,7 +22,7 @@ from builtins import super from functools import partial from typing import NamedTuple -from .globals import W, SERVERS, OPTIONS, SCRIPT_NAME, ENCRYPTION +from .globals import W, SERVERS, OPTIONS, SCRIPT_NAME from .utf import utf8_decode from .colors import Formatted from .utils import ( @@ -875,6 +875,11 @@ class RoomBuffer(object): self._handle_topic(event, True) elif isinstance(event, PowerLevelsEvent): self._handle_power_level(event) + elif isinstance(event, RoomEncryptionEvent): + message = ("This room is encrypted, encryption is " + "currently unsuported. Message sending is disabled for " + "this room.") + self.weechat_buffer.error(message) def handle_timeline_event(self, event): if isinstance(event, RoomMemberEvent): @@ -962,9 +967,6 @@ class RoomBuffer(object): self._handle_redacted_message(event) elif isinstance(event, RoomEncryptionEvent): - if ENCRYPTION: - return - message = ("This room is encrypted, encryption is " "currently unsuported. Message sending is disabled for " "this room.") diff --git a/matrix/server.py b/matrix/server.py index 323e3c7..caa9272 100644 --- a/matrix/server.py +++ b/matrix/server.py @@ -478,6 +478,9 @@ class MatrixServer(object): W.prnt(self.server_buffer, msg) def room_send_state(self, room_buffer, body, event_type): + if room_buffer.room.encrypted: + return + _, request = self.client.room_put_state( room_buffer.room.room_id, event_type, @@ -487,6 +490,9 @@ class MatrixServer(object): def room_send_message(self, room_buffer, formatted, msgtype="m.text"): # type: (RoomBuffer, Formatted) -> None + if room_buffer.room.encrypted: + return + if msgtype == "m.emote": message_class = OwnAction else: