diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-09-17 11:30:53 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | 994e2d246fc09ed942a871696ccae1bdc3002217 (patch) | |
tree | 2c1ac01192e50c6d1c717f8c78b70fd47585fcf9 /slack/slack_workspace.py | |
parent | 2a9cad66efec738e68230d335540e6c9e7d9c7e8 (diff) | |
download | wee-slack-994e2d246fc09ed942a871696ccae1bdc3002217.tar.gz |
Support thread buffers
Diffstat (limited to 'slack/slack_workspace.py')
-rw-r--r-- | slack/slack_workspace.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/slack/slack_workspace.py b/slack/slack_workspace.py index a570658..08895d1 100644 --- a/slack/slack_workspace.py +++ b/slack/slack_workspace.py @@ -25,8 +25,10 @@ from slack.log import print_error from slack.proxy import Proxy from slack.shared import shared from slack.slack_api import SlackApi +from slack.slack_buffer import SlackBuffer from slack.slack_conversation import SlackConversation from slack.slack_message import SlackMessage, SlackTs +from slack.slack_thread import SlackThread from slack.slack_user import SlackBot, SlackUser, SlackUsergroup from slack.task import Future, Task, create_task, gather, run_async from slack.util import get_callback_name @@ -344,12 +346,25 @@ class SlackWorkspace: print("lost connection on ping, reconnecting") run_async(self.reconnect()) - def send_typing(self, conversation_id: str): + def send_typing(self, buffer: SlackBuffer): if not self.is_connected: raise SlackError(self, "Can't send typing when not connected") if self._ws is None: raise SlackError(self, "is_connected is True while _ws is None") - msg = {"type": "typing", "channel": conversation_id} + + if isinstance(buffer, SlackConversation): + conversation_id = buffer.id + elif isinstance(buffer, SlackThread): + conversation_id = buffer.parent.conversation.id + else: + raise NotImplementedError(f"Unknown buffer type: {type(buffer)}") + + msg = { + "type": "user_typing", + "channel": conversation_id, + } + if isinstance(buffer, SlackThread): + msg["thread_ts"] = buffer.parent.ts self._ws.send(json.dumps(msg)) async def reconnect(self): |