Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Commit

Permalink
Implement pulls command. Fix jsocol#4.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Socol committed Jul 12, 2012
1 parent ec67562 commit 18fa5e8
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions jig.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,42 @@ var client = new irc.Client(IRCHOST, IRCNICK, {


var response = '\00307#%(number)s\003 - \002%(state)s\002 - \00303%(user)s\003 - %(title)s - %(url)s';

function printPullReq(to, pull) {
client.say(
to,
interpolate(response, {
'number': pull.number,
'title': pull.title,
'url': pull.html_url,
'user': pull.user.login,
'state': pull.state.toUpperCase()
}, true));
}

client.on('message', function(from, to, msg) {
if (to.indexOf('#') != 0) return;
msg = msg.toLowerCase();
if (msg.indexOf(IRCNICK) == 0 && /botsnack\s*$/i.test(msg)) {
client.say(to, 'YUMMY');
} else if (msg.indexOf(IRCNICK) == 0 && /thanks/i.test(msg)) {
client.say(to, 'no problem!');
} else if (msg.indexOf(IRCNICK) == 0 && /pulls\s*$/i.test(msg)) {
var requester = {user: CONFIG.github.user, repo: CONFIG.github.repo, state: 'open'};
github.pullRequests.getAll(requester, function(err, pulls) {
pulls.forEach(function(pull) {
printPullReq(to, pull);
});
});
} else if (PULLREQRE.test(msg)) {
var m = PULLREQRE.exec(msg);
github.pullRequests.get({user: CONFIG.github.user, repo: CONFIG.github.repo, number: m[1]}, function(err, pull) {
var m = PULLREQRE.exec(msg),
requester = {user: CONFIG.github.user, repo: CONFIG.github.repo, number: m[1]};
github.pullRequests.get(requester, function(err, pull) {
if (err || !pull) {
console.log(err);
return;
}
client.say(
to,
interpolate(response, {
'number': pull.number,
'title': pull.title,
'url': pull.html_url,
'user': pull.user.login,
'state': pull.state.toUpperCase()
}, true));
printPullReq(to, pull);
});
}
});
Expand Down

0 comments on commit 18fa5e8

Please sign in to comment.