Cannot delete a chat message via Slack API

2019-07-03 04:04发布

问题:

I have a Slack team with a public channel. My goal is to use the channel only for announcements posted by bot-A.

I understand that it is not possible to configure Slack channel to be writable for only one person and read-only for the rest, I created a bot-B (Python thing running on an external machine) that monitors the channel via RTM and if there is any message not coming from bot-A, bot-B's task is to delete the message by calling chat.delete (https://api.slack.com/methods/chat.delete). Bot-B is also in the channel.

Unfortunately bot-B is getting "cant_delete_message" which, according to the chat.delete doc, means that he has no permissions.

However, according to https://api.slack.com/bot-users, chat.delete is allowed for Custom Bots.

So is my bot-B not a "Custom Bot"? If so, what does a Custom Bot actually is and how can I create one?

Or what am I doing wrong?

回答1:

I believe that a Slack user (bot or otherwise) is only allowed to delete its own messages. There's no way to delete messages posted by someone else.

EDIT: I stand corrected. Admins can delete other people's messages. From https://get.slack.help/hc/en-us/articles/202395258-Editing-or-deleting-messages:

Owners and Admins can delete messages from any sender as long as the messages are in public or private channels that the Owner or Admin has joined.