Skip to content

Instantly share code, notes, and snippets.

@rrx
Created October 24, 2017 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rrx/03783c74dd2b8afc8d13f4f67cdc55cc to your computer and use it in GitHub Desktop.
Save rrx/03783c74dd2b8afc8d13f4f67cdc55cc to your computer and use it in GitHub Desktop.
Delete all files from slack
import slacker
from slacker import Slacker
import os
slack = Slacker(os.environ['terraform_slack_token'])
page = 1
while True:
response = slack.files.list(page=page)
pages = response.body['paging']['pages']
page = response.body['paging']['page'] + 1
print(response.body['paging'])
for f in response.body['files']:
print(f['id'],f['name'])
slack.files.delete(f['id'])
if page >= pages:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment