aboutsummaryrefslogtreecommitdiffstats
path: root/slack/slack_message.py
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 /slack/slack_message.py
parent66e54b06896a9de7b35d1700ad34b25778780408 (diff)
downloadwee-slack-c6f7fb64acc17ba056d69d4a6c9f07cbbd688c56.tar.gz
Color user mentions
Diffstat (limited to 'slack/slack_message.py')
-rw-r--r--slack/slack_message.py10
1 files changed, 9 insertions, 1 deletions
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)