A simple tool to help archive public channels that haven't been used for a while.
The following pre-requisites are required.
This has only been tested in *nix environment (e.g. MacOS/Linux) although there's nothing tying it to these platforms.
You'll also require bot
and user
API tokens from Slack. You can obtain new API tokens by creating a new App in Slack.
The bot token must have the following scopes:
channels:history
channels:manage
channels:read
The user token must have the following scopes:
channels:history
channels:read
channels:write
The bot
and user
API tokens can be specified in three ways, in order of priority:
- Pass it as the trailing arguments, e.g.
bin/slack-channel-archiver 90 bot-api-token user-api-token
- Set it as env var
BOT_SLACK_API_TOKEN
/USER_SLACK_API_TOKEN
, e.g.BOT_SLACK_API_TOKEN=api-token USER_SLACK_API_TOKEN=another-token bin/slack-channel-archiver
- Set in
~/.slack-channel-archiver
, e.g.
bot-api-token: an-api-token
user-api-token: another-api-token
You can use the following configuration options in ~/.slack-channel-archiver
:
Name | Type | Description |
---|---|---|
bot-api-token | string | Slack bot API token, as described above |
user-api-token | string | Slack user API token, as described above |
ignored-channel-names | list of strings | Names of channels that should never be archived, even if they match the archive criteria |
For example:
bot-api-token: xoxb-a-bot-api-token
user-api-token: xoxp-a-user-api-token
ignored-channel-names:
- channel1
- channel2
Usage:
bin/slack-channel-archiver [inactivity-period = 90 days] [bot-api-token] [user-api-token]
On the first run it'll install dependencies, which may be a bit noisy.
Due to rate limits on the Slack side it'll run quite slowly - about 1 channel/second will be tested. Also please note that channels will be marked as archived by the user who installed the app, as Slack doesn't allow bots to archive channels.
Support is on a best-effort basis. We'll endeavour to keep it in a good state and to respond to any issues/requests, but it works nicely for our purposes and is unlikely to see any major feature enhancements.
This code is licenced under an MIT licence as described in LICENSE.
Copyright © Springer Nature Ltd.