Socket
Socket
Sign inDemoInstall

hubot-response

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hubot-response

Makes creating hubot responses easy.


Version published
Weekly downloads
8
increased by700%
Maintainers
1
Weekly downloads
 
Created
Source

Hubot Response

Makes writing hubot scripts as easy as

{
  "match": "Hello",
  "listener": "hear",
  "response": [
    "World!"
  ]
}

TL;DR

Install

npm install --save hubot-response

Register

In external-scripts.json add

"hubot-response"

Make your own responses

Create a responses directory. Create mysweetresponse.json and add

{
  "match": "Hello",
  "listener": "hear",
  "response": [
    "World!"
  ]
}

Now when hubot hears Hello in the room, it replies back with World!. Run npm start to try it out!

Checkout more examples.

Environment Variables

HUBOT_RESPONSE_GLOB - Glob of where to look for responses. Defaults to responses/*.*

How to use

Hubot Response can read anything that can be reqire-ed as an object. So json, js, coffee files all work.

The file should export either an object for one response, or an array for multiple responses.

Each response object should consist of:

  • match - Either a string that is turned into a regex, or an actual instance of RegExp that the robot is listening for.
  • listener - Either hear or respond.
  • response - Can be a String, Function that is called, or an Array where an index is randomly selected.

Don't we already have a way of doing this?

Yes, and the hubot-scripts org is awesome! But for simple hear and respond modules (animated gifs mostly) customization sucks...

Say you want to use this awesome business-cat script, but really want to add an image.

You have 3 options:

  • Copy and paste the script into your hubot scripts folder and modify it there.
  • Fork it and modify it. Then deal with merge conflicts.
  • Submit a pull request, but maybe no one else want's your stupid cat picture?

None of these are really clean.

Solution

Since response files are just an object, we can extend however we want. You can see an example of this in the extension example.

Keywords

FAQs

Package last updated on 06 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc