diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-10-14 19:52:44 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | 291ce07645f63614b3b00fbe20063d6ef0161bef (patch) | |
tree | f6b2d0f7412f1f3ac2c02d8c2ab2957d1dc338fa /slack/slack_api.py | |
parent | 184bf08360003538179e3c19b2711016c823eadd (diff) | |
download | wee-slack-291ce07645f63614b3b00fbe20063d6ef0161bef.tar.gz |
Support sending messages
Diffstat (limited to 'slack/slack_api.py')
-rw-r--r-- | slack/slack_api.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/slack/slack_api.py b/slack/slack_api.py index be74c2c..7fff321 100644 --- a/slack/slack_api.py +++ b/slack/slack_api.py @@ -297,3 +297,23 @@ class SlackApi(SlackApiCommon): if response["ok"] is False: raise SlackApiError(self.workspace, method, response, params) return response + + async def chat_post_message( + self, + conversation: SlackConversation, + text: str, + thread_ts: Optional[SlackTs] = None, + ): + method = "chat.postMessage" + params: Params = { + "channel": conversation.id, + "text": text, + "as_user": True, + "link_names": True, + } + if thread_ts is not None: + params["thread_ts"] = thread_ts + response: SlackGenericResponse = await self._fetch(method, params) + if response["ok"] is False: + raise SlackApiError(self.workspace, method, response, params) + return response |