From 624ecc4d7708b5feacb11a7c71252b14c5d7e1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 29 Nov 2018 16:48:12 +0100 Subject: [PATCH] config: Add typing notice conditions. --- matrix/buffer.py | 1 + matrix/config.py | 13 +++++++++++++ matrix/server.py | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/matrix/buffer.py b/matrix/buffer.py index e3047ae..da7dca7 100644 --- a/matrix/buffer.py +++ b/matrix/buffer.py @@ -827,6 +827,7 @@ class RoomBuffer(object): self.typing_notice_time = None self._typing = False + self.typing_enabled = True buffer_name = "{}.{}".format(server_name, room.room_id) diff --git a/matrix/config.py b/matrix/config.py index d842a9c..8f80bb9 100644 --- a/matrix/config.py +++ b/matrix/config.py @@ -612,6 +612,19 @@ class MatrixConfig(WeechatConfig): "500", ("minimum lag to show (in milliseconds)"), ), + Option( + "typing_notice_conditions", + "string", + "", + 0, + 0, + "${typing_enabled}", + ("conditions to send typing notifications (note: content is " + "evaluated, see /help eval); besides the buffer and window " + "variables the typing_enabled variable is also expanded; " + "the typing_enabled variable can be manipulated with the " + "/room command, see /help room"), + ), ] color_options = [ diff --git a/matrix/server.py b/matrix/server.py index 0b60c77..657a94b 100644 --- a/matrix/server.py +++ b/matrix/server.py @@ -685,6 +685,16 @@ class MatrixServer(object): input = room_buffer.weechat_buffer.input + typing_enabled = bool(int(W.string_eval_expression( + G.CONFIG.network.typing_notice_conditions, + {}, + {"typing_enabled": str(int(room_buffer.typing_enabled))}, + {"type": "condition"} + ))) + + if not typing_enabled: + return + # Don't send a typing notice if the user is typing in a weechat command if input.startswith("/") and not input.startswith("//"): return