Latest_timestamp = min(float(m) for m in res) Otherwise Slack returns a lot of already-deleted messages. Latest=latest_timestamp,)#important to do paging. Latest_timestamp = ((()-datetime.timedelta(hours=hours_in_past)) - datetime.datetime(1970,1,1)).total_seconds() Hours_in_past = int(raw_input("How many hours in the past should messages be kept? Enter 0 to delete them all. Raise Exception("got error: %s"%(str(res.get('error')))) Pool=(4) #slack rate-limits the API, so not much benefit to more threads.Ĭount = (ctypes.c_int,0) Different API.Ĭhannel = raw_input("Enter channel name to clear > ").strip("#") "groups.list", # groups are private channels, conversations are public channels. Legacy_token = raw_input("Enter token of an admin user. Import multiprocessing.dummy, ctypes, time, traceback, datetime Unfortunately Slack has no bulk-delete API, and they rate-limit the individual delete to 50 per minute, so it unavoidably takes a long time. Can be a good starting point if you want more programmatic control of deletion. Option 3 Below is a little Python script that I use to clear Private channels. Option 2 The slack-cleaner command line tool that others have mentioned. After that, in the Slack client you can open a channel, click the gear, and click "Edit message retention." First, you have to go to your Slack Workspace Settings, Message Retention & Deletion, and check "Let workspace members override these settings". Option 1 You can set a Slack channel to automatically delete messages after 1 day, but it's a little hidden.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |