Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Revert "Remove hipchat notifier."
Browse files Browse the repository at this point in the history
This reverts commit bbb10c2.
  • Loading branch information
cjsaylor committed Jul 30, 2018
1 parent bdae2e0 commit 78fcc51
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const StaleRepos = require('./lib/stalerepos');
const notifiers = {
email: require('./lib/notifiers/email'),
github: require('./lib/notifiers/github'),
hipchat: require('./lib/notifiers/hipchat'),
slack: require('./lib/notifiers/slack'),
console: require('./lib/notifiers/console'),
};
Expand All @@ -30,6 +31,8 @@ command
.option('--exclude-labels [labels]', 'Define a [comma delimited] group of labels of which a PR must NOT contain.', coerceList, [])
.option('--include-reviewed [count]', 'Filter PRs with at least [count] approved reviews.', 0)
.option('--exclude-reviewed [count]', 'Filter PRs without at least [count] approved reviews.', 0)
.option('--hipchat-apikey [api key]', 'Hipchat API integration key. If included, hipchat will attempt to be notified.')
.option('--hipchat-room [room name]', 'Hipchat room ID or name.')
.option('--slack-webhook [url]', 'Slack webhook URL to post messages.')
.parse(process.argv);

Expand Down Expand Up @@ -65,6 +68,9 @@ async function main() {
if (command.label) {
notifier.add(new notifiers.github(githubClient));
}
if (command.hipchatApikey) {
notifier.add(new notifiers.hipchat(command.hipchatApikey, command.hipchatRoom));
}
if (command.slackWebhook) {
notifier.add(new notifiers.slack(command.slackWebhook));
}
Expand Down
26 changes: 26 additions & 0 deletions lib/notifiers/hipchat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const fs = require('fs');
const P = require('bluebird');
const Hipchatter = require('hipchatter');
const co = require('co');
const _ = require('lodash');

module.exports = class Hipchat {
constructor(apiKey, roomID) {
const template = fs.readFileSync(__dirname + '/../../templates/hipchat.html').toString();
this.compiledTemplate = _.template(template);
this.roomID = roomID;
this.client = new Hipchatter(apiKey);
this.client.notify = P.promisify(this.client.notify);
}

notify(repos) {
return co.call(this, function*() {
return yield this.client.notify(this.roomID, {
message: this.compiledTemplate({ repos: repos }),
message_format: 'html',
notify: true,
color: 'gray'
});
});
}
};

0 comments on commit 78fcc51

Please sign in to comment.