diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-08-20 16:36:03 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | e71e04f1ed15dfa5348350a1f2921458ade3e77a (patch) | |
tree | 5cc36dcacbe2aa35a62b40afe40c0f4f56771238 /slack | |
parent | 2cfbb994506cb6d8e63d95b7f98feee06418c67d (diff) | |
download | wee-slack-e71e04f1ed15dfa5348350a1f2921458ade3e77a.tar.gz |
Set correct tags for self messages
Diffstat (limited to 'slack')
-rw-r--r-- | slack/slack_message.py | 9 | ||||
-rw-r--r-- | slack/slack_user.py | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/slack/slack_message.py b/slack/slack_message.py index a2220f3..403dc41 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 format_bot_nick +from slack.slack_user import SlackUser, format_bot_nick from slack.task import gather from slack.util import with_color @@ -103,7 +103,12 @@ class SlackMessage: tags.append("bot_message") if user_or_bot and shared.weechat_version >= 0x04000000: tags.append(f"prefix_nick_{user_or_bot.nick_color()}") - log_tags = ["notify_message", "log1"] + + if isinstance(user_or_bot, SlackUser) and user_or_bot.is_self: + tags.append("self_msg") + log_tags = ["notify_none", "no_highlight", "log1"] + else: + log_tags = ["notify_message", "log1"] if backlog: tags += ["no_highlight", "notify_none", "logger_backlog", "no_log"] diff --git a/slack/slack_user.py b/slack/slack_user.py index e888b41..aa84089 100644 --- a/slack/slack_user.py +++ b/slack/slack_user.py @@ -57,6 +57,10 @@ class SlackUser: info_response = await workspace.api.fetch_user_info(id) return cls(workspace, info_response["user"]) + @property + def is_self(self) -> bool: + return self._info["id"] == self.workspace.my_user._info["id"] + def nick(self, colorize: bool = False, only_nick: bool = False) -> str: nick = self._name_without_spaces() @@ -72,7 +76,7 @@ class SlackUser: return name_from_user_info_without_spaces(self.workspace, self._info) def nick_color(self) -> str: - if self._info["id"] == self.workspace.my_user._info["id"]: + if self.is_self: return weechat.config_string( weechat.config_get("weechat.color.chat_nick_self") ) |