Last active
August 29, 2015 14:07
-
-
Save hiddentao/e4c329d6d09f6db6376a to your computer and use it in GitHub Desktop.
Setting up a HipChat room notifier in a Waigo startup step
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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