diff options
author | Romain THERRAT <romain@pockost.com> | 2023-03-07 01:10:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-07 01:10:50 +0100 |
commit | a44fb2dcf3e8602be8e432479ef4c416d514937c (patch) | |
tree | b4cb1105d190105a551142a3e0ab61ffb29e8f9f | |
parent | 3e4ba2a79cf011df9a32b674454fb0e18a0ad5c9 (diff) | |
download | wee-slack-a44fb2dcf3e8602be8e432479ef4c416d514937c.tar.gz |
feat(huddle): Display link to join huddle when started (#885)
-rw-r--r-- | wee_slack.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py index 14c3607..d8cf3fa 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -3409,6 +3409,7 @@ class SlackMessage(object): text += unfurl_refs(unwrap_attachments(self, text)) text += unfurl_refs(unwrap_files(self, self.message_json, text)) + text += unfurl_refs(unwrap_huddle(self, self.message_json)) text = unhtmlescape(text.lstrip().replace("\t", " ")) text += create_reactions_string( @@ -4781,6 +4782,35 @@ def unwrap_attachments(message, text_before): return "\n".join(attachment_texts) +def unwrap_huddle(message, message_json): + """ + If huddle is linked to message append huddle information and link + to connect. + """ + huddle_texts = [] + + if "room" in message_json: + for block in message_json.get("blocks"): + for element in block.get("elements"): + for element2 in element.get("elements"): + huddle_texts.append(element2.get("text")) + + if "name" in message_json.get("room"): + room_name = message_json.get("room").get("name") + + if room_name != "": + huddle_texts.append("Huddle name : {}".format(room_name)) + + for channel in message_json.get("room").get("channels"): + huddle_texts.append( + "https://app.slack.com/client/{team}/{channel}?open=start_huddle".format( + team=message_json.get("team"), channel=channel + ) + ) + + return "\n".join(huddle_texts) + + def unwrap_files(message, message_json, text_before): files_texts = [] for f in message_json.get("files", []): |