Giter Club home page Giter Club logo

slack-cleaner's Introduction

slack-cleaner

License: MIT PyPi

Bulk delete messages and files on Slack.

this is a fork of https://github.com/kfei/slack-cleaner

An improved Python module based version is located at https://github.com/sgratzl/slack_cleaner2

Install

Install from Pip:

pip install slack-cleaner

current development version:

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

If you prefer Docker, there is a pre-built Docker image as well:

docker pull sgratzl/slack-cleaner

Just use docker run -it --rm sgratzl/slack-cleaner -c "slack-cleaner ..." for each command or jump into a shell using docker run -it --rm sgratzl/slack-cleaner.

Install for Fedora or EPEL7

@rapgro maintains packages for both Fedora and EPEL7

# Fedora
dnf install slack-cleaner
# EPEL7
yum install -y epel-release ; yum install slack-cleaner

Arguments

usage: slack-cleaner [-h] --token TOKEN [--log] [--quiet] [--rate RATE]
                     [--as_user] [--message | --file | --info] [--regex]
                     [--channel CHANNEL] [--direct DIRECT] [--group GROUP]
                     [--mpdirect MPDIRECT] [--user USER] [--botname BOTNAME]
                     [--bot] [--keeppinned] [--after AFTER] [--before BEFORE]
                     [--types TYPES] [--pattern PATTERN] [--perform]

optional arguments:
  -h, --help           show this help message and exit
  --token TOKEN        Slack API token (https://api.slack.com/web) or SLACK_TOKEN env var
  --log                Create a log file in the current directory
  --quiet              Run quietly, does not log messages deleted
  --proxy              Proxy Server url:port
  --verify             Verify option for Session (http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification)
  --rate RATE          Delay between API calls (in seconds)
  --as_user            Pass true to delete the message as the authed user. Bot
                       users in this context are considered authed users.
  --message            Delete messages
  --file               Delete files
  --info               Show information
  --regex              Interpret channel, direct, group, and mpdirect as regex
  --channel CHANNEL    Channel name's, e.g., general
  --direct DIRECT      Direct message's name, e.g., sherry
  --group GROUP        Private group's name
  --mpdirect MPDIRECT  Multiparty direct message's name, e.g.,
                       sherry,james,johndoe
  --user USER          Delete messages/files from certain user
  --botname BOTNAME    Delete messages/files from certain bots. Implies '--bot'
  --bot                Delete messages from bots
  --keeppinned         exclude pinned messages from deletion
  --after AFTER        Delete messages/files newer than this time (YYYYMMDD)
  --before BEFORE      Delete messages/files older than this time (YYYYMMDD)
  --types TYPES        Delete files of a certain type, e.g., posts,pdfs
  --pattern PATTERN    Delete messages/files with specified pattern or if one of their attachments matches (regex)
  --perform            Perform the task

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 of the workspace.

Deleting messages from public channels

  • channels:history
  • channels:read
  • chat:write (or both chat:write:user and chat:write:bot for older apps)
  • users:read

Deleting messages from private channels

  • groups:history
  • groups:read
  • chat:write (or chat:write:user for older apps)
  • users:read

Deleting messages from 1:1 IMs

  • im:history
  • im:read
  • chat:write (or chat:write:user for older apps)
  • users:read

Deleting messages from multi-person IMs

  • mpim:history
  • mpim:read
  • chat:write (or chat:write:user for older apps)
  • users:read

Deleting files

  • files:read
  • files:write (or files:write:user for older apps)
  • users:read

Usage

# Delete all messages from a channel
slack-cleaner --token <TOKEN> --message --channel general --user "*"

# Delete all messages from a private group aka private channel
slack-cleaner --token <TOKEN> --message --group hr --user "*"

# Delete all messages from a direct message channel
slack-cleaner --token <TOKEN> --message --direct sherry --user johndoe

# Delete all messages from a multiparty direct message channel. Note that the
# list of usernames must contains yourself
slack-cleaner --token <TOKEN> --message --mpdirect sherry,james,johndoe --user "*"

# Delete all messages from certain user
slack-cleaner --token <TOKEN> --message --channel gossip --user johndoe

# Delete all messages from bots (especially flooding CI updates)
slack-cleaner --token <TOKEN> --message --channel auto-build --bot

# Delete all messages older than 2015/09/19
slack-cleaner --token <TOKEN> --message --channel general --user "*" --before 20150919

# Delete all files
slack-cleaner --token <TOKEN> --file --user "*"

# Delete all files from certain user
slack-cleaner --token <TOKEN> --file --user johndoe

# Delete all snippets and images
slack-cleaner --token <TOKEN> --file --types snippets,images

# Show information about users, channels:
slack-cleaner --token <TOKEN> --info

# Delete matching a regexp pattern
slack-cleaner --token <TOKEN> --pattern "(bar|foo.+)"

# TODO add add keep_pinned example, add quiet

# Always have a look at help message
slack-cleaner --help

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

Tips

After the task, a backup file slack-cleaner.<timestamp>.log will be created in current directory if --log is supplied.

If any API problem occurred, try --rate=<delay-in-seconds> to reduce the API call rate (which by default is unlimited).

If you see the following warning from urllib3, consider to install missing packages: pip install --upgrade requests[security] or just upgrade your Python to 2.7.9.

InsecurePlatformWarning: A true SSLContext object is not available.
          This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail.
          For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

Credits

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

slack-cleaner's People

Contributors

baragona avatar grantholly avatar jamessa avatar jomasti avatar kfei avatar marcograss avatar nh2 avatar peeohvee avatar puzzlement avatar renshuki avatar rkandilarov avatar sgratzl avatar sillium avatar thebestmensch avatar titaniumbones avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slack-cleaner's Issues

Running Docker Outside The Container

Just prepend docker run -it --rm sgratzl/slack-cleaner for each command does not work for me.
I only get slack-cleaner to work if I run it from inside the container shell.

Unable to use botname and pattern argument

I only wanted to delete messages from one incoming webhook in a channel but the botname did not want to filter out those messages. I tired a few different variation but I always got 0 messages back.

I tried to filter the messages by the title or message but that did not seem to work too. I would like to delete the messages from "production Monolog" but keep those from "staging-server"

image

I just can't get it working...

Hey there - I need some help.
I keep getting the following error:
AttributeError: 'dict' object has no attribute 'iteritems'

And here's the last bit from the console:

Traceback (most recent call last):
  File "/Users/rob/PycharmProjects/slack-cleaner/venv1/bin/slack-cleaner", line 11, in <module>
    sys.exit(main())
  File "/Users/rob/PycharmProjects/slack-cleaner/venv1/lib/python3.6/site-packages/slack_cleaner/cli.py", line 337, in main
    message_cleaner()
  File "/Users/rob/PycharmProjects/slack-cleaner/venv1/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 "/Users/rob/PycharmProjects/slack-cleaner/venv1/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 "/Users/rob/PycharmProjects/slack-cleaner/venv1/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'

Any advice?

no attribute "conversations"

Hi,

I'm once again trying to use slack-cleaner as my semestr starts. THis time I get a new error about the attributes of the Slacker object:

unning slack-cleaner v0.6.0
Deleting messages from channel js-assignment
Traceback (most recent call last):
  File "/usr/bin/slack-cleaner", line 11, in <module>
    load_entry_point('slack-cleaner', 'console_scripts', 'slack-cleaner')()
  File "/home/matt/Dropbox/Work/History/DigitalHistory/dh-website/src/slack-cleaner/slack_cleaner/cli.py", line 471, in main
    message_cleaner()
  File "/home/matt/Dropbox/Work/History/DigitalHistory/dh-website/src/slack-cleaner/slack_cleaner/cli.py", line 400, in message_cleaner
    clean_channel(channel_id, channel_type, time_range, user_id=_user_id, bot=args.bot)
  File "/home/matt/Dropbox/Work/History/DigitalHistory/dh-website/src/slack-cleaner/slack_cleaner/cli.py", line 136, in clean_channel
    res = slack.conversations.history(channel_id, latest=latest, oldest=oldest).body
AttributeError: 'Slacker' object has no attribute 'conversations'

I'm pertty sure I have the right permisisons, but I'm not 1-% sure. THis is what fails:

usr/bin/slack-cleaner --token xoxp-20780100948-20785551937-736478807525-2becdc0606fe4693d49af4778079a2da  --channel "js-assignment" --user "*" --message

Backup feature

Hi.
I used this one for cleaning up my space from files and it works great, thanks! 🥇
I used it with a: https://github.com/auino/slack-downloader which is a simple script to download the files, but gets the job done as well.
I'm wondering if you think it would be desired to add a backup feature to this user-friendly toolkit of yours.

Users with spaces in their usernames.

It appears that there isn't a way to delete direct messages where one or more of the users has a username with a space in it. One of my users has a "First Last" username. I've tried putting the name in quotes, as well as using the "@" code (ex: <@U2B7M4JKQ>). This @ code I tried with and without the opening and closing brackets, as well as with quotations.

still no messages to delete

I'm using 0.5 (just installed w/ pip) but am getting what seems like the behaviour described in #37:

slack-cleaner --token=XXXXXXXXXXXXXXXXX --channel tech-setup --message --as_user 
Running slack-cleaner v0.5.0
Deleting messages from channel tech-setup

0 message(s) will be cleaned.

I justregenerated the token so I think that is not the issue (though I am not sure how else to test that).

Thank you, let me know if I na help debug!

add `verify` option to turn off SSL check

Hello,

Thank you very much for making this fork of slack-cleaner and maintaining it.

I'm trying to run slack-cleaner behind my company proxy which messes up SSL certificates to make them not valid. Is it possible to disable the SSL check as a flag or something?

Failed to delete (HTTPSConnectionPool(host='slack.com', port=443): Max retries exceeded with url: /api/chat.delete?token= (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)'),)))->

429 Too many requests

Started cleaning slack recently from CI bot spam
Once I got over 100 messages I start receiving:
Failed to delete (429 Client Error: Too Many Requests for url: https://slack.com/api/chat.delete?token=<my token>

According to Slak's Documentation the error shows up once you reach the limit and you should start parsing Retry-After parameter in the response.

Can not delete from private channel

I am using --group and the name of the channel is correct as far as I can tell.

Are there some new Slack limitation on the channel containing more than X messages then can't delete with the API ?

Running slack-cleaner v0.3.0
Channel, direct message or private group not found

restructure command line arguments

currently they are mixed up with commands and options.

possible structure

basic commands:

  • message - delete messages
  • bot - delete bot messages
  • files - delete files
  • info - dump information about users and channels

extras:

  • invert the logic add ad --dry-run instead of --perform
  • don't separate groups and channels but unify them

Webhook message delete not possible

Hi,
i can delete normal message, but no webhook message.
i always get the error message:
slack-cleaner --token <TOKEN> --message --channel alerts --user "*"
0 message(s) cleaned.

failed to delete error

Expect below to work with slack-cleaner with mailclark bot but got error, can't_delete_message.

steps to perform:

$ docker run sgratzl/slack-cleaner -c 'slack-cleaner --token <token> --message --channel zc-alarm --user 'mailclark' --before 20180122 --rate 1 --perform'
Running slack-cleaner v0.4.0
Deleting messages from channel zc-alarm
Failed to delete (cant_delete_message)->
{   u'attachments': [   {   u'author_icon': u'https://mailclark.ai/static/img/logos/service-email.png',
                            u'author_link': u'https://mailclark.ai/settings/room/19915/975115/ffc9dqpwe-Q8qw6HJNS2m5E5E5E?expand=imap-smtp',
                            u'author_name': u'[email protected]',
                            u'color': u'FFFFFF',
                            u'fallback': u'Sorry, your Slack client doesn\u2019t support buttons.',
                            u'id': 1},
                        {   u'actions': [   {   u'id': u'1',
                                                u'style': u'',
                                                u'text': u'Edit settings',
                                                u'type': u'button',
                                                u'url': u'https://mailclark.ai/settings/room/redirect/19915/975115/JGwt4FCFXRezrxK7A67BEdKLLZ0'},
                                            {   u'id': u'2',
                                                u'style': u'',
                                                u'text': u'Connect services',
                                                u'type': Failed to delete (cant_delete_message)->
u'button',
                                                u'url': u'https://mailclark.ai/welcome/19915/975115/B1INw4RpX4b81KupbmgdJoO7yCY'}],
                            u'color': u'FFFFFF',
                            u'fallback': u' ',
                            u'id': 2}],
    u'bot_id': u'B8GAWKN72',
    u'parent_user_id': u'U8EM71DM5',
    u'text': u'<#C8J2RTG3Z|zc-alarm> connectors:',
    u'thread_ts': u'1516558705.000088',
    u'ts': u'1516558706.000084',
    u'type': u'message',
    u'user': u'U8GU2U5M1'}

platform:

  1. mailclark website (https://help.mailclark.ai)
  2. using docker with main branch of slack-cleaner
  3. I am chat channel owner and granted API

support message archiving

e.g. a simple support for storing messages in some place before deleting them, such as

  • a json file
  • a mongodb
  • stdout

delete app messages

I'm trying to delete messages delivered to a channel via the Twitter or Google Calendar apps, but the slack-cleaner does not appear to detect these messages even in a public channel.

--botname doesn't seem to delete messages [weird output of # of messages to be deleted]

Hello! I'm running slack-cleaner v.0.4.0 on Python 3.6, via PowerShell. I'm trying to delete one particular bot's messages from one particular channel:

PS C:\1\insta_env> slack-cleaner --token xxxx --message --channel internal-updates --botname notion
Running slack-cleaner v0.4.0
Deleting messages from channel internal-updates

�[92m0�[0m message(s) will be cleaned.

Now you can re-run this program with `--perform` to actually perform the task.

I guess it's a character issue, but still, even after initiating the delete via --perform with this output,

�[92m0�[0m message(s) cleaned.

All the messages remain. None are deleted. Have I missed a crucial step here? This is the bot whom I'm trying to wipe.

Here's what the app looks like:

2018-04-05_15-47-32

2018-04-05_15-48-30

Enable botname parameter when using bot message option

To enable the use of the botname parameter the below code will enable filtering based on an exact match of the username using the botname parameter when using the 'bot' message type option:

git diff specified below:

index 6e13c2b..baaf539 100644
--- a/slack_cleaner/cli.py
+++ b/slack_cleaner/cli.py
@@ -128,6 +128,10 @@ def clean_channel(channel_id, channel_type, time_range, user_id=None, bot=False)

         # Delete bot messages
         if bot and (m.get('subtype') == 'bot_message' or 'bot_id' in m):
+          # If botname specified conditionalise the match
+          if args.botname:
+            if m.get('username') != user_id:
+              continue
           delete_message_on_channel(channel_id, m)

       # Exceptions
@@ -342,6 +346,9 @@ def resolve_user():

     if _user_id is None:
       sys.exit('User not found')
+  # For bots the username is customisable and can be any name
+  if args.botname:
+    _user_id = args.botname
   return _user_id

Getting cant_delete_message for direct messages

I'm the owner of the Slack workspace
and I'm trying to remove messages from Direct Messages.

It deleted my own messages without any issues.
But the other person's messages I can't delete.
Not a single one.

Getting (with --rate of 3) on every message:

Failed to delete (cant_delete_message)->
{   u'client_msg_id': u'XXX',
    u'text': u'XXX ',
    u'ts': u'XXX',
    u'type': u'message',
    u'user': u'XXX'
}

Any ideas?

Delete all direct messages older than a given date?

Around 90% of our Slack space is comprised of direct messages, and we're fast approaching the 10k nag. Can I delete DMs using wildcards?

I've tried:

slack-cleaner --rate $RATE --token $TOKEN --message --direct "*" --user "*" --before $DATED $1

With no luck.

Handle errors in the queue

Hello.
Whenever I --perform some query that is to delete tens of messages - I usually get 429 errors (about exceeding rate limit).
If I set --rate high enough to not get those errors - deleting goes too slow: even with rate of 0.7 I from time to time get those errors, so I'd rather go at rate 0.1 and delete things faster but also get more 429 errors.

Anyways, my question is about the exit status: shouldn't it be non-zero in case there was at least a single message not deleted due to an error?
I think it makes sense to set exit status equal the number of failed attempts to delete a message.

Or there should be an option to just move the failed tasks to the end of queue?

Messages not found

image

After deleting files, these messages appear in the channel history. These messages cannot be found by slack-cleaner to delete.

Fedora packages

Hi,
let me kindly announce official packages available in the Fedora repository, currently for Rawhide, F30 and EPEL7 (latter as addon for RHEL7/CentOS7). I'm the proud maintainer of both packages named slack-cleaner and python-slacker (as dependency).
Commands to install:

# Fedora
dnf install slack-cleaner
# EPEL7
yum install -y epel-release ; yum install slack-cleaner

Regards.

dev: unicode error in cli application

coming from #7 (comment)

Traceback (most recent call last):
File "/usr/local/bin/slack-cleaner", line 9, in
load_entry_point('slack-cleaner2==0.1.0', 'console_scripts', 'slack-cleaner')()
File "/Library/Python/2.7/site-packages/slack_cleaner2-0.1.0-py2.7.egg/slack_cleaner2/cli.py", line 209, in main
_show_infos(slack)
File "/Library/Python/2.7/site-packages/slack_cleaner2-0.1.0-py2.7.egg/slack_cleaner2/cli.py", line 23, in _show_infos
_print_dict('users', {u.id: '{} = {}'.format(u.name, u.real_name) for u in slack.users})
File "/Library/Python/2.7/site-packages/slack_cleaner2-0.1.0-py2.7.egg/slack_cleaner2/cli.py", line 23, in
_print_dict('users', {u.id: '{} = {}'.format(u.name, u.real_name) for u in slack.users})
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 8: ordinal not in range(128

Deleting Threads (conversations.replies)

Everything works really well, except that when deleting all messages on a channel, I find that the replies on a thread are usually left behind. I've tried most of the args to try getting rid of it but am hitting a wall.

AttributeError raised when trying to delete messages posted by a bot user

duong-dajgja:~ duong2179$ slack-cleaner --token xoxb-xxx-xxxxxx --message --group my-private-channel --user bot_uname
Running slack-cleaner v0.3.0
Traceback (most recent call last):
  File "/usr/local/bin/slack-cleaner", line 11, in <module>
    load_entry_point('slack-cleaner', 'console_scripts', 'slack-cleaner')()
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/slack_cleaner/cli.py", line 337, in main
    message_cleaner()
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/slack_cleaner/cli.py", line 305, in message_cleaner
    _user_id = get_user_id_by_name(args.user_name)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/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'

Failed to delete (cant_delete_message)->

Hello.
I can't delete any message from logs channel.
I run : slack-cleaner --token TOKEN --message --channel CHANNEL --bot --perform --rate 5.
Scopes under this token :

users:read
channels:history
channels:read
chat:write:user
chat:write:bot

Unable to find any files to delete

Running the cleaner on my machine with a fresh install is appearing to have problems finding any files to delete. This is a new problem, I have successfully run it in the past with no problems. Not getting any error messages, just the below output:

slack-cleaner --token <token> --file --user "*" --rate=5
Running slack-cleaner v0.4.1
Deleting all matching files

0 file(s) will be cleaned.

Also pulled the latest Docker image and tried that method, to no avail.

docker run -it --rm sgratzl/slack-cleaner -c "slack-cleaner --token <token> --file --user \"*\""
Running slack-cleaner v0.4.1
Deleting all matching files

0 file(s) will be cleaned.

Now you can re-run this program with `--perform` to actually perform the task.

Also reissued a new token and tried that with no success.

ValueError exception thrown

Hey there!

Been looking for a python program to bulk delete messages from Slack, and stumbled upon this project. Anyway, I pulled the image from Docker and ran slack-cleaner with the following arguments:
/backup # slack-cleaner --token TOKEN --message --channel test --user "*"

This got thrown back at me:

Running slack-cleaner v0.4.0
Traceback (most recent call last):
  File "/usr/local/bin/slack-cleaner", line 11, in <module>
    load_entry_point('slack-cleaner==0.4.0', 'console_scripts', 'slack-cleaner')()
  File "/usr/local/lib/python2.7/site-packages/slack_cleaner/cli.py", line 380, in main
    message_cleaner()
  File "/usr/local/lib/python2.7/site-packages/slack_cleaner/cli.py", line 350, in message_cleaner
    _channels = resolve_channels()
  File "/usr/local/lib/python2.7/site-packages/slack_cleaner/cli.py", line 317, in resolve_channels
    _channels.extend([(id, name, 'channel') for (id, name) in get_channel_ids_by_pattern(args.channel_name, not args.regex)])
ValueError: too many values to unpack

Any ideas?

Human readable 'before' or 'after' parameters

Is your feature request related to a problem? Please describe.
I want to run your script on a cron, so I would like to issue the same command every day. For example:

slack-cleaner --channel debug --bot --perform --before 'yesterday'

To remove all messages older than a day. Right now I have to calculate the date it was yesterday using some other library or tool.

Describe the solution you'd like
I would like the --before and the --after parameters to take human readable input as well as YYYYMMDD

Describe alternatives you've considered
Wrapping your tool in ruby, since it's pretty easy to work with dates in Ruby

Additional context
I'm a lazy sysadmin and would 100% understand that you can't/won't implement this feature. Btw: amazing product, please keep it alive!

Doesn't work for me

I do slack-cleaner --token <MY_TOKEN> --info and I get a list of users, public channels, private channels, instant messages and multi user direct messages, which proves my token is working.

Then I do slack-cleaner --token <MY_TOKEN> --message -channel <ANY_CHANNEL> and it says that 0 message(s) will be cleaned, but we do have messages in the channel! And I have enough rights to remove messages at least from myself and from bots.

This happened first with slack-cleaner v0.3.0 (although it worked before), then I updated to v0.4.0 and the issue is still there.

Error when trying to get info on the group

When I’m trying to get info on the group, I get this error:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 28: ordinal not in range(128)

error

Handle gracefully 429 HTTP error

Rather than having the user guess what the rate should be, it would be ideal if the application handles gracefully 429's errors Client Error: Too Many Requests.

--keeppinned unrecognized

When using the --keeppinned argument, I am seeing an unrecognized argument error. If I remove this argument, everything runs well. Was this option removed or renamed recently?

Launch Command:
slack-cleaner --token TOKEN --message --keeppinned --channel test --user "*" --perform --rate 1

Console Output:
usage: slack-cleaner [-h] --token TOKEN [--log] [--rate RATE] (--message | --file) [--channel CHANNEL | --direct DIRECT | --group GROUP | --mpdirect MPDIRECT] [--user USER] [--bot] [--after AFTER] [--before BEFORE] [--types TYPES] [--perform] slack-cleaner: error: unrecognized arguments: --keeppinned

Per the Readme, this should be right:
usage: slack-cleaner [-h] --token TOKEN [--log] [--quiet] [--rate RATE] [--as_user] [--message | --file] [--regex] [--channel CHANNEL] [--direct DIRECT] [--group GROUP] [--mpdirect MPDIRECT] [--user USER] [--botname BOTNAME] [--bot] **[--keeppinned]** [--after AFTER] [--before BEFORE] [--types TYPES] [--pattern PATTERN] [--perform]

Fails to delete any files

I orginally tried to delete all files for everyone older than July 1st, e.g.:
slack-cleaner --token xxx --file --user "*" --before 20170701
It says 391 will be deleted, try again with --perform. I do it again:
slack-cleaner --token xxx --file --user "*" --before 20170701 --perform
and it errors on all 391 it looks like, with the following for each:
Failed to delete (delete() got an unexpected keyword argument 'as_user') ->

I restricted it to myself:
slack-cleaner --token xxx --file --user "kelly" --perform
which should have deleted a handful of files and I get the same error.
Running slack-cleaner v0.4.0
Deleting all matching files
Failed to delete (delete() got an unexpected keyword argument 'as_user') ->
(etc)

Ideas?

user_dict keyerror

  File "/home/palewire/.virtualenvs/slack-cleaner-y1JoDDbN/bin/slack-cleaner", line 11, in <module>
    load_entry_point('slack-cleaner', 'console_scripts', 'slack-cleaner')()
  File "/home/palewire/.virtualenvs/slack-cleaner-y1JoDDbN/src/slack-cleaner/slack_cleaner/cli.py", line 471, in main
    message_cleaner()
  File "/home/palewire/.virtualenvs/slack-cleaner-y1JoDDbN/src/slack-cleaner/slack_cleaner/cli.py", line 400, in message_cleaner
    clean_channel(channel_id, channel_type, time_range, user_id=_user_id, bot=args.bot)
  File "/home/palewire/.virtualenvs/slack-cleaner-y1JoDDbN/src/slack-cleaner/slack_cleaner/cli.py", line 163, in clean_channel
    delete_message_on_channel(channel_id, m)
  File "/home/palewire/.virtualenvs/slack-cleaner-y1JoDDbN/src/slack-cleaner/slack_cleaner/cli.py", line 219, in delete_message_on_channel
    get_user_name(message), get_message_or_first_attachment_text(message))
  File "/home/palewire/.virtualenvs/slack-cleaner-y1JoDDbN/src/slack-cleaner/slack_cleaner/cli.py", line 191, in get_user_name
    return user_dict[_id]
KeyError: 'UG50GR0SG'

unexpected keyword argument 'session'

File "/usr/local/bin/slack-cleaner", line 9, in <module>
    load_entry_point('slack-cleaner', 'console_scripts', 'slack-cleaner')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/root/src/slack-cleaner/slack_cleaner/cli.py", line 26, in <module>
    slack = Slacker(args.token, session=session)
TypeError: __init__() got an unexpected keyword argument 'session'

Failed to delete

Im getting an error when trying to delete

Running slack-cleaner v0.6.0 Deleting messages from channel ideas Failed to delete (missing_scope)-> { u'subtype': u'channel_join', u'text': u'<@ULC5K5DKR> has joined the channel', u'ts': u'1562772926.000200', u'type': u'message', u'user': u'ULC5K5DKR'}

add hint regarding user token only

see kfei/slack-cleaner#72

by @Gerardwx

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.