aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/wee_slack.py b/wee_slack.py
index ffc7249..6439ba1 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2113,14 +2113,6 @@ class SlackMessage(object):
message_json['text']
)
- if message_json.get('upload'):
- parts = [message_json['text']]
- for f in message_json.get('files', []):
- parts.append("({}) - {}".format(
- f.get('title'),
- f.get('url_private')))
- message_json['text'] = ' | '.join(p for p in parts if p)
-
def __hash__(self):
return hash(self.ts)
@@ -2791,6 +2783,8 @@ def render(message_json, team, channel, force=False):
text += unfurl_refs(unwrap_attachments(message_json, text))
+ text += unfurl_refs(unwrap_files(message_json, text))
+
text = text.lstrip()
text = unhtmlescape(text.replace("\t", " "))
if message_json.get('mrkdwn', True):
@@ -2960,6 +2954,14 @@ def unwrap_attachments(message_json, text_before):
return "\n".join(attachment_texts)
+def unwrap_files(message_json, text_before):
+ files_texts = ['{} ({})'.format(f['url_private'], f['title'])
+ for f in message_json.get('files', [])]
+ if text_before:
+ files_texts.insert(0, '')
+ return "\n".join(files_texts)
+
+
def resolve_ref(ref):
# TODO: This hack to use eventrouter needs to go
# this resolver should probably move to the slackteam or eventrouter itself