Delete all of the messages in a Slack channel.
- Slack Python SDK, Slack API token with permissions (see below).
- Python
This script was developed and tested with Slack Python SDK version 1.0.6
, Python version 2.7.13
.
The Slack app tied to the API token must have the necessary permissions for channels.list (to find the ID of the channel), channels.history (get all messages from the channel), and chat.delete (delete messages from the channel).
-
Install Slack Python SDK.
-
Clone this repo.
In this repo, from commandline:
export SLACK_API_TOKEN=<your-slack-api-token>
user$ python slackterminator.py --help
usage: slackterminator.py [-h] --channel_name <channel name without hashtag>
Delete all messages from a given Slack channel.
optional arguments:
-h, --help show this help message and exit
--channel_name <channel name without hashtag>
The name of the Slack channel to delete all messages
in.