kfei / slack-cleaner Goto Github PK
View Code? Open in Web Editor NEW:speech_balloon: Bulk delete messages and files on Slack
License: MIT License
:speech_balloon: Bulk delete messages and files on Slack
License: MIT License
Using this command:
slack-cleaner --token <TOKEN> --message --direct sherry --user johndoe
Only 6 messages were listed for deletion. This DM channel however contains 10 visible DMs when viewed in Slack. Using --perform
only deleted the 6 listed messages and left the 4 remaining others.
The deleted messages were neither the most recent nor the oldest, they were in the middle.
Re-runing the same command still leaves the 4 remaining messages intact, with output 0 message(s) will be cleaned.
.
When trying to erase all messages from a user we get this result:
Channel, direct message or private group not found
We used:
slack-cleaner --token [TOKEN] --message --channel gossip --user [USER] --perform
Any ideas?
On the mobile app, I see more messages that weren't deleted, those that are filtered on desktop, with the note "There's more to this conversation. to see and search this conversation's full history, upgrade to one of our paid plans." A bulk of our messages are in this section that Slack is trying to hide to incentivize us to pay. Is there a way to pull these via API? Does this have to do with the permission scope?
I've pulled from docker but I'm not sure whether I'm running it correctly. This is what I'm trying...
'C:\Users\me> docker run kfei/slack-cleaner slack-cleaner --token "xoxp-#####" --message --channel general --user "*"`
And this is the error I get:
import: unable to open X server `' @ error/import.c/ImportImageCommand/364.
import: unable to open X server `' @ error/import.c/ImportImageCommand/364.
/usr/local/bin/slack-cleaner: line 7: from: command not found
/usr/local/bin/slack-cleaner: slack-cleaner: line 10: syntax error near unexpected token `('
/usr/local/bin/slack-cleaner: slack-cleaner: line 10: ` sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])'
Any guidance would be greatly appreciated. I generated the token from https://api.slack.com/docs/oauth-test-tokens
The underlying python time.sleep() method accepts a float, giving you more resolution that 1s. However, the argument was typed as int, so sub-second rates (eg, 0.5 or 0.2) which may be slow enough for the API while still being significantly faster than 1s cannot be utilized.
Get this error running:
slack-cleaner --token --file --user "*"
Using the slack-cleaner installed from pip.
Tried adding all scopes to my app and reinstalling app.
I had an existing token I tried to with slack-cleaner; it failed with a cryptic invalid_scope error. Eventually I found documentation that certain APIs only work with user tokens (ones that start wtih xoxp and not bot tokens xoxb).
A quick note on the documentation might save others some trouble.
Is there a way to remove messages posted by APPs? They dont seem to be recognized as bots. For eg, removing messages posted by Trello or Bitbucket apps,
I am trying to delete all messages from all channels/groups for all users before a certain date. How would I modify this command to achieve that?
slack-cleaner --token --message --channel general --user "*" --before 20180424
Thank you.
I think an option to keep pinned messages would be great, as it's often important information.
Hi,
You did a great job with this library. Thank you.
A nice feature would be to use argument --no-log to skip logging ;)
Get error
root@localhost:~# pip install slack-cleaner
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
sys.exit(main())
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib/python2.7/locale.py", line 581, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
Could you add an example of how to clean messages with the docker container?
File "c:\proj\venvs\xxx\lib\site-packages\slack_cleaner\cli.py", line 98
print 'No more messsages'
^
SyntaxError: Missing parentheses in call to 'print'
I don't see a flag that will prevent terminal from showing the message content that is being deleted. I am using this to clean-up our messages and avoid that 12k message from slack. But I don't want to see the content of people's messages. Anyway to do like -silence?
New to Slack apps. Created an app on slack to get a token. Turned on assorted permissions but when I run the slack-cleaner I ultimately get a stack trace and 'slacker.Error: invalid_auth'.
It would be helpful if the readme had a short description of what to do on the Slack side of config.
Your application is great!
It works like a charm.
I have a special case
I use some different BOT in a channel. How can I delete messages of certain BOT?
Again, thank you very much
I'm running
slack-cleaner --token xx-xxx-xxx --message --direct U000000 --user U000001 --before 2018-08-01
user U000000 is my user ID (copied from slack, under user "userID") and the U000001 person I have direct message with, this channel definitely exists but I'm getting direct message not found. Am I using the wrong userID? ie. should I use their email, not sure because there is no username on my slack channel ie "johndoe" the format is "john doe" and is a first/last name string
Dear
I found some deactivated user and want to delete the msg from this user.
after ai execute
slack-cleaner --token --message --direct deactivateduser --user "*" --perform
i can only delete my msg
and shows
Failed to delete ->
{ u'text': u'\u4e5f\u53ea\u6709\u522a\u6389\u5e7e\u5f35\u800c\u5df2\u5566',
u'ts': u'1446101041.000003',
u'type': u'message',
u'user': u'U07BQB98U'}
It's any possible to delete this user's all msg?
thanks.
I tried to delete message from IFTTT bot but it shows the error as the attached pictures. When I ran the command
slack-cleaner --token= --message --channel general --bot --perform
it deleted only 1 message from that BOT. Could you please fix it. Thank you.
I have a slack channel populated by and incoming webhook bot. I want to clear the channel, I have paid account maybe I can do this within admin? I use this command and just get loads of failed to delete messages, any help would be great!
This is the command I use
slack-cleaner --token=###mytoken --message --channel my-channel --bot --perform --log --rate 1
Installed slack-cleaner via pip without an issue. Goal is to remove all files in the account, however when running the command I get the following feedback:
$ sudo slack-cleaner --token SECRET --file --user "*" --rate=1
Running slack-cleaner v0.3.0
Traceback (most recent call last):
File "/usr/local/bin/slack-cleaner", line 7, in <module>
from slack_cleaner.cli import main
File "/Library/Python/2.7/site-packages/slack_cleaner/cli.py", line 61, in <module>
init_user_dict()
File "/Library/Python/2.7/site-packages/slack_cleaner/cli.py", line 52, in init_user_dict
res = slack.users.list().body
File "/Library/Python/2.7/site-packages/slacker/__init__.py", line 164, in list
return self.get('users.list', params={'presence': int(presence)})
File "/Library/Python/2.7/site-packages/slacker/__init__.py", line 90, in get
api, **kwargs
File "/Library/Python/2.7/site-packages/slacker/__init__.py", line 72, in _request
raise Error(response.error)
slacker.Error: invalid_auth
Hi, how can use this tool on windows 10 ? Thanks
I want to execute the command for executing messages for bots. But i get timeouts.
Message:
Failed to delete (429 Client Error: Too Many Requests for url: https://slack.com/api/chat.delete?token=tokenname)->
Is it possible to add a timeout in the command. like seconds and minutes before deleting a message(bot/app)?
Install on Python 3.5. When entering "slack-cleaner" into the command line (with or without a command), the response is "failed to create process".
Windows 7, ConEmu, running the process as admin. Any thoughts?
Thanks for this very useful program, it was an extremely pleasing experience watching all of slackbots old reminder messages disappear!
I've encountered an issue trying to clean up bot posts in public channels, the syntax:
slack-cleaner --token TOKEN --channel test --message --bot --perform
cleans posts by users as well as bots (almost as if I hadn't used the --bot argument).
For example, in an empty test channel I posted two "asdasd" messages and ran the cleaner using the aforementioned synatx and got the following result:
Both my messages get deleted and I'm pretty sure I'm not a bot. Any ideas as to what I'm doing wrong?
When trying to erase all messages from a private channel, but get this result:
Channel, direct message or private group not found
I used:
slack-cleaner --token TOKEN --message --group name_of_channel --before 20181101
I also used it:
slack-cleaner --token TOKEN --message --channel name_of_channel --before 20181101
I don't think it works with a Private Channel.
Can anyone tell me?
Thank's.
Display name: slackbot, member ID: USLACKBOT
slack-cleaner --token=[token] --file --user uslackbot
slack-cleaner --token=[token] --file --user slackbot
slack-cleaner --token=[token] --message --direct slackbot --bot
slack-cleaner --token=[token] --message --direct uslackbot --bot
Running slack-cleaner v0.3.0
Traceback (most recent call last):
File "/usr/local/bin/slack-cleaner", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/slack_cleaner/cli.py", line 337, in main
message_cleaner()
File "/usr/local/lib/python3.6/site-packages/slack_cleaner/cli.py", line 286, in message_cleaner
_channel_id = get_direct_id_by_name(args.direct_name)
File "/usr/local/lib/python3.6/site-packages/slack_cleaner/cli.py", line 244, in get_direct_id_by_name
_user_id = get_user_id_by_name(name)
File "/usr/local/lib/python3.6/site-packages/slack_cleaner/cli.py", line 224, in get_user_id_by_name
for k, v in user_dict.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'
I'm trying "slack-cleaner --token "xoxp-XXX" --message --channel "geraldotest"" and it's only listing 0 messages, no matter what....
Also tryed:
slack-cleaner --token "xoxp-XXX" --message --direct user1--user me_user2
I get:
Running slack-cleaner v0.3.0
Channel, direct message or private group not found
Any hint on what might be happening? Any way that I can see debugging info?
Thank you.
Getting this on A LOT of files.... I ran the following:
slack-cleaner --token xxxxxxxxxxxxxxx --file --types snippets,images
Failed to delete ->
{ 'channels': ['CAEABN55M'],
'comments_count': 0,
'created': 1529417675,
'display_as_bot': False,
'editable': False,
'external_type': '',
'filetype': 'jpg',
'groups': [],
'id': 'FB9JWMTL1',
'image_exif_rotation': 1,
'ims': [],
'is_external': False,
'is_public': True,
'mimetype': 'image/jpeg',
'mode': 'hosted',
'name': 'Image uploaded from iOS.jpg',
'original_h': 5079,
'original_w': 3726,
'permalink': 'https://dfspowerhour.slack.com/files/U7Y8BL5G9/FB9JWMTL1/image_uploaded_from_ios.jpg',
'permalink_public': 'https://slack-files.com/T50LX5FEF-FB9JWMTL1-082e15034f',
'pretty_type': 'JPEG',
'public_url_shared': False,
'size': 672210,
'thumb_1024': 'https://files.slack.com/files-tmb/T50LX5FEF-FB9JWMTL1-f94c9acfef/image_uploaded_from_ios_1024.jpg',
'thumb_1024_h': 1024,
'thumb_1024_w': 751,
'thumb_160': 'https://files.slack.com/files-tmb/T50LX5FEF-FB9JWMTL1-f94c9acfef/image_uploaded_from_ios_160.jpg',
'thumb_360': 'https://files.slack.com/files-tmb/T50LX5FEF-FB9JWMTL1-f94c9acfef/image_uploaded_from_ios_360.jpg',
'thumb_360_h': 360,
'thumb_360_w': 264,
'thumb_480': 'https://files.slack.com/files-tmb/T50LX5FEF-FB9JWMTL1-f94c9acfef/image_uploaded_from_ios_480.jpg',
'thumb_480_h': 480,
'thumb_480_w': 352,
'thumb_64': 'https://files.slack.com/files-tmb/T50LX5FEF-FB9JWMTL1-f94c9acfef/image_uploaded_from_ios_64.jpg',
'thumb_720': 'https://files.slack.com/files-tmb/T50LX5FEF-FB9JWMTL1-f94c9acfef/image_uploaded_from_ios_720.jpg',
'thumb_720_h': 720,
'thumb_720_w': 528,
'thumb_80': 'https://files.slack.com/files-tmb/T50LX5FEF-FB9JWMTL1-f94c9acfef/image_uploaded_from_ios_80.jpg',
'thumb_800': 'https://files.slack.com/files-tmb/T50LX5FEF-FB9JWMTL1-f94c9acfef/image_uploaded_from_ios_800.jpg',
'thumb_800_h': 1090,
'thumb_800_w': 800,
'thumb_960': 'https://files.slack.com/files-tmb/T50LX5FEF-FB9JWMTL1-f94c9acfef/image_uploaded_from_ios_960.jpg',
'thumb_960_h': 960,
'thumb_960_w': 704,
'timestamp': 1529417675,
'title': 'Slack for iOS Upload',
'url_private': 'https://files.slack.com/files-pri/T50LX5FEF-FB9JWMTL1/image_uploaded_from_ios.jpg',
'url_private_download': 'https://files.slack.com/files-pri/T50LX5FEF-FB9JWMTL1/download/image_uploaded_from_ios.jpg',
'user': 'U7Y8BL5G9',
'username': ''}
Is it possible to delete those older messages that don't show up anymore?
Could you add the ability to delete multiple channels. Thanks
I'm sure there is a way to do this with a variable...but I am too dumb. Would be a great feature to have built in!
Example: Delete messages older than one week, 3 days etc.
Can someone let me know what scopes are required to delete a message from a #general channel? I keep getting slacker.Error: missing_scope messages. Kinda strange this isn't in the README.
please how do I get a token to use with slack-cleaner? when I use test token from (https://api.slack.com/docs/oauth-test-tokens), I can delete only my messages (deleting , even if I am primary team owner and running slack-cleaner --token xoxp-XXXX --message --direct testo --user "*" --perform).
Hi kfei!
Many thanks for your program, it's really useful, great work ;)
I'm trying to delete all the direct messages that my bot has sent to me (the messages appear in my slackbot's direct messages field), but I can't make it work. This are list of commands that I have tried:
With my personal token:
With the bot's personal token:
Do you know what command should I use? I'm a little bit lost...
Many thanks for your help! Best regards,
Aitor
Thanks for this tool - it's been great. However, my direct messages are building, and I can't easily clean them.
I have tried multiple variations on the following:
slack-cleaner --token --message --direct
using the token for the . I've tried adding --user (both "*" and an actual user) and --rate=1, but always get the same result - "0 message(s) will be cleaned."
Any idea what I might be doing wrong?
btw, I'd love to be able to use "*" (or similar) as the param to --direct, as I need to script through all my users one-by-one :-/
Thanks much!
jeremy.
pretty much what the title is
Whenever I try to do anything, I always get the same error message about the channel not being found, e.g.:
slack-cleaner --token mytoken --message --user myuser --channel mychannel
Nevermind, installed it on a linux server after all.
Hi,
I like this project, however it seems to be dead. Therefore, I forked it (actually cloned) and cleaned it up.
--> https://github.com/sgratzl/slack-cleaner
changes
if you have further suggestions, please post issues, prs, ...
Hi there, what type of token should I use for the app? Under custom integrations I see Bots, but that doesn't seem to work. Is there another way of getting a token?
Is it possible to use this app without paying for Slack?
The cleaner works fine for a while but after about 50 messages I'm getting a "failed to delete" error:
[93m Failed to delete -> [0m]
followed by information on the message but not the issue. It happens with all the commands, and I've tried tried uninstalling and re-installing older versions, I can't see what the issue is. I even got a colleague to install and try it on their machine from fresh but the same error is occurring, can anyone help?
Changing to float will allow 0.25 / 0.5 / etc. to be specified, which can help prevent the rate limiting errors, but also still perform more operations.
p.s. Thanks for the tool. Very helpful!
I'm trying to clean up our general channel and I'm always receiving a syntax error. I'm running Python 3.4 on Windows.
File "C:\Python34\lib\site-packages\slack_cleaner\cli.py", line 92
print 'No more messsages'
^
SyntaxError: Missing parentheses in call to 'print'
Have a group name includes a letter " ı " , it is a Turkish character and how can I should write this letter to terminal, I tried "i" as well but didnt help
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.