config: Add typing notice conditions.

This commit is contained in:
Damir Jelić 2018-11-29 16:48:12 +01:00
parent 45ebb921a9
commit 624ecc4d77
3 changed files with 24 additions and 0 deletions

View file

@ -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)

View file

@ -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 = [

View file

@ -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