Created
December 6, 2018 18:44
-
-
Save voice1/a868b997c89ffccb2cbaf79092707eec to your computer and use it in GitHub Desktop.
slack-cleaner wrapper to automate slack message clean up.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Automated cleanup of slack messages. | |
# Must have slack-cleaner already installed. | |
# Simply replace your SLACK_TOKEN string with your legacy webapi token. | |
# Set the number of days you wish to retain, and add this to a cron job to run at | |
# the desired interval. | |
SLACK_TOKEN=My-Slack-Legacy-WebToken | |
DAYS=-30 | |
BEFORE=$(date -v${DAYS}d +%Y%m%d) | |
echo "Cleaning up channels" | |
slack-cleaner --rate 1 --token $SLACK_TOKEN --message --channel ".*" --regex --bot --before $BEFORE --perform | |
slack-cleaner --rate 1 --token $SLACK_TOKEN --message --channel ".*" --regex --user "*" --before $BEFORE --perform | |
slack-cleaner --rate 1 --token $SLACK_TOKEN --file --channel ".*" --regex --before $BEFORE --perform | |
echo "Cleaning up Direct Messages (DM's)" | |
slack-cleaner --rate 1 --token $SLACK_TOKEN --message --direct ".*" --regex --bot --before $BEFORE --perform | |
slack-cleaner --rate 1 --token $SLACK_TOKEN --message --direct ".*" --regex --user "*" --before $BEFORE --perform | |
slack-cleaner --rate 1 --token $SLACK_TOKEN --file --direct ".*" --regex --before $BEFORE --perform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment