diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-10-19 22:09:30 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | 20fcca5f2ccbd7b524908d11d14a9ce8f33c2dd6 (patch) | |
tree | 3e1cdff1ebcc3342fce8f916ba577d4a058b3eb6 /slack/slack_conversation.py | |
parent | 6eac18fb0080132e42285b0976205d2bb6d36848 (diff) | |
download | wee-slack-20fcca5f2ccbd7b524908d11d14a9ce8f33c2dd6.tar.gz |
Show user status in DM buffer title
Diffstat (limited to 'slack/slack_conversation.py')
-rw-r--r-- | slack/slack_conversation.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py index 257796a..351d24d 100644 --- a/slack/slack_conversation.py +++ b/slack/slack_conversation.py @@ -188,6 +188,11 @@ class SlackConversation(SlackBuffer): def muted(self) -> bool: return self.id in self.workspace.muted_channels + @property + def im_user_id(self) -> Optional[str]: + if self.type == "im": + return self._info.get("user") + async def sort_key(self) -> str: type_sort_key = { "channel": 0, @@ -248,9 +253,14 @@ class SlackConversation(SlackBuffer): return True return False - def buffer_title(self) -> str: + async def buffer_title(self) -> str: # TODO: unfurl and apply styles - return unhtmlescape(self._info.get("topic", {}).get("value", "")) + topic = unhtmlescape(self._info.get("topic", {}).get("value", "")) + if self.im_user_id: + user = await self.workspace.users[self.im_user_id] + status = f"{user.status_emoji} {user.status_text}".strip() + return " | ".join(part for part in [status, topic] if part) + return topic async def set_topic(self, title: str): if "topic" not in self._info: @@ -269,7 +279,7 @@ class SlackConversation(SlackBuffer): return name, { "short_name": short_name, - "title": self.buffer_title(), + "title": await self.buffer_title(), "input_multiline": "1", "nicklist": "0" if self.type == "im" else "1", "nicklist_display_groups": "0", |