errbotio / err-backend-slackv3

Slack Events and RTM backend for Errbot
GNU General Public License v3.0
27 stars 28 forks source link

Slack: A message property returning if it's an edit #36

Open rcoup opened 6 years ago

rcoup commented 6 years ago

In order to let us help you better, please fill out the following fields as best you can:

I am...

I am running...

Issue description

After errbotio/errbot#382, when messages are edited in Slack, Errbot plugins receive them again. If the bot responds to a message (eg. "ticket errbotio/errbot#1234" -> {details of ticket}) then the channel keeps getting additional replies over & over.

Would be nice to be able to detect a message as an edit so the botcmd can skip it. eg. if msg.is_edit: return

This doesn't solve all use cases (eg. "ticket errbotio/errbot#1234" edited to "ticket errbotio/errbot#1235" when the bot should respond with different content) but does help the common case, and could be built on to support that sort of thing.

andrewthetechie commented 5 years ago

https://github.com/errbotio/errbot/issues/1032 is related to this

sijis commented 5 years ago

They are different. This is asking for a property to be added to the msg object. The other ticket is looking for a mechanism to have a plugin reply update an existing messge (if the backend supports the feature).

andrewthetechie commented 5 years ago

Yup, but they're a bit related imho. If a plugin can update/edit a message, it would be good to be able to check if a new message coming in is edited.

sijis commented 5 years ago

Possibly related: https://github.com/errbotio/errbot/pull/1269

nzlosh commented 3 years ago

Access to the underlying slack event is possible with the slackv3 backend. https://github.com/errbotio/err-backend-slackv3/blob/4d48c5bf5efb5655ee3ed18f5012bc15c0cd5c2a/slackv3.py#L489

Below is an extract from a slack event that contains a message edit:

 'subtype': 'message_changed',
 'ts': '1627072096.001000',
 'type': 'message'}

Plugins that need to make a decision on how to handle message edits, have access to this event via msg.extras property and can decide how to process the changed text.

This feature should be documented to be clearly understood by future plugin developers.