{"id":15576723,"url":"https://github.com/sgratzl/slack_cleaner2","last_synced_at":"2025-04-13T00:49:27.609Z","repository":{"id":35790054,"uuid":"208659286","full_name":"sgratzl/slack_cleaner2","owner":"sgratzl","description":":memo: Python3 module for deleting Slack messages and files using the Slack REST API","archived":false,"fork":false,"pushed_at":"2024-08-16T22:14:35.000Z","size":410,"stargazers_count":238,"open_issues_count":8,"forks_count":23,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-13T00:49:22.330Z","etag":null,"topics":["pypi","python","python3","slack","slack-api","slack-cleaner","slack-free-plan","slackapi"],"latest_commit_sha":null,"homepage":"https://slack-cleaner2.readthedocs.io","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["sgratzl"]}},"created_at":"2019-09-15T21:23:49.000Z","updated_at":"2025-03-07T21:09:28.000Z","dependencies_parsed_at":"2022-07-21T09:02:33.853Z","dependency_job_id":"a37e0959-d01e-4738-abd3-682886c0fec6","html_url":"https://github.com/sgratzl/slack_cleaner2","commit_stats":{"total_commits":377,"total_committers":21,"mean_commits":"17.952380952380953","dds":0.5198938992042441,"last_synced_commit":"69155dbf7cfd7c6a92bdf26abfed86811cb31c45"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgratzl%2Fslack_cleaner2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgratzl%2Fslack_cleaner2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgratzl%2Fslack_cleaner2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgratzl%2Fslack_cleaner2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgratzl","download_url":"https://codeload.github.com/sgratzl/slack_cleaner2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650436,"owners_count":21139672,"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","python3","slack","slack-api","slack-cleaner","slack-free-plan","slackapi"],"created_at":"2024-10-02T18:55:09.507Z","updated_at":"2025-04-13T00:49:27.591Z","avatar_url":"https://github.com/sgratzl.png","language":"Python","funding_links":["https://github.com/sponsors/sgratzl"],"categories":[],"sub_categories":[],"readme":"# slack_cleaner2\n\n[![License: MIT][mit-image]][mit-url] [![Github Actions][github-actions-image]][github-actions-url] [![PyPi][pypi-image]][pypi-url] [![Read the Docs][docs-image]][docs-url]\n\nBulk delete messages and files on Slack.\n\n## Install\n\nInstall from PyPi:\n\n```sh\npip install slack-cleaner2\n```\n\nlatest version\n\n```sh\npip install -e git+https://github.com/sgratzl/slack_cleaner2.git#egg=slack_cleaner2\n```\n\n## Usage\n\nIn contrast to the original version (https://github.com/kfei/slack-cleaner) this version is a focusing on pure python package that allows for easy scripting instead of a vast amount of different command line arguments.\n\nbasic usage\n\n```python\nfrom slack_cleaner2 import *\n\ns = SlackCleaner('SECRET TOKEN')\n# list of users\ns.users\n# list of all kind of channels\ns.conversations\n\n# delete all messages in -bots channels\nfor msg in s.msgs(filter(match('.*-bots'), s.conversations)):\n  # delete messages, its files, and all its replies (thread)\n  msg.delete(replies=True, files=True)\n\n# delete all general messages and also iterate over all replies\nfor msg in s.c.general.msgs(with_replies=True):\n  msg.delete()\n```\n\n[Migration Guides form slack-cleaner](https://github.com/sgratzl/slack-cleaner/issues/79) contains a series of common pattern in slack cleaner and their counterpart in Slack Cleaner2\n\n## Token\n\nThe slack 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)\n1. select 'Create New App', fill out an App Name (eg 'Slack Cleaner') and\n   select the Slack workspace you want to use it in\n1. select 'OAuth \u0026 Permissions' in the sidebar\n1. scroll down to **User Token Scope** and select all scopes you need according to list below\n1. select 'Save changes'\n1. select 'Install App to Workspace'\n1. review the permissions and press 'Authorize'\n1. copy the 'OAuth Access Token' shown, and use as the first argument to `SlackCleaner`\n\nThe token should start with **xoxp** and not like bot tokens with **xoxb**.\n\nBeyond granting permissions, if you wish to use this library 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) of the workspace.\n\n### User Token Scopes by Use Case\n\n#### General channel and user detection\n\n-   `users:read`\n-   `channels:read`\n-   `groups:read`\n-   `im:read`\n-   `mpim:read`\n\n#### Deleting messages from public channels\n\n-   `users:read`\n-   `channels:read`\n-   `channels:history`\n-   `chat:write`\n\n#### Deleting messages from private channels\n\n-   `users:read`\n-   `groups:read`\n-   `groups:history`\n-   `chat:write`\n\n#### Deleting messages from 1:1 IMs\n\n**Note**: You can only delete your own messages, not the ones of others. This is due to a restriction in the Slack API and there is nothing one can do about it.\n\n-   `im:read`\n-   `im:history`\n-   `users:read`\n-   `chat:write`\n\n#### Deleting messages from multi-person IMs\n\n-   `mpim:read`\n-   `mpim:history`\n-   `users:read`\n-   `chat:write`\n\n#### Deleting files\n\n-   `files:read`\n-   `users:read`\n-   `files:write`\n\n### All User Token scopes\n\n![user token scopes](https://user-images.githubusercontent.com/4129778/81291893-f20b9580-906a-11ea-80a8-f19f3e6878e9.png)\n\n## Docker\n\nThere is no direct docker file available, however since it is a python module one can easily create one:\n\n```\nFROM python:3.9-alpine\n\nLABEL maintainer=\"Samuel Gratzl \u003csam@sgratzl.com\u003e\"\n\nVOLUME \"/backup\"\nWORKDIR /backup\n\nRUN pip --no-cache-dir install slack-cleaner2\n\nCMD [\"python\", \"-\"]\n```\n\nAn Docker image named `slack_cleaner2` with this Dockerfile would be used like\n\n```sh\ncat myscript.py | docker run -i slack_cleaner2\n```\n\nThe `myscript.py` file is a python script using the slack_cleaner2 module.\n\n## Credits\n\n**To all the people who can only afford a free plan. :cry:**\n\n## Development\n\n### Release\n\n```sh\nbumpversion patch\ngit commit -am 'release vX.X.X'\ngit tag vX.X.X\ninvoke release\ngit push\ngit push --tags\n```\n\nchange version in `slack_cleaner2/_info.py`\n\n[mit-image]: https://img.shields.io/badge/License-MIT-yellow.svg\n[mit-url]: https://opensource.org/licenses/MIT\n[github-actions-image]: https://github.com/sgratzl/slack_cleaner2/workflows/python/badge.svg\n[github-actions-url]: https://github.com/sgratzl/slack_cleaner2/actions\n[pypi-image]: https://img.shields.io/pypi/v/slack_cleaner2\n[pypi-url]: https://pypi.python.org/pypi/slack_cleaner2/\n[docs-image]: https://readthedocs.org/projects/slack-cleaner2/badge/?version=latest\n[docs-url]: https://slack-cleaner2.readthedocs.io/en/latest/?badge=latest\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgratzl%2Fslack_cleaner2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgratzl%2Fslack_cleaner2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgratzl%2Fslack_cleaner2/lists"}