Skip to content

Instantly share code, notes, and snippets.

@hiddentao
Last active August 29, 2015 14:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hiddentao/e4c329d6d09f6db6376a to your computer and use it in GitHub Desktop.
Setting up a HipChat room notifier in a Waigo startup step
"use strict";
var HipChatter = require('hipchatter'),
Q = require('bluebird');
var _ = require('waigo')._;
module.exports = function*(app) {
if (app.config.hipChat) {
app.logger.debug('Setup HipChat notifier...');
var hipChat = new HipChatter();
Q.promisifyAll(hipChat);
app.hipChatNotify = function*(message, options) {
options = _.extend({
roomId: app.config.hipChat.roomId,
authToken: app.config.hipChat.authToken,
color: 'green',
}, options);
try {
yield hipChat.notifyAsync(options.roomId, {
message: message,
color: options.color,
token: options.authToken,
});
app.logger.debug('Notified through HipChat');
} catch (err) {
app.logger.error('Error notifying through HipChat: ' + err.message);
}
};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment