Skip to content

Commit

Permalink
switch to mozilla/zamboni, get rid of check.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jbalogh committed Oct 17, 2011
1 parent de09b0c commit 6f27e01
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 52 deletions.
50 changes: 26 additions & 24 deletions amobot.js
@@ -1,52 +1,58 @@
var sys = require('sys'), var sys = require('sys'),
irc_ = require('irc'), irc_ = require('irc'),
redis_ = require('redis'), redis_ = require('redis'),
check = require('./check'); request = require('request'),
format = require('./format').format;




var amo = '#amo', var amo = '#amo',
amobots = '#amo-bots', amobots = '#amo-bots',
NICK = 'gk0bes' NICK = 'amobot'
irc = new irc_.Client('irc.mozilla.org', NICK, irc = new irc_.Client('irc.mozilla.org', NICK,
{channels: [amo, amobots]}), {channels: [amo, amobots]}),
jp = new irc_.Client('irc.mozilla.org', 'zalooon', redis = redis_.createClient(6381, '10.8.83.29'),
{channels: ['#flightdeck']}), repo = 'https://github.com/mozilla/zamboni',
redis = redis_.createClient(6379, 'mradm02'), revURL = 'https://addons-dev.allizom.org/media/git-rev.txt',
repo = 'https://github.com/jbalogh/zamboni'; branchesURL = 'https://github.com/api/v2/json/repos/show/mozilla/zamboni/branches';


var channels = { var channels = {
zamboni: [irc, amobots, amo], 'zamboni': [irc, amobots, amo],
'zamboni-lib': [irc, amobots, amo], 'zamboni-lib': [irc, amobots, amo],
flightdeck: [jp, '#flightdeck', '#flightdeck'],
}; };




var updater = { var updater = {
'master': 'https://addons.allizom.org/media/updater.output.txt', 'master': 'https://addons-dev.allizom.org/media/updater.output.txt',
'next': 'https://addons-next.allizom.org/media/updater.output.txt' }

var checkRev = function(cb) {
request(branchesURL, function(err, response, body) {
var ghRev = JSON.parse(body).branches.master;
request(revURL, function(err, response, body) {
sys.puts(body, ghRev);
cb(body, ghRev);
});
});
} }




irc.on('message', function(from, to, message) { irc.on('message', function(from, to, message) {
if (message == NICK + ': yo') { if (message == NICK + ': yo') {
check.checkRev(function(amo, github) { checkRev(function(amo, github) {
irc.say(to, from + ': preview is at ' + repo + '/commits/' + amo); if (github.indexOf(amo) === 0) {
if (github.indexOf(amo) != 0) { irc.say(to, format('{0}: -dev is at {1}/commits/{2} (up to date)',
irc.say(to, from + ': we are behind master! ' + repo + '/compare/' + amo + '...' + github.substring(0, 8)); from, repo, amo));
} else {
irc.say(to, format('{0}: we are behind master! {1}/compare/{2}...{3}',
from, repo, amo, github.substring(0, 8)));
} }
}); });
} else if (message == NICK + ': woo') {
irc.say(to, from + ': awww yeah');
} }
}); });
irc.on('error', function(msg) { irc.on('error', function(msg) {
sys.puts('ERROR: ' + msg); sys.puts('ERROR: ' + msg);
sys.puts(JSON.stringify(msg)); sys.puts(JSON.stringify(msg));
}); });
jp.on('error', function(msg) {
sys.puts('ERROR: ' + msg);
sys.puts(JSON.stringify(msg));
});


redis.on('pmessage', function(pattern, channel, message) { redis.on('pmessage', function(pattern, channel, message) {
sys.puts(pattern, channel); sys.puts(pattern, channel);
Expand Down Expand Up @@ -81,10 +87,6 @@ redis.on('pmessage', function(pattern, channel, message) {
var up = updater[msg[3].ref.split('/').pop()]; var up = updater[msg[3].ref.split('/').pop()];
bot.say(bad, 'Push failed: ' + updater[branch]) bot.say(bad, 'Push failed: ' + updater[branch])
} }
} else {
var commits = msg.commits,
commit = commits[commits.length - 1];
// irc.say(amo, 'Pushing ' + msg.compare + ' by ' + commit.author.username);
} }
}); });
redis.psubscribe('update.*'); redis.psubscribe('update.*');
28 changes: 0 additions & 28 deletions check.js

This file was deleted.

0 comments on commit 6f27e01

Please sign in to comment.