Package: slack-cleaner2
slack_cleaner2Bulk delete messages and files on Slack.InstallInstall from PyPi:pipinstallslack-cleaner2latest versionpipinstall-egit+https://github.com/sgratzl/slack_cleaner2.git#egg=slack_cleaner2UsageIn 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.basic usagefromslack_cleaner2import*s=SlackCleaner('SECRET TOKEN')# list of userss.users# list of all kind of channelss.conversations# delete all messages in -bots channelsformsgins.msgs(filter(match('.*-bots'),s.conversations)):# delete messages, its files, and all its replies (thread)msg.delete(replies=True,files=True)# delete all general messages and also iterate over all repliesformsgins.c.general.msgs(with_replies=True):msg.delete()Migration Guides form slack-cleanercontains a series of common pattern in slack cleaner and their counterpart in Slack Cleaner2TokenThe slack 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 toUser Token Scopeand select all scopes you need according to list belowselect 'Save changes'select 'Install App to Workspace'review the permissions and press 'Authorize'copy the 'OAuth Access Token' shown, and use as the first argument toSlackCleanerThe token should start withxoxpand not like bot tokens withxoxb.Beyond granting permissions, if you wish to use this library to delete
messages or files posted by others, you will need to be anOwner or
Adminof the workspace.User Token Scopes by Use CaseGeneral channel and user detectionusers:readchannels:readgroups:readim:readmpim:readDeleting messages from public channelsusers:readchannels:readchannels:historychat:writeDeleting messages from private channelsusers:readgroups:readgroups:historychat:writeDeleting messages from 1:1 IMsNote: 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.im:readim:historyusers:readchat:writeDeleting messages from multi-person IMsmpim:readmpim:historyusers:readchat:writeDeleting filesfiles:readusers:readfiles:writeAll User Token scopesDockerThere is no direct docker file available, however since it is a python module one can easily create one:FROM python:3.9-alpine

LABEL maintainer="Samuel Gratzl <sam@sgratzl.com>"

VOLUME "/backup"
WORKDIR /backup

RUN pip --no-cache-dir install slack-cleaner2

CMD ["python", "-"]An Docker image namedslack_cleaner2with this Dockerfile would be used likecatmyscript.py|dockerrun-islack_cleaner2Themyscript.pyfile is a python script using the slack_cleaner2 module.CreditsTo all the people who can only afford a free plan. :cry:DevelopmentReleasebumpversionpatch
gitcommit-am'release vX.X.X'gittagvX.X.X
invokerelease
gitpush
gitpush--tagschange version inslack_cleaner2/_info.py