# slack_cleaner2
[![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]
Bulk delete messages and files on Slack.
## Install
Install from PyPi:
```bash
pip install slack-cleaner2
```
latest version
```bash
pip install -e git+https://github.com/sgratzl/slack_cleaner2.git
```
## 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
```python
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)):
msg.delete()
for msg in s.c.general.msgs():
msg.delete()
```
## Tokens
You will need to generate a Slack legacy *user* token to use slack-cleaner. You can generate a token [here](https://api.slack.com/custom-integrations/legacy-tokens):
[https://api.slack.com/custom-integrations/legacy-tokens](https://api.slack.com/custom-integrations/legacy-tokens).
The token should start with **xoxp** and not like bot tokens with **xoxb**.
## Permission Scopes needed
The 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 an [Owner or
Admin](https://get.slack.help/hc/en-us/articles/218124397-Change-a-member-s-role)
of the workspace.
#### General channel and user detection
- `channels:read`
- `users:read`
- `users.profile:read`
- `users:read.email`
- `im:read`
- `mpim:read`
#### Deleting messages from public channels
- `channels:history`
- `channels:read`
- `chat:write:user`
- `users:read`
#### Deleting messages from private channels
- `groups:history`
- `groups:read`
- `chat:write:user`
- `users:read`
#### Deleting messages from 1:1 IMs
- `im:history`
- `im:read`
- `chat:write:user`
- `users:read`
#### Deleting messages from multi-person IMs
- `mpim:history`
- `mpim:read`
- `chat:write:user`
- `users:read`
#### Deleting files
- `files:read`
- `files:write:user`
- `users:read`
## Configuring app
The 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](https://api.slack.com/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 Scopes and select all scopes you need
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 this token as the `--token`
argument to the script
## Credits
**To all the people who can only afford a free plan. :cry:**
## Development
### Release
```bash
python setup.py clean sdist bdist_wheel
twine upload dist/*
```
change version in `slack_cleaner2/_info.py`
[mit-image]: https://img.shields.io/badge/License-MIT-yellow.svg
[mit-url]: https://opensource.org/licenses/MIT
[github-actions-image]: https://github.com/sgratzl/slack_cleaner2/workflows/python/badge.svg
[github-actions-url]: https://github.com/sgratzl/slack_cleaner2/actions
[pypi-image]: https://pypip.in/version/slack_cleaner2/badge.svg
[pypi-url]: https://pypi.python.org/pypi/slack_cleaner2/
[docs-image]: https://readthedocs.org/projects/slack-cleaner2/badge/?version=latest
[docs-url]: https://slack-cleaner2.readthedocs.io/en/latest/?badge=latest
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源分类:Python库 所属语言:Python 资源全名:slack_cleaner2-2.1.0.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
slack_cleaner2-2.1.0.tar.gz (33个子文件)
slack_cleaner2-2.1.0
MANIFEST.in 238B
PKG-INFO 6KB
pyproject.toml 90B
docs
history.rst 29B
conf.py 5KB
usage.rst 90B
installation.rst 1KB
modules.rst 193B
authors.rst 29B
readme.rst 28B
index.rst 290B
contributing.rst 34B
slack_cleaner2
predicates.py 5KB
cli.py 7KB
logger.py 3KB
util.py 615B
__main__.py 128B
__init__.py 670B
model.py 27KB
_info.py 167B
tests
__init__.py 18B
test_slack_cleaner2.py 730B
LICENSE 1KB
setup.cfg 326B
slack_cleaner2.egg-info
PKG-INFO 6KB
requires.txt 55B
not-zip-safe 2B
SOURCES.txt 708B
top_level.txt 15B
dependency_links.txt 1B
requirements.txt 58B
setup.py 1KB
README.md 4KB
共 33 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功