Skip to content

Commit

Permalink
Quick fix to access files shared in Slack Connect
Browse files Browse the repository at this point in the history
  • Loading branch information
ranlu committed Jan 9, 2024
1 parent db1a8f9 commit d80a9f0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions slackbot/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,15 @@ def download_file(msg):
if "files" in msg:
# only use the first file:
file_info = msg["files"][0]

if file_info.get("file_access", None) == "check_file_info":
if "url_private_download" not in file_info:
sc = slack.WebClient(slack_token, timeout=300)
ret = sc.files_info(file=file_info["id"])
file_info = ret.data["file"]

private_url = file_info["url_private_download"]

filetype = file_info["pretty_type"]
response = requests.get(private_url, headers={'Authorization': 'Bearer {}'.format(slack_token)})

Expand Down

0 comments on commit d80a9f0

Please sign in to comment.