Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can this be used to delete a mpdm conversation by "Channel ID" or any other method? #94

Open
level42ca opened this issue Nov 22, 2023 · 3 comments
Labels
question Further information is requested

Comments

@level42ca
Copy link

level42ca commented Nov 22, 2023

I am trying to purge a user from our Slack environment, and so far I have been able to remove everything public, but at this point, I am trying to purge communications with this user in Private chats. I understand there are restrictions around this from Slack, but is it in any way possible for me to remove correspondences with myself? Can I remove myself from the private mpdm channels by the channel ID or something?

The channel.delete() function does not seem to exist and I'm not sure what else I may be able to do here, if anything at all..

===[Edit 1]===
This is as far as I have gotten. It is able to locate the messages, but it is unable to delete anything :(

for channel in s.conversations:
  print(channel.id)
  if str(channel.id) == 'DJQMJXXXX':
    print('  ===> Found Channel!')
    for msg in channel.msgs(with_replies=True):
        if msg.user_id == 'UHLEQXXXX':
          print('  ===> Found message! -', msg)
          print('  ===> Deleting message...')
          msg.delete()

I am an Administrator of Slack, and I believe my bot has full permissions (permissions outlined in this ticket), but I simply get a response as such:

list msgs of deactivateduser (after=None, before=None)
  ===> Found message! - deactivateduser:2022-06-03T17:21:12.003709 (deactivateduser (UHLEQXXXX) Deactivated User): you too!
  ===> Deleting message...
xcannot delete entry: deactivateduser:2022-06-03T17:21:12.003709 (deactivateduser (UHLEQXXXX) Deactivated User): you too!: cant_delete_message

*For context, DJQMJXXXX is a conversation between myself, and (deactivateduser (UHLEQXXXX) Deactivated User)

===[Edit 2]===
According to the Slack API documentation, my specific error {cant_delete_message} means:

Authenticated user does not have permission to delete this message.

... but, according to this documentation, I should be able to delete DM's of which I am a member of, so I'm a bit confused.

Is this referring to the bot's permissions? Is this because the bot I created (in terms of the token), is not a member of the private conversation? Is it as simple as add the bot to the private message group, and re-attempt to delete? 🤔

===[Edit 3]===

So, it doesn't appear possible to add this bot to the private group, as the bot doesn't register as a user. My next though was maybe API permissions, but per the link above, I've already set the appropriate permissions. 🤷‍♂️

Bot tokens

User tokens

@level42ca level42ca added the question Further information is requested label Nov 22, 2023
@sgratzl
Copy link
Owner

sgratzl commented May 6, 2024

... but, according to this documentation, I should be able to delete DM's of which I am a member of, so I'm a bit confused.

you can delete the message you wrote but not the other ones, you = the token ownere

@sgratzl
Copy link
Owner

sgratzl commented May 6, 2024

this library is optimized for deleting messages not channel handling. You can take a look at the underlying slack api to delete channels

@level42ca
Copy link
Author

Ultimately, I was successfully able to delete private conversation, but it required the assistance of Slack. They were the ones who were able to delete the messages in question.

Thanks for the update though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants