Skip to content

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

@level42ca

Description

@level42ca

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions