hipchat-spy

0.7.0 • Public • Published

hipchat-spy

NPM version

Express middleware for monitoring activity in HipChat.

Automatically setup webhooks to listen for activity via a simple EventEmitter interface.

Installation

$ npm install hipchat-spy

Usage

Create an express app:

var express    = require('express');
var hipchatSpy = require('hipchat-spy');

var app = express();

Create a new spy middleware by passing in your HipChat API key and the full (publicly accessible) URL that will serve as the base of all the webhooks:

var spy = hipchatSpy('your-api-key', 'http://myapp.com/webhooks');

Mount the middleware in our express app under the URL prefix that matches with the URL we gave our spy factory above:

app.use('/webhooks', spy);

The spy has an emitter property that is an EventEmitter instance. Have the spy listen in on a few rooms and respond to events (see HipChat docs for all events):

// Use the roomId or the room name
spy.addRoom(12351);
spy.addRoom('Software Development');

spy.emitter.on('room_message', function(message) {
  console.log(message);
});

spy.emitter.on('room_exit', function(info) {
  console.log(info);
});

License

MIT

Package Sidebar

Install

npm i hipchat-spy

Weekly Downloads

1

Version

0.7.0

License

MIT

Last publish

Collaborators

  • bvalosek