diff options
Diffstat (limited to 'slack')
-rw-r--r-- | slack/config.py | 7 | ||||
-rw-r--r-- | slack/slack_message.py | 10 |
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) |