err-backend-slackv3 icon indicating copy to clipboard operation
err-backend-slackv3 copied to clipboard

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

Open rcoup opened this issue 8 years ago • 5 comments

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

I am...

  • [X] Suggesting a new feature

I am running...

  • Errbot version: 5.1.3
  • OS version: Debian (python Docker)
  • Python version: 3.6
  • Using a virtual environment: no

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.

rcoup avatar Dec 07 '17 09:12 rcoup

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

andrewthetechie avatar Jan 09 '19 22:01 andrewthetechie

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).

sijis avatar Jan 10 '19 06:01 sijis

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.

andrewthetechie avatar Jan 10 '19 14:01 andrewthetechie

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

sijis avatar Jun 18 '19 06:06 sijis

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.

nzlosh avatar Jul 23 '21 20:07 nzlosh