Skip to content

Commit

Permalink
Wait until connected to log the channel the bot is on
Browse files Browse the repository at this point in the history
  • Loading branch information
robbyoconnor committed Feb 28, 2016
1 parent fcc6e0e commit d6bf3ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ nconf
.defaults({
irc: {
server: "chat.freenode.net",
port: "7000",
channel: "#openmrs",
nick: "omrs-scrum-bot",
userName: "scrumbot",
realName: "OpenMRS Scrum Bot",
startListening: "!scrumon",
stopListening: "!scrumoff",
sayBuildFailures: "!scrumon"
Expand All @@ -22,4 +25,4 @@ nconf
}
});

module.exports = nconf;
module.exports = nconf;
11 changes: 8 additions & 3 deletions ircbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var bamboo = require("./bamboo");
var SERVER = config.get("irc").server;
var CHANNEL = config.get("irc").channel;
var NICK = config.get("irc").nick;
var USERNAME = config.get("irc").userName;
var REALNAME = config.get("irc").realName;
var START_LISTENING = config.get("irc").startListening;
var STOP_LISTENING = config.get("irc").stopListening;
var SAY_BUILD_FAILURES = config.get("irc").sayBuildFailures;
Expand All @@ -22,8 +24,11 @@ var postMessage = function (text) {
client.say(CHANNEL, text);
};

var client = new irc.Client(SERVER, NICK, {userName: 'scrumbot', realName: 'OpenMRS Scrum Bot', channels: [CHANNEL]});
log.info("Connected to " + CHANNEL);
var client = new irc.Client(SERVER, NICK, {userName: USERNAME, realName: REALNAME, channels: [CHANNEL]});

client.addListener('motd', function(message) {
log.info("Connected to " + CHANNEL);
});

client.addListener('error', function (message) {
log.error(message);
Expand Down Expand Up @@ -74,7 +79,7 @@ client.addListener('message', function (from, to, message) {
bamboo.summarizeBrokenBuilds().then(function (summary) {
_.each(summary, function (line) {
postMessage(line);
})
});
});
}
});
Expand Down

0 comments on commit d6bf3ed

Please sign in to comment.