From d6bf3ede8dd06277bec53ecb45f11a17c07e7584 Mon Sep 17 00:00:00 2001 From: Robert O'Connor Date: Sun, 28 Feb 2016 05:26:20 -0500 Subject: [PATCH] Wait until connected to log the channel the bot is on --- config.js | 5 ++++- ircbot.js | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/config.js b/config.js index 664c37d..c646e0e 100644 --- a/config.js +++ b/config.js @@ -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" @@ -22,4 +25,4 @@ nconf } }); -module.exports = nconf; \ No newline at end of file +module.exports = nconf; diff --git a/ircbot.js b/ircbot.js index 2b859da..da1b791 100644 --- a/ircbot.js +++ b/ircbot.js @@ -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; @@ -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); @@ -74,7 +79,7 @@ client.addListener('message', function (from, to, message) { bamboo.summarizeBrokenBuilds().then(function (summary) { _.each(summary, function (line) { postMessage(line); - }) + }); }); } });