import requests
import json
import time
import sys

_token = "xxxxxxx"
_domain = "xxxxxxx"

def del_time(Day):
    Set_time = str(int(time.time())-Day*86400)
    return Set_time

def files_list(Day):
    Del_time = del_time(Day)
    files_list_url = "https://slack.com/api/files.list"
    data = {
        "token": _token,
        "ts_to": Del_time,
        "count":1000
        }
    response = requests.post(files_list_url,data)

    if response.json()["ok"] == 0:
        print("Error_exit(around API's argument)")
        sys.exit()
    return response.json()["files"]

def delete():
    
    return

if __name__ == '__main__':
    while 1:
        files = files_list(0)
        if len(files) == 0:
            print ("No files")
            break
        for f in files:
            print ("Deleting file " + f["name"] + "...")
            delete_url = "https://slack.com/api/files.delete"
            data = {
                    "token": _token,
                    "file": f["id"],
                    "set_active": "true",
                    "_attempts": "1"
                    }
            requests.post(delete_url, data)
print ("complete")


import requests
import json
import time
import sys

file = open('token.txt', 'r')
_token = file.readline()
file.close()
file = open('domain.txt', 'r')
_domain = file.readline()

def del_time(Day):
    Set_time = str(int(time.time())-Day*86400)
    return Set_time

def files_list(Day):
    Del_time = del_time(Day)
    files_list_url = "https://slack.com/api/files.list"
    data = {
        "token": _token,
        "ts_to": Del_time,
        "count":1000
        }
    response = requests.post(files_list_url,data)

    if response.json()["ok"] == 0:
        print("Error_exit(around API's argument)")
        sys.exit()
    return response.json()["files"]

def delete():
    
    return

if __name__ == '__main__':
    while 1:
        files = files_list(0)
        if len(files) == 0:
            print ("No files")
            break
        for f in files:
            print ("Deleting file " + f["name"] + "...")
            delete_url = "https://slack.com/api/files.delete"
            data = {
                    "token": _token,
                    "file": f["id"],
                    "set_active": "true",
                    "_attempts": "1"
                    }
            requests.post(delete_url, data)
print ("complete")


Change about read "token" & "domain"
Change about read "token" & "domain"

