Package: slack-cleaner
slack-cleanerBulk delete messages and files on Slack.this is a fork ofhttps://github.com/kfei/slack-cleanerInstallInstall from Pip:pipinstallslack-cleanercurrent development version:pip install -e git+https://github.com/sgratzl/slack-cleaner.git#egg=slack-cleanerIf you prefer Docker, there is a pre-built Docker image as well:dockerpullsgratzl/slack-cleanerJust usedocker run -it --rm sgratzl/slack-cleaner -c "slack-cleaner ..."for each command or jump into a shell usingdocker run -it --rm sgratzl/slack-cleaner.Install for Fedora or EPEL7@rapgromaintains packages for both Fedora and EPEL7# Fedoradnfinstallslack-cleaner# EPEL7yuminstall-yepel-release;yuminstallslack-cleanerArgumentsusage: slack-cleaner [-h] --token TOKEN [--log] [--quiet] [--rate RATE]
                     [--as_user] [--message | --file | --info] [--regex]
                     [--channel CHANNEL] [--direct DIRECT] [--group GROUP]
                     [--mpdirect MPDIRECT] [--user USER] [--botname BOTNAME]
                     [--bot] [--keeppinned] [--after AFTER] [--before BEFORE]
                     [--types TYPES] [--pattern PATTERN] [--perform]

optional arguments:
  -h, --help           show this help message and exit
  --token TOKEN        Slack API token (https://api.slack.com/web) or SLACK_TOKEN env var
  --log                Create a log file in the current directory
  --quiet              Run quietly, does not log messages deleted
  --proxy              Proxy Server url:port
  --verify             Verify option for Session (http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification)
  --rate RATE          Delay between API calls (in seconds)
  --as_user            Pass true to delete the message as the authed user. Bot
                       users in this context are considered authed users.
  --message            Delete messages
  --file               Delete files
  --info               Show information
  --regex              Interpret channel, direct, group, and mpdirect as regex
  --channel CHANNEL    Channel name's, e.g., general
  --direct DIRECT      Direct message's name, e.g., sherry
  --group GROUP        Private group's name
  --mpdirect MPDIRECT  Multiparty direct message's name, e.g.,
                       sherry,james,johndoe
  --user USER          Delete messages/files from certain user
  --botname BOTNAME    Delete messages/files from certain bots. Implies '--bot'
  --bot                Delete messages from bots
  --keeppinned         exclude pinned messages from deletion
  --after AFTER        Delete messages/files newer than this time (YYYYMMDD)
  --before BEFORE      Delete messages/files older than this time (YYYYMMDD)
  --types TYPES        Delete files of a certain type, e.g., posts,pdfs
  --pattern PATTERN    Delete messages/files with specified pattern or if one of their attachments matches (regex)
  --perform            Perform the taskPermission Scopes neededThe permissions to grant depend on what you are going to use the script for.
Grant the permissions below depending on your use.Beyond granting permissions, if you wish to use this script to delete
messages or files posted by others, you will need to be anOwner or
Adminof the workspace.Deleting messages from public channelschannels:historychannels:readchat:write(or bothchat:write:userandchat:write:botfor older apps)users:readDeleting messages from private channelsgroups:historygroups:readchat:write(orchat:write:userfor older apps)users:readDeleting messages from 1:1 IMsim:historyim:readchat:write(orchat:write:userfor older apps)users:readDeleting messages from multi-person IMsmpim:historympim:readchat:write(orchat:write:userfor older apps)users:readDeleting filesfiles:readfiles:write(orfiles:write:userfor older apps)users:readUsage# Delete all messages from a channelslack-cleaner--token<TOKEN>--message--channelgeneral--user"*"# Delete all messages from a private group aka private channelslack-cleaner--token<TOKEN>--message--grouphr--user"*"# Delete all messages from a direct message channelslack-cleaner--token<TOKEN>--message--directsherry--userjohndoe# Delete all messages from a multiparty direct message channel. Note that the# list of usernames must contains yourselfslack-cleaner--token<TOKEN>--message--mpdirectsherry,james,johndoe--user"*"# Delete all messages from certain userslack-cleaner--token<TOKEN>--message--channelgossip--userjohndoe# Delete all messages from bots (especially flooding CI updates)slack-cleaner--token<TOKEN>--message--channelauto-build--bot# Delete all messages older than 2015/09/19slack-cleaner--token<TOKEN>--message--channelgeneral--user"*"--before20150919# Delete all filesslack-cleaner--token<TOKEN>--file--user"*"# Delete all files from certain userslack-cleaner--token<TOKEN>--file--userjohndoe# Delete all snippets and imagesslack-cleaner--token<TOKEN>--file--typessnippets,images# Show information about users, channels:slack-cleaner--token<TOKEN>--info# Delete matching a regexp patternslack-cleaner--token<TOKEN>--pattern"(bar|foo.+)"# TODO add add keep_pinned example, add quiet# Always have a look at help messageslack-cleaner--helpConfiguring appThe cleaner needs you to give Slack's API permission to let it run the
operations it needs. You grant these by registering it as an app in the
workspace you want to use it in.You can grant these permissions to the app by:going toYour Appsselect 'Create New App', fill out an App Name (eg 'Slack Cleaner') and
select the Slack workspace you want to use it inselect 'OAuth & Permissions' in the sidebarscroll down to Scopes and select all scopes you needselect 'Save changes'select 'Install App to Workspace'review the permissions and press 'Authorize'copy the 'OAuth Access Token' shown, and use this token as the--tokenargument to the scriptTipsAfter the task, a backup fileslack-cleaner.<timestamp>.logwill be created in current directory if--logis supplied.If any API problem occurred, try--rate=<delay-in-seconds>to reduce the API call rate (which by default is unlimited).If you see the following warning fromurllib3, consider to install missing
packages:pip install --upgrade requests[security]or just upgrade your Python to 2.7.9.InsecurePlatformWarning: A true SSLContext object is not available.
          This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail.
          For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.CreditsTo all the people who can only afford a free plan. :cry: