Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hubot.Robot.react #363

Merged
merged 2 commits into from Oct 6, 2016
Merged

Add hubot.Robot.react #363

merged 2 commits into from Oct 6, 2016

Conversation

@mbland
Copy link
Contributor

@mbland mbland commented Oct 6, 2016

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've been mindful about doing atomic commits, adding documentation to my changes, not refactoring too much.
  • I've a descriptive title and added any useful information for the reviewer. Where appropriate, I've attached a screenshot and/or screencast (gif preferrably).
  • I've written tests to cover the new code and functionality included in this PR.
  • I've read, agree to, and signed the Contributor License Agreement (CLA).

PR Summary

Add hubot.Robot.react

Per #360, this implements robot.react as a replacement for the approach from mbland/hubot-slack-reaction-example v1.1.0. 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
)

NOTE: It was necessary to bump the hubot development dependency to at least v2.16.0, since that is when the Robot.listen method first appeared. I took the liberty of bumping it to the current version by specifying ^2.19.

Related Issues

Follows from the post-merge discussion of #360.

Test strategy

Unit tests to validate the new Robot.react method as part of the existing Adapter and the new Robot.react suites.

cc: @johnagan @DEGoodmanWilson

mbland added 2 commits Oct 6, 2016
Per #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 #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
  )
@mbland mbland mentioned this pull request Oct 6, 2016
6 of 6 tasks complete
@coveralls
Copy link

@coveralls coveralls commented Oct 6, 2016

Coverage Status

Changes Unknown when pulling e7d95c4 on mbland:robot-react into * on slackhq:master*.

mbland added a commit to mbland/hubot-slack-reaction-example that referenced this pull request Oct 6, 2016
After slackapi/hubot-slack#363 goes in, this dependency should be
updated.
mbland added a commit to mbland/hubot-slack-reaction-example that referenced this pull request Oct 6, 2016
@mbland
Copy link
Contributor Author

@mbland mbland commented Oct 6, 2016

@DEGoodmanWilson DEGoodmanWilson merged commit 6de1b5d into slackapi:master Oct 6, 2016
mbland added a commit to mbland/hubot-slack-reaction-example that referenced this pull request Oct 6, 2016
slackapi/hubot-slack#363 has been merged into master. When the next
version is released, the dependency can be updated to reflect that
version.
@mbland mbland deleted the mbland:robot-react branch Oct 6, 2016
mbland added a commit to mbland/hubot-slack-github-issues that referenced this pull request Oct 7, 2016
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.
mbland added a commit to mbland/hubot-slack-github-issues that referenced this pull request Oct 7, 2016
Added via slackapi/hubot-slack#363. When a new release beyond 4.10.0 is
released with this change, a future commit will update the dependency
accordingly.
mbland added a commit to mbland/hubot-slack-github-issues that referenced this pull request Oct 7, 2016
Added via slackapi/hubot-slack#363. When a new release beyond 4.10.0 is
released with this change, a future commit will update the dependency
accordingly.
@leschekfm leschekfm mentioned this pull request Sep 4, 2017
6 of 6 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants