{"id":13563696,"url":"https://github.com/sgratzl/slack-cleaner","last_synced_at":"2025-04-04T12:09:45.947Z","repository":{"id":46537650,"uuid":"102904692","full_name":"sgratzl/slack-cleaner","owner":"sgratzl","description":"delete slack messages and files. An improved version is at: ","archived":false,"fork":false,"pushed_at":"2021-08-12T11:31:43.000Z","size":220,"stargazers_count":366,"open_issues_count":2,"forks_count":42,"subscribers_count":14,"default_branch":"main","last_synced_at":"2024-10-13T09:45:26.510Z","etag":null,"topics":["pypi","python","slack","slack-api","slack-cleaner","slack-free-plan"],"latest_commit_sha":null,"homepage":"https://github.com/sgratzl/slack_cleaner2","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sgratzl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["sgratzl"]}},"created_at":"2017-09-08T21:10:05.000Z","updated_at":"2024-10-03T14:52:12.000Z","dependencies_parsed_at":"2022-08-12T12:51:07.384Z","dependency_job_id":null,"html_url":"https://github.com/sgratzl/slack-cleaner","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgratzl%2Fslack-cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgratzl%2Fslack-cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgratzl%2Fslack-cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgratzl%2Fslack-cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgratzl","download_url":"https://codeload.github.com/sgratzl/slack-cleaner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174454,"owners_count":20896078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pypi","python","slack","slack-api","slack-cleaner","slack-free-plan"],"created_at":"2024-08-01T13:01:22.354Z","updated_at":"2025-04-04T12:09:45.930Z","avatar_url":"https://github.com/sgratzl.png","language":"Python","funding_links":["https://github.com/sponsors/sgratzl"],"categories":["Python"],"sub_categories":[],"readme":"# slack-cleaner\n[![License: MIT][mit-image]][mit-url] [![PyPi][pypi-image]][pypi-url]\n\nBulk delete messages and files on Slack.\n\nthis is a fork of https://github.com/kfei/slack-cleaner\n\nAn improved Python module based version is located at https://github.com/sgratzl/slack_cleaner2\n\n## Install\n\nInstall from Pip:\n\n```bash\npip install slack-cleaner\n```\n\ncurrent development version:\n\n```\npip install -e git+https://github.com/sgratzl/slack-cleaner.git#egg=slack-cleaner\n```\n\nIf you prefer Docker, there is a pre-built Docker image as well:\n\n```bash\ndocker pull sgratzl/slack-cleaner\n```\n\nJust use `docker run -it --rm sgratzl/slack-cleaner -c \"slack-cleaner ...\"` for each command or jump into a shell using `docker run -it --rm sgratzl/slack-cleaner`.\n\nInstall for Fedora or EPEL7\n\n[@rapgro](https://github.com/rapgro) maintains packages for both Fedora and EPEL7\n\n```bash\n# Fedora\ndnf install slack-cleaner\n# EPEL7\nyum install -y epel-release ; yum install slack-cleaner\n```\n\n## Arguments\n\n```\nusage: slack-cleaner [-h] --token TOKEN [--log] [--quiet] [--rate RATE]\n                     [--as_user] [--message | --file | --info] [--regex]\n                     [--channel CHANNEL] [--direct DIRECT] [--group GROUP]\n                     [--mpdirect MPDIRECT] [--user USER] [--botname BOTNAME]\n                     [--bot] [--keeppinned] [--after AFTER] [--before BEFORE]\n                     [--types TYPES] [--pattern PATTERN] [--perform]\n\noptional arguments:\n  -h, --help           show this help message and exit\n  --token TOKEN        Slack API token (https://api.slack.com/web) or SLACK_TOKEN env var\n  --log                Create a log file in the current directory\n  --quiet              Run quietly, does not log messages deleted\n  --proxy              Proxy Server url:port\n  --verify             Verify option for Session (http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification)\n  --rate RATE          Delay between API calls (in seconds)\n  --as_user            Pass true to delete the message as the authed user. Bot\n                       users in this context are considered authed users.\n  --message            Delete messages\n  --file               Delete files\n  --info               Show information\n  --regex              Interpret channel, direct, group, and mpdirect as regex\n  --channel CHANNEL    Channel name's, e.g., general\n  --direct DIRECT      Direct message's name, e.g., sherry\n  --group GROUP        Private group's name\n  --mpdirect MPDIRECT  Multiparty direct message's name, e.g.,\n                       sherry,james,johndoe\n  --user USER          Delete messages/files from certain user\n  --botname BOTNAME    Delete messages/files from certain bots. Implies '--bot'\n  --bot                Delete messages from bots\n  --keeppinned         exclude pinned messages from deletion\n  --after AFTER        Delete messages/files newer than this time (YYYYMMDD)\n  --before BEFORE      Delete messages/files older than this time (YYYYMMDD)\n  --types TYPES        Delete files of a certain type, e.g., posts,pdfs\n  --pattern PATTERN    Delete messages/files with specified pattern or if one of their attachments matches (regex)\n  --perform            Perform the task\n```\n\n## Permission Scopes needed\n\nThe permissions to grant depend on what you are going to use the script for.\nGrant the permissions below depending on your use.\n\nBeyond granting permissions, if you wish to use this script to delete\nmessages or files posted by others, you will need to be an [Owner or\nAdmin](https://get.slack.help/hc/en-us/articles/218124397-Change-a-member-s-role)\nof the workspace.\n\n#### Deleting messages from public channels\n\n- `channels:history`\n- `channels:read`\n- `chat:write` (or both `chat:write:user` and `chat:write:bot` for older apps)\n- `users:read`\n\n#### Deleting messages from private channels\n\n- `groups:history`\n- `groups:read`\n- `chat:write` (or `chat:write:user` for older apps)\n- `users:read`\n\n#### Deleting messages from 1:1 IMs\n\n- `im:history`\n- `im:read`\n- `chat:write` (or `chat:write:user` for older apps)\n- `users:read`\n\n#### Deleting messages from multi-person IMs\n\n- `mpim:history`\n- `mpim:read`\n- `chat:write` (or `chat:write:user` for older apps)\n- `users:read`\n\n#### Deleting files\n\n- `files:read`\n- `files:write` (or `files:write:user` for older apps)\n- `users:read`\n\n## Usage\n\n```bash\n# Delete all messages from a channel\nslack-cleaner --token \u003cTOKEN\u003e --message --channel general --user \"*\"\n\n# Delete all messages from a private group aka private channel\nslack-cleaner --token \u003cTOKEN\u003e --message --group hr --user \"*\"\n\n# Delete all messages from a direct message channel\nslack-cleaner --token \u003cTOKEN\u003e --message --direct sherry --user johndoe\n\n# Delete all messages from a multiparty direct message channel. Note that the\n# list of usernames must contains yourself\nslack-cleaner --token \u003cTOKEN\u003e --message --mpdirect sherry,james,johndoe --user \"*\"\n\n# Delete all messages from certain user\nslack-cleaner --token \u003cTOKEN\u003e --message --channel gossip --user johndoe\n\n# Delete all messages from bots (especially flooding CI updates)\nslack-cleaner --token \u003cTOKEN\u003e --message --channel auto-build --bot\n\n# Delete all messages older than 2015/09/19\nslack-cleaner --token \u003cTOKEN\u003e --message --channel general --user \"*\" --before 20150919\n\n# Delete all files\nslack-cleaner --token \u003cTOKEN\u003e --file --user \"*\"\n\n# Delete all files from certain user\nslack-cleaner --token \u003cTOKEN\u003e --file --user johndoe\n\n# Delete all snippets and images\nslack-cleaner --token \u003cTOKEN\u003e --file --types snippets,images\n\n# Show information about users, channels:\nslack-cleaner --token \u003cTOKEN\u003e --info\n\n# Delete matching a regexp pattern\nslack-cleaner --token \u003cTOKEN\u003e --pattern \"(bar|foo.+)\"\n\n# TODO add add keep_pinned example, add quiet\n\n# Always have a look at help message\nslack-cleaner --help\n```\n\n## Configuring app\n\nThe cleaner needs you to give Slack's API permission to let it run the\noperations it needs. You grant these by registering it as an app in the\nworkspace you want to use it in.\n\nYou can grant these permissions to the app by:\n\n1. going to [Your Apps](https://api.slack.com/apps)\n2. select 'Create New App', fill out an App Name (eg 'Slack Cleaner') and\n   select the Slack workspace you want to use it in\n3. select 'OAuth \u0026 Permissions' in the sidebar\n4. scroll down to Scopes and select all scopes you need\n5. select 'Save changes'\n6. select 'Install App to Workspace'\n7. review the permissions and press 'Authorize'\n8. copy the 'OAuth Access Token' shown, and use this token as the `--token`\n   argument to the script\n\n## Tips\n\nAfter the task, a backup file `slack-cleaner.\u003ctimestamp\u003e.log` will be created in current directory if `--log` is supplied.\n\nIf any API problem occurred, try `--rate=\u003cdelay-in-seconds\u003e` to reduce the API call rate (which by default is unlimited).\n\nIf you see the following warning from `urllib3`, consider to install missing\npackages: `pip install --upgrade requests[security]` or just upgrade your Python to 2.7.9.\n\n```\nInsecurePlatformWarning: A true SSLContext object is not available.\n          This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail.\n          For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.\n```\n\n## Credits\n\n**To all the people who can only afford a free plan. :cry:**\n\n\n[mit-image]: https://img.shields.io/badge/License-MIT-yellow.svg\n[mit-url]: https://opensource.org/licenses/MIT\n[pypi-image]: https://pypip.in/version/slack-cleaner/badge.svg\n[pypi-url]: https://pypi.python.org/pypi/slack-cleaner/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgratzl%2Fslack-cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgratzl%2Fslack-cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgratzl%2Fslack-cleaner/lists"}