aboutsummaryrefslogtreecommitdiffstats
path: root/slack
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-08-20 19:11:01 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:53 +0100
commit899ce2af752351871c94c0b8623dfc28cdac074f (patch)
tree34039e92f8b9db00823e262efbc04671d73dc601 /slack
parentdda51f3e01911e91dc386711717310efaf0a530a (diff)
downloadwee-slack-899ce2af752351871c94c0b8623dfc28cdac074f.tar.gz
Use the correct nick color for bots with a username
Diffstat (limited to 'slack')
-rw-r--r--slack/slack_message.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/slack/slack_message.py b/slack/slack_message.py
index 6fb6c37..792b064 100644
--- a/slack/slack_message.py
+++ b/slack/slack_message.py
@@ -9,7 +9,7 @@ import weechat
from slack.log import print_exception_once
from slack.python_compatibility import removeprefix, removesuffix
from slack.shared import shared
-from slack.slack_user import SlackUser, format_bot_nick
+from slack.slack_user import format_bot_nick, nick_color
from slack.task import gather
from slack.util import with_color
@@ -100,12 +100,11 @@ class SlackMessage:
if self.sender_bot_id:
tags.append(f"slack_bot_id_{self.sender_bot_id}")
- if self.sender_user_id:
- user_or_bot = await self.workspace.users[self.sender_user_id]
- elif self.sender_bot_id:
- user_or_bot = await self.workspace.bots[self.sender_bot_id]
- else:
- user_or_bot = None
+ user = (
+ await self.workspace.users[self.sender_user_id]
+ if self.sender_user_id
+ else None
+ )
if self._message_json.get("subtype") in ["channel_join", "group_join"]:
tags.append("slack_join")
@@ -117,10 +116,13 @@ class SlackMessage:
tags.append("slack_privmsg")
if self.is_bot_message:
tags.append("bot_message")
- if user_or_bot and shared.weechat_version >= 0x04000000:
- tags.append(f"prefix_nick_{user_or_bot.nick_color()}")
+ if shared.weechat_version >= 0x04000000:
+ if user:
+ tags.append(f"prefix_nick_{user.nick_color()}")
+ else:
+ tags.append(f"prefix_nick_{nick_color(nick)}")
- if isinstance(user_or_bot, SlackUser) and user_or_bot.is_self:
+ if user and user.is_self:
tags.append("self_msg")
log_tags = ["notify_none", "no_highlight", "log1"]
else: