aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-01-28 19:41:47 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:53 +0100
commitc6f7fb64acc17ba056d69d4a6c9f07cbbd688c56 (patch)
tree78ef8fc52f15913eadd59d77f10d0d6f2094ccb7
parent66e54b06896a9de7b35d1700ad34b25778780408 (diff)
downloadwee-slack-c6f7fb64acc17ba056d69d4a6c9f07cbbd688c56.tar.gz
Color user mentions
-rw-r--r--slack/config.py7
-rw-r--r--slack/slack_message.py10
2 files changed, 16 insertions, 1 deletions
diff --git a/slack/config.py b/slack/config.py
index 4533780..7efe69b 100644
--- a/slack/config.py
+++ b/slack/config.py
@@ -43,6 +43,13 @@ class SlackConfigSectionColor:
WeeChatColor("darkgray"),
)
+ self.user_mention_color = WeeChatOption(
+ self._section,
+ "user_mention_color",
+ "text color for mentioned user names in the chat",
+ WeeChatColor("blue"),
+ )
+
class SlackConfigSectionLook:
def __init__(self, weechat_config: WeeChatConfig):
diff --git a/slack/slack_message.py b/slack/slack_message.py
index db5c6cf..1a0d482 100644
--- a/slack/slack_message.py
+++ b/slack/slack_message.py
@@ -3,8 +3,10 @@ from __future__ import annotations
import re
from typing import TYPE_CHECKING, List, Optional
+from slack.shared import shared
from slack.slack_user import SlackUser, format_bot_nick
from slack.task import gather
+from slack.util import with_color
if TYPE_CHECKING:
from slack_api.slack_conversations_history import SlackMessage as SlackMessageDict
@@ -59,6 +61,12 @@ class SlackMessage:
def unfurl_user(user_id: str):
user = users[user_id]
- return "@" + user.nick() if isinstance(user, SlackUser) else f"@{user_id}"
+ return (
+ with_color(
+ shared.config.color.user_mention_color.value, "@" + user.nick()
+ )
+ if isinstance(user, SlackUser)
+ else f"@{user_id}"
+ )
return re_user.sub(lambda match: unfurl_user(match.group(1)), message)