From c6f7fb64acc17ba056d69d4a6c9f07cbbd688c56 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 28 Jan 2023 19:41:47 +0100 Subject: Color user mentions --- slack/slack_message.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'slack/slack_message.py') 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) -- cgit