From 54a61626cc438287f00bcd209571619562538ccd Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Tue, 3 Apr 2018 11:22:11 -0700 Subject: Replace Slack links with direct links to shared files The current links in shared file messages only show a thumbnail and require an extra click to get to the actual shared file, which is a minor annoyance. Links from external members in shared channels are also from their team's Slack subdomain, so they're inaccessible if you're not a member of their team. The direct links are from the files.slack.com subdomain though and visible to all, and the official Slack client uses them to show those files. --- wee_slack.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wee_slack.py b/wee_slack.py index f6448ce..7ba22ab 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2051,6 +2051,15 @@ class SlackMessage(object): if message_json.get('subtype') == 'me_message' and not message_json['text'].startswith(self.sender): message_json['text'] = self.sender + ' ' + self.message_json['text'] + # Replace Slack link with direct link to shared file (required if + # shared by an external user since only the direct link is accessible) + if message_json.get('subtype') == 'file_share': + message_json['text'] = re.sub( + r'