A command line tool to interface slack.
$ pip install slack.pyAll the subcommands require a Slack access token to work. You can pass the token either as a parameter:
$ slack -a <AUTH-TOKEN> auth_testor as an environment variable:
$ SLACK_API_TOKEN=<AUTH-TOKEN> slack auth_testAuthentication in Slack is based on OAuth and might be complicated to set it up. To get started, you can generate a personal token from this page: https://api.slack.com/custom-integrations/legacy-tokens
This commands allows you to interact with Slack channels (listing, archiving or deleting them). All these subcommands accept filters like --starts-with or --contains. Deleting and Archiving allow --dry-run mode to simulate the behavior without making real changes. Be aware of Slack API Rates. See section below
See examples below.
List channels' ids, names, archived status:
$ slack -a <AUTH-TOKEN> channelsYou can filter by --starts-with:
$ slack -a <AUTH-TOKEN> channels --starts-with 'z-visitor'And --contains:
$ slack -a <AUTH-TOKEN> channels --contains 'visitor'(Warning: Once a channel is deleted there's no way to restore it. Use it at your own risk)
Use your usual channels filters and pass the --archive or --delete flags to either archive or delete the matching channels. Try your action with the --dry-run flag before performing the real action to see which channels would be deleted.
$ slack -a <AUTH-TOKEN> channels --starts-with 'z-visitor' --delete --dry-run --sleep 0The --sleep parameter is required for --archive and --delete due to Slack API Rates. See below.
Finally, a real --delete command looks like:
$ slack -a <AUTH-TOKEN> channels --starts-with 'z-visitor' --deleteSome commands like --delete channels can't be issued too frequently because the Slack API fails. That's why most commands have a --sleep parameter that will wait a given number of milliseconds before issuing new requests. You can try decreasing it by just passing --sleep to your commands. I couldn't find any official documentation for the correct time limits of some methods. I tried out and for example, deleting channels requires at least 10 seconds before every request.

