Handle reaction_added messages#360
Conversation
Supercedes and closes #271. Converts reaction_added messages to TextMessages before passing them to Hubot. Used to implement behavior needed by 18F/hubot-slack-github-issues and depends on behavior from slackapi/node-slack-sdk#96. Also pertains to #251.
|
Changes Unknown when pulling 560bf51 on mbland:reaction-added-v3 into * on slackhq:master*. |
|
Hello @mbland ! This looks quite nice, thank you for taking the time to update your PR! However, I have one complaint. Rather than emitting a Thoughts? |
|
@mbland thanks so much for picking this back up! |
|
Changes Unknown when pulling 87c3926 on mbland:reaction-added-v3 into * on slackhq:master*. |
|
@DEGoodmanWilson I was secretly hoping you'd suggest something like that. Done. The reason I held back originally (other than trying to keep parity with the existing #271 while I re-familiarized myself with the code) was because I noticed all the existing message types are imported from the |
|
Changes Unknown when pulling 533682b on mbland:reaction-added-v3 into * on slackhq:master*. |
|
Also, looking back at slackapi/node-slack-sdk#96 and https://github.com/slackhq/node-slack-sdk/blob/3.4.0/lib/clients/rtm/client.js, it looks like the |
|
LGTM 👍 great work! |
|
Yeah, this is great. I would advise against adding these types upstream in Hubot. Not all messaging services provide this kind of functionality, and to my mind at least, platform-specific features should remain with the adapter. Because, let's be honest, a Hubot script or plugin that makes use of this message type is simply not going to work on another service. Merging this in, will release…soon. I promise. |
|
Cool, thanks! (And I was tilting towards the same conclusion re: pushing |
|
Hi there @mbland, |
|
@neufeldtech I'll try to get to it in the next day or two. Feel free to ping me by Friday if I haven't posted back. FWIW, the original hack was to hook into the |
|
@neufeldtech OK, here you go: https://github.com/mbland/hubot-slack-reaction-example |
|
@mbland Thanks! I'll be sure to take a look at this. |
|
Not to drag this thread out too long, but...I've already updated the example script to be even smaller and easier to follow. And @DEGoodmanWilson: Do you think it'd be worth patching on a |
|
@mbland That might be a good idea, actually! |
Per slackapi#360, this is the first step towards implementing a `robot.react` method based on: https://github.com/mbland/hubot-slack-reaction-example/blob/v1.1.0/scripts/handle-reaction.coffee The previous Hubot development dependency version was ~2.11, but the `robot.listen` method didn't appear until v2.16.0: hubotio/hubot#986 hubotio/hubot#1035
Per slackapi#360, this implements `robot.react` as a replacement for the approach from: https://github.com/mbland/hubot-slack-reaction-example/blob/v1.1.0/scripts/handle-reaction.coffee Specifically, the `ReactionMessage` definition will no longer be required in client code, and this: robot.listen( (message) -> message instanceof ReactionMessage handleReaction ) can now become: robot.react handleReaction `robot.react` can also take optional `matcher` and `options` arguments just like the underlying `robot.listen` method: robot.react( (message) -> message.type == 'added' && message.reaction == '+1' {id: 'my-reaction-matcher'} handleReaction )
|
OK, just filed #363. Anyone who's still interested can subscribe to that PR. |
Thanks to the new @slack/client npm, slackapi/hubot-slack#360, and slackapi/hubot-slack#363, the `SlackBot` will now emit a `ReactionMessage` object for `reaction_added` and `reaction_removed` events. A future commit will repackage the logic so that it is no longer middleware, but called as part of a `robot.listen` or `robot.react` callback.
|
FYI @neufeldtech (and others), with the merge of #363 and release of v4.2.0, |
PR Summary
Handle reaction_added messages
Converts reaction_added messages to TextMessages before passing them to Hubot. Used to implement behavior needed by 18F/hubot-slack-github-issues and depends on behavior from slackapi/node-slack-sdk#96, which may be out-of-date by now. I'll take a look at the latest version and report back when I get a chance tonight or tomorrow, unless someone else already has context and beats me to it.
Related Issues
Supercedes and closes #271. Also pertains to #251.
Test strategy
Unit tests to validate the new
SlackBot.reactionAddedmethod as part of the existingHandling incoming messagessuite.cc: @johnagan @mtlewis @patcon @afeld @ccostino @skehlet @MidnightLightning @stevecat @DEGoodmanWilson