From e72014859d33e5c4166eb2dd37ade451f8fe98bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 13 Sep 2018 00:04:29 +0200 Subject: [PATCH] buffer: Change the notify tag for private messages. --- matrix/buffer.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/matrix/buffer.py b/matrix/buffer.py index 8c6db37..003e05a 100644 --- a/matrix/buffer.py +++ b/matrix/buffer.py @@ -164,6 +164,11 @@ class RoomUser(WeechatUser): class WeechatChannelBuffer(object): tags = { "message": [SCRIPT_NAME + "_message", "notify_message", "log1"], + "message_private": [ + SCRIPT_NAME + "_message", + "notify_private", + "log1" + ], "self_message": [ SCRIPT_NAME + "_message", "notify_none", @@ -177,6 +182,12 @@ class WeechatChannelBuffer(object): "notify_message", "log1", ], + "action_private": [ + SCRIPT_NAME + "_message", + SCRIPT_NAME + "_action", + "notify_private", + "log1", + ], "notice": [SCRIPT_NAME + "_notice", "notify_message", "log1"], "old_message": [ SCRIPT_NAME + "_message", @@ -482,7 +493,8 @@ class WeechatChannelBuffer(object): def message(self, nick, message, date, extra_tags=None): # type: (str, str, int, List[str]) -> None user = self._get_user(nick) - tags = self._message_tags(user, "message") + (extra_tags or []) + tags_type = "message_private" if self.type == "private" else "message" + tags = self._message_tags(user, tags_type) + (extra_tags or []) self._print_message(user, message, date, tags) user.update_speaking_time(date) @@ -551,7 +563,8 @@ class WeechatChannelBuffer(object): def action(self, nick, message, date, extra_tags=None): # type: (str, str, int, Optional[List[str]]) -> None user = self._get_user(nick) - tags = self._message_tags(user, "action") + (extra_tags or []) + tags_type = "action_private" if self.type == "private" else "action" + tags = self._message_tags(user, tags_type) + (extra_tags or []) self._print_action(user, message, date, tags) user.update_speaking_time(date) @@ -747,6 +760,10 @@ class WeechatChannelBuffer(object): def short_name(self): return W.buffer_get_string(self._ptr, "short_name") + @property + def type(self): + return W.buffer_get_string(self._ptr, "localvar_type") + @short_name.setter def short_name(self, name): W.buffer_set(self._ptr, "short_name", name)