All Projects β†’ sgratzl β†’ Slack_cleaner2

sgratzl / Slack_cleaner2

Licence: mit
πŸ“ Python3 module for deleting Slack messages and files using the Slack REST API

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Slack cleaner2

Slack Cleaner
delete slack messages and files. An improved version is at:
Stars: ✭ 329 (+257.61%)
Mutual labels:  slack-api, slack, pypi
Slacker
Slack Bot Framework
Stars: ✭ 495 (+438.04%)
Mutual labels:  slack-api, slack
Chat
Chat with your team while you collaborate over code using VS Live Share
Stars: ✭ 468 (+408.7%)
Mutual labels:  slack-api, slack
Whatis
Whatis bot server for Slack!
Stars: ✭ 22 (-76.09%)
Mutual labels:  slack-api, slack
slackblocks
🎲 Python API for Building Messages Using the Slack Block Kit API
Stars: ✭ 32 (-65.22%)
Mutual labels:  slack, slack-api
Java Slack Sdk
Slack Developer Kit (including Bolt for Java) for any JVM language
Stars: ✭ 393 (+327.17%)
Mutual labels:  slack-api, slack
Slack Black Theme
slack theme, dark theme for slack, black theme slack black theme
Stars: ✭ 531 (+477.17%)
Mutual labels:  slack-api, slack
slack-web-api
Simple, convenient, and configurable HTTP client for making requests to Slack’s Web API. Deno port of @slack/web-api
Stars: ✭ 16 (-82.61%)
Mutual labels:  slack, slack-api
Slack Ruby Client
A Ruby and command-line client for the Slack Web, Real Time Messaging and Event APIs.
Stars: ✭ 957 (+940.22%)
Mutual labels:  slack-api, slack
Slack Api
A super simple PHP wrapper for Slack API
Stars: ✭ 34 (-63.04%)
Mutual labels:  slack-api, slack
Bolt Starter
A Bolt ⚑️ app template with useful settings for easier development
Stars: ✭ 37 (-59.78%)
Mutual labels:  slack-api, slack
WebsocketClientLite.PCL
websocket Client Lite PCL - Xaramrin
Stars: ✭ 22 (-76.09%)
Mutual labels:  slack, slack-api
dienstplan
Slack bot app for duty rotations
Stars: ✭ 14 (-84.78%)
Mutual labels:  slack, slack-api
google-calendar-slack-status
Automatically sync your Google Calendar events to your Slack status
Stars: ✭ 33 (-64.13%)
Mutual labels:  slack, slack-api
Fantasy Football Metrics Weekly Report
Command line application to create weekly reports (containing stats, metrics, and rankings) for Fantasy Football leagues on the following platforms: Yahoo, Fleaflicker, Sleeper, ESPN.
Stars: ✭ 62 (-32.61%)
Mutual labels:  slack-api, slack
Slackpirate
Slack Enumeration and Extraction Tool - extract sensitive information from a Slack Workspace
Stars: ✭ 512 (+456.52%)
Mutual labels:  slack-api, slack
Slacknimate
πŸ‘― Realtime text animation for Slack chatops
Stars: ✭ 250 (+171.74%)
Mutual labels:  slack-api, slack
vscode-chat
Chat with your team while you collaborate over code using VS Live Share
Stars: ✭ 496 (+439.13%)
Mutual labels:  slack, slack-api
Slack Cli
Powerful Slack CLI via pure bash. Rich messaging, uploads, posts, piping, oh my!
Stars: ✭ 850 (+823.91%)
Mutual labels:  slack-api, slack
Slack Poster
Simple gem to post messages on Slack using web hooks.
Stars: ✭ 49 (-46.74%)
Mutual labels:  slack-api, slack

slack_cleaner2

License: MIT Github Actions PyPi Read the Docs

Bulk delete messages and files on Slack.

Install

Install from PyPi:

pip install slack-cleaner2

latest version

pip install -e git+https://github.com/sgratzl/slack_cleaner2.git#egg=slack_cleaner2

Usage

In 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 usage

from slack_cleaner2 import *

s = SlackCleaner('SECRET TOKEN')
# list of users
s.users
# list of all kind of channels
s.conversations

# delete all messages in -bots channels
for msg in s.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 replies
for msg in s.c.general.msgs(with_replies=True):
  msg.delete()

Migration Guides form slack-cleaner contains a series of common pattern in slack cleaner and their counterpart in Slack Cleaner2

Token

The 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:

  1. going to Your Apps
  2. select 'Create New App', fill out an App Name (eg 'Slack Cleaner') and select the Slack workspace you want to use it in
  3. select 'OAuth & Permissions' in the sidebar
  4. scroll down to User Token Scope and select all scopes you need according to list below
  5. select 'Save changes'
  6. select 'Install App to Workspace'
  7. review the permissions and press 'Authorize'
  8. copy the 'OAuth Access Token' shown, and use as the first argument to SlackCleaner

The token should start with xoxp and not like bot tokens with xoxb.

Beyond granting permissions, if you wish to use this library to delete messages or files posted by others, you will need to be an Owner or Admin of the workspace.

User Token Scopes by Use Case

General channel and user detection

  • users:read
  • channels:read
  • groups:read
  • im:read
  • mpim:read

Deleting messages from public channels

  • users:read
  • channels:read
  • channels:history
  • chat:write

Deleting messages from private channels

  • users:read
  • groups:read
  • groups:history
  • chat:write

Deleting messages from 1:1 IMs

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.

  • im:read
  • im:history
  • users:read
  • chat:write

Deleting messages from multi-person IMs

  • mpim:read
  • mpim:history
  • users:read
  • chat:write

Deleting files

  • files:read
  • users:read
  • files:write

All User Token scopes

user token scopes

Docker

There is no direct docker file available, however since it is a python module one can easily create one:

FROM python:3.7-alpine

LABEL maintainer="Samuel Gratzl <[email protected]>"

VOLUME "/backup"
WORKDIR /backup

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

CMD ["python", "-"]

An Docker image named slack_cleaner2 with this Dockerfile would be used like

cat myscript.py | docker run -i slack_cleaner2

The myscript.py file is a python script using the slack_cleaner2 module.

Credits

To all the people who can only afford a free plan. 😒

Development

Release

bumpversion patch
git commit -am 'release vX.X.X'
git tag vX.X.X
invoke release
git push 
git push --tags

change version in slack_cleaner2/_info.py

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].