Giter Club home page Giter Club logo

Comments (13)

sgratzl avatar sgratzl commented on September 6, 2024

does it return the cannot delete message error message or are just no messages are about to be deleted. In the latter case, could be a duplicate to #38

from slack-cleaner.

botzill avatar botzill commented on September 6, 2024

Having the same issues. I have a channel with lot's of messages from an app bot I have. When I di

slack-cleaner --token ${TOKEN} --message --channel ${CHANNEL} --bot --perform --rate 2

I get Failed to delete (cant_delete_message)->. Any idea how to solve this and way I get this?

I can delete users messages ok, but issues are with bot ones.

Thx.

from slack-cleaner.

sgratzl avatar sgratzl commented on September 6, 2024

Hi can you try the develop branch of this project. it follows a different approach, a pure python one. but allows you more control about which messages should be deleted.

https://github.com/sgratzl/slack-cleaner/tree/develop and https://slack-cleaner2.readthedocs.io/en/latest/modules.html

thus it would be easier to come up with a more specific reason why the message cannot be deleted

from slack-cleaner.

botzill avatar botzill commented on September 6, 2024

I did and I get

Traceback (most recent call last):
  File "/Users/mac/.virtualenvs/crawless/bin/slack-cleaner", line 10, in <module>
    sys.exit(main())
  File "/Users/mac/.virtualenvs/crawless/lib/python3.7/site-packages/slack_cleaner2/cli.py", line 216, in main
    _delete_messages(slack, args)
  File "/Users/mac/.virtualenvs/crawless/lib/python3.7/site-packages/slack_cleaner2/cli.py", line 73, in _delete_messages
    user = _resolve_user(slack, args)
  File "/Users/mac/.virtualenvs/crawless/lib/python3.7/site-packages/slack_cleaner2/cli.py", line 42, in _resolve_user
    return next(filter(match_user(args.user), slack.users))
  File "/Users/mac/.virtualenvs/crawless/lib/python3.7/site-packages/slack_cleaner2/predicates.py", line 166, in match_user
    regex = re.compile('^' + pattern + '$', re.I)
TypeError: can only concatenate str (not "NoneType") to str

When running:

slack-cleaner --token ${TOKEN} --message --channel ${CHANNEL} --bot --perform --rate 2

from slack-cleaner.

botzill avatar botzill commented on September 6, 2024

Hi @sgratzl, any update on this issue?

from slack-cleaner.

sgratzl avatar sgratzl commented on September 6, 2024

the easiest way would be to write a custom python script and use the library directly.

e.g. untested python code but should be quite right

from slack_cleaner2 import *

s = SlackCleaner(TOKEN, sleep_for=2)
channel = next((c for c in s.channels if c.name == CHANNEL), None)
if channel:
  for msg in channel.msgs():
    if msg.bot:
      msg.delete()

from slack-cleaner.

sgratzl avatar sgratzl commented on September 6, 2024

re cli: you can try to add --user "*"

from slack-cleaner.

botzill avatar botzill commented on September 6, 2024

@sgratzl still getting the same issues with cant_delete_message with the code you're mentioning.

How can we know that is the issues? I'm using a legacy token.

from slack-cleaner.

sgratzl avatar sgratzl commented on September 6, 2024

when looking at https://api.slack.com/methods/chat.delete there are the following restrictions:

When used with a typical user token, may only delete messages posted by that user.

When used with an admin user's user token, may delete most messages posted in a workspace.

When used with a bot user's token, may delete only messages posted by that bot user.

so are you an admin? Moreover, you can try to set the as_user flag as in

msg.delete(as_user=True)

from slack-cleaner.

botzill avatar botzill commented on September 6, 2024

Hi.

Sorry, I was not admin, with admin token I can delete now.

Thx!

from slack-cleaner.

sgratzl avatar sgratzl commented on September 6, 2024

happy that you found the issue

from slack-cleaner.

cinguva avatar cinguva commented on September 6, 2024

the easiest way would be to write a custom python script and use the library directly.

e.g. untested python code but should be quite right

from slack_cleaner2 import *

s = SlackCleaner(TOKEN, sleep_for=2)
channel = next(c for c in s.channels if c.name == CHANNEL, None)
if channel:
  for msg in channel.msgs():
    if msg.bot:
      msg.delete()

little syntax change, channel = next((c for c in s.channels if c.name == 'random'), None)
missing paranthesis

from slack-cleaner.

sgratzl avatar sgratzl commented on September 6, 2024

thx

from slack-cleaner.

Related Issues (20)

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.