import requests import time import json token = 'xoxp-2193773949-54381650928-135878815508-5109792251125e3a2e4fc21c631e4964' #Delete files older than this: ts_to = int(time.time()) - 30 * 24 * 60 * 60 def list_files(): params = { 'token': token ,'ts_to': ts_to ,'count': 1000 } uri = 'https://slack.com/api/files.list' response = requests.get(uri, params=params) return json.loads(response.text)['files'] def delete_files(file_ids): count = 0 num_files = len(file_ids) for file_id in file_ids: count = count + 1 params = { 'token': token ,'file': file_id } uri = 'https://slack.com/api/files.delete' response = requests.get(uri, params=params) print count, "of", num_files, "-", file_id, json.loads(response.text)['ok'] files = list_files() file_ids = [f['id'] for f in files] delete_files(file_ids)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question