aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-06-03 13:17:15 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2023-06-03 13:17:15 +0200
commit7310fe88d6fbf94d1bda7c10f24fa9e396d80311 (patch)
tree4bf4402a3559d28f9b9cc75baf1ee6269a1fe903 /wee_slack.py
parent484c35b7ac117cce7d37c2f3e6edc8f79e41eaf4 (diff)
downloadwee-slack-7310fe88d6fbf94d1bda7c10f24fa9e396d80311.tar.gz
Use prefix_nick_<color> tag for messages in WeeChat 4.0.0
Since WeeChat now has multiline support, the problems with using prefix_nick_<color> (mainly that it isn't possible to distinguish between a multiline message and multiple messages when weechat.look.prefix_same_nick is set) isn't present anymore, so we can use this tag to properly mark lines as chat messages from a nick. This also means that we don't have to use prefix_same_nick or nick_prefix/suffix ourselves anymore.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 6ffc994..3d11a06 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1940,6 +1940,7 @@ class SlackChannelCommon(object):
message.ts,
tagset=tagset,
tag_nick=message.sender_plain,
+ prefix_color=message.prefix_color,
history_message=history_message,
no_log=no_log,
extra_tags=extra_tags,
@@ -2468,6 +2469,7 @@ class SlackChannel(SlackChannelCommon):
timestamp,
tagset,
tag_nick=None,
+ prefix_color=None,
history_message=False,
no_log=False,
extra_tags=None,
@@ -2491,6 +2493,7 @@ class SlackChannel(SlackChannelCommon):
tagset,
user=tag_nick,
self_msg=self_msg,
+ prefix_color=prefix_color,
backlog=backlog,
no_log=no_log,
extra_tags=extra_tags,
@@ -3095,6 +3098,7 @@ class SlackThreadChannel(SlackChannelCommon):
timestamp,
tagset,
tag_nick=None,
+ prefix_color=None,
history_message=False,
no_log=False,
extra_tags=None,
@@ -3115,6 +3119,7 @@ class SlackThreadChannel(SlackChannelCommon):
tagset,
user=tag_nick,
self_msg=self_msg,
+ prefix_color=prefix_color,
backlog=backlog,
no_log=no_log,
extra_tags=extra_tags,
@@ -3481,6 +3486,14 @@ class SlackMessage(object):
def sender_plain(self):
return self.get_sender(True)
+ @property
+ def prefix_color(self):
+ user = self.team.users.get(self.user_identifier)
+ if user:
+ return user.color_name
+ else:
+ return get_nick_color(self.sender_plain)
+
def get_reaction(self, reaction_name):
for reaction in self.message_json.get("reactions", []):
if reaction["name"] == reaction_name:
@@ -5018,6 +5031,9 @@ def nick_from_profile(profile, username):
def format_nick(nick, previous_nick=None):
+ if weechat_version >= 0x04000000:
+ return nick
+
if nick == previous_nick:
nick = w.config_string(w.config_get("weechat.look.prefix_same_nick")) or nick
nick_prefix = w.config_string(w.config_get("weechat.look.nick_prefix"))
@@ -5048,6 +5064,7 @@ def tag(
tagset=None,
user=None,
self_msg=False,
+ prefix_color=None,
backlog=False,
no_log=False,
extra_tags=None,
@@ -5064,7 +5081,12 @@ def tag(
ts_tag = "slack_ts_{}".format(ts)
slack_tag = "slack_{}".format(tagset or "default")
nick_tag = ["nick_{}".format(user).replace(" ", "_")] if user else []
- tags = [ts_tag, slack_tag] + nick_tag + tagsets.get(tagset, [])
+ prefix_nick_tag = (
+ ["prefix_nick_{}".format(prefix_color.replace(",", ":"))]
+ if prefix_color and weechat_version >= 0x04000000
+ else []
+ )
+ tags = [ts_tag, slack_tag] + nick_tag + prefix_nick_tag + tagsets.get(tagset, [])
if self_msg or backlog:
tags = tags_set_notify_none(tags)
if self_msg: