From c66c9c39b46e50700c93b12473176005db01012f Mon Sep 17 00:00:00 2001 From: jaejeon Date: Sun, 26 Apr 2020 20:02:06 +0900 Subject: [PATCH] Fix blocks support to Slacker --- slacker/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/slacker/__init__.py b/slacker/__init__.py index cc06892..1ee095d 100644 --- a/slacker/__init__.py +++ b/slacker/__init__.py @@ -495,7 +495,10 @@ def post_message(self, channel, text=None, username=None, as_user=None, if attachments: if isinstance(attachments, list): attachments = json.dumps(attachments) - + # Ensure blocks are json encoded + if blocks: + if isinstance(blocks, list): + blocks = json.dumps(blocks) return self.post('chat.postMessage', data={ 'channel': channel, @@ -532,6 +535,9 @@ def update(self, channel, ts, text, attachments=None, parse=None, # Ensure attachments are json encoded if attachments is not None and isinstance(attachments, list): attachments = json.dumps(attachments) + # Ensure blocks are json encoded + if blocks is not None and isinstance(blocks, list): + blocks = json.dumps(blocks) return self.post('chat.update', data={ 'channel': channel, @@ -558,6 +564,9 @@ def post_ephemeral(self, channel, text, user, as_user=None, # Ensure attachments are json encoded if attachments is not None and isinstance(attachments, list): attachments = json.dumps(attachments) + # Ensure blocks are json encoded + if blocks is not None and isinstance(blocks, list): + blocks = json.dumps(blocks) return self.post('chat.postEphemeral', data={ 'channel': channel,