aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-03-20 00:12:08 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2020-03-20 00:12:08 +0100
commita43b09c27ca62a8fc3f078f7b9b2b7fe04ee43c6 (patch)
tree9f3502318c28e9f97c659e9608e1f50dd2bb4f49
parentd33b04930e72b2ccc9bbddc610903246d2d77b2b (diff)
downloadwee-slack-a43b09c27ca62a8fc3f078f7b9b2b7fe04ee43c6.tar.gz
Set highlight_words for new channels and thread channels
Fixes #736
-rw-r--r--wee_slack.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py
index e00da71..05c4a4d 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1281,13 +1281,13 @@ class SlackTeam(object):
self.got_history = True
self.create_buffer()
self.set_muted_channels(kwargs.get('muted_channels', ""))
+ self.set_highlight_words(kwargs.get('highlight_words', ""))
for c in self.channels.keys():
channels[c].set_related_server(self)
channels[c].check_should_open()
# Last step is to make sure my nickname is the set color
self.users[self.myidentifier].force_color(w.config_string(w.config_get('weechat.color.chat_nick_self')))
# This highlight step must happen after we have set related server
- self.set_highlight_words(kwargs.get('highlight_words', ""))
self.load_emoji_completions()
self.type = "team"
@@ -1765,6 +1765,9 @@ class SlackChannel(SlackChannelCommon):
else:
w.buffer_set(self.channel_buffer, "highlight_tags_restrict", "")
+ for thread_channel in self.thread_channels.values():
+ thread_channel.set_highlights(h_str)
+
def create_buffer(self):
"""
Creates the weechat buffer where the channel magic happens.
@@ -1780,6 +1783,7 @@ class SlackChannel(SlackChannelCommon):
w.buffer_set(self.channel_buffer, "localvar_set_channel", self.formatted_name())
w.buffer_set(self.channel_buffer, "localvar_set_nick", self.team.nick)
w.buffer_set(self.channel_buffer, "short_name", self.formatted_name(style="sidebar", enable_color=True))
+ self.set_highlights()
self.set_topic()
self.eventrouter.weechat_controller.set_refresh_buffer_list(True)
if self.channel_buffer:
@@ -2314,6 +2318,12 @@ class SlackThreadChannel(SlackChannelCommon):
if self.channel_buffer and not self.label:
w.buffer_set(self.channel_buffer, "short_name", self.formatted_name(style="sidebar", enable_color=True))
+ def set_highlights(self, highlight_string=None):
+ if self.channel_buffer:
+ if highlight_string is None:
+ highlight_string = ",".join(self.parent_message.channel.highlights())
+ w.buffer_set(self.channel_buffer, "highlight_words", highlight_string)
+
def create_buffer(self):
"""
Creates the weechat buffer where the thread magic happens.
@@ -2326,6 +2336,7 @@ class SlackThreadChannel(SlackChannelCommon):
w.buffer_set(self.channel_buffer, "localvar_set_channel", self.formatted_name())
w.buffer_set(self.channel_buffer, "localvar_set_server", self.team.preferred_name)
w.buffer_set(self.channel_buffer, "short_name", self.formatted_name(style="sidebar", enable_color=True))
+ self.set_highlights()
time_format = w.config_string(w.config_get("weechat.look.buffer_time_format"))
parent_time = time.localtime(SlackTS(self.parent_message.ts).major)
topic = '{} {} | {}'.format(time.strftime(time_format, parent_time), self.parent_message.sender, self.render(self.parent_message) )