From 695b92cf7b668c19f5f7b1440ae5151793b2cd6b Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 19 Feb 2015 08:44:12 -0500 Subject: [PATCH] Fix irc? --- lib/bothandlers.js | 6 +++++- lib/ircclient.js | 10 ++++++++-- package.json | 4 ++-- www/js/internals.js | 1 - 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/bothandlers.js b/lib/bothandlers.js index e16e86d..9bd01bb 100644 --- a/lib/bothandlers.js +++ b/lib/bothandlers.js @@ -36,6 +36,10 @@ var addHandlers = function(bot) { bot.channelEmotes = emotes }) + bot.socket.on("error", function(err) { + bot.logger.errlog.log(err) + }) + bot.socket.on("login", function(data) { bot.handleLogin(data) }) @@ -104,4 +108,4 @@ var addHandlers = function(bot) { }) } -exports.addHandlers = addHandlers \ No newline at end of file +exports.addHandlers = addHandlers diff --git a/lib/ircclient.js b/lib/ircclient.js index 40032ac..023701a 100644 --- a/lib/ircclient.js +++ b/lib/ircclient.js @@ -16,6 +16,7 @@ function IRCClient(ircInfo, bot) { this.nick = ircInfo["nick"] this.channel = ircInfo["channel"] this.pass = ircInfo["pass"] + this.connected = false this.client = new irc.Client(this.ircServer["server"], this.nick, { debug: true, @@ -29,6 +30,10 @@ function IRCClient(ircInfo, bot) { self.handleIRCMessage(from, message) }) + this.client.addListener("registered", function(message) { + self.connected = true + }) + this.client.addListener("error", function(error) { self.bot.logger.errlog.log("I~~~I: " + error) }) @@ -69,7 +74,8 @@ IRCClient.prototype.parseServer = function(server) { // Sends a message over IRC // message - The message to send IRCClient.prototype.sendMessage = function(message) { - this.client.say(this.channel, message) + if (this.connected) + this.client.say(this.channel, message) }; // Starts the connection to the server @@ -81,4 +87,4 @@ IRCClient.prototype.start = function() { self.client.say("NickServ", "IDENTIFY " + self.pass) }, 5000) } -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 1cda8d0..fe4c8d8 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "socket.io": "^1.3.3", "jade": "~1.3.1", "forever-monitor": "~1.2.3", - "irc": "~0.3.7", + "irc": "~0.3.9", "limiter": "~1.0.5" } -} \ No newline at end of file +} diff --git a/www/js/internals.js b/www/js/internals.js index 04110af..65b7ca2 100644 --- a/www/js/internals.js +++ b/www/js/internals.js @@ -1,5 +1,4 @@ socket = io(IO_URL) - socket.on("connect", function() { socket.emit("getInternals") })