aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wee_slack.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 6eb725e..61a25a8 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2474,6 +2474,9 @@ class SlackMessage(object):
else:
text = ""
+ if "blocks" in self.message_json:
+ text += unfurl_blocks(self.message_json)
+
if self.message_json.get('mrkdwn', True):
text = render_formatting(text)
@@ -3371,6 +3374,20 @@ def linkify_text(message, team, only_users=False):
return re.sub(linkify_regex, linkify_word, message_escaped, re.UNICODE)
+def unfurl_blocks(message_json):
+ block_text = []
+ for block in message_json["blocks"]:
+ if block["type"] == "section":
+ block_text.append(block["text"]["text"]) #TODO: markdown, etc. parse?
+ if block["type"] == "actions":
+ block_text.append("|".join(i["text"]["text"] for i in block["elements"]))
+ if block["type"] == "divider":
+ block_text.append("\n")
+ if block["type"] == "context":
+ block_text.append("|".join(i["text"] for i in block["elements"]))
+ return "\n".join(block_text)
+
+
def unfurl_refs(text, ignore_alt_text=None, auto_link_display=None):
"""
input : <@U096Q7CQM|someuser> has joined the channel