Skip to content

Commit

Permalink
Fix irc?
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearace committed Feb 19, 2015
1 parent b189ea1 commit 695b92c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion lib/bothandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -104,4 +108,4 @@ var addHandlers = function(bot) {
})
}

exports.addHandlers = addHandlers
exports.addHandlers = addHandlers
10 changes: 8 additions & 2 deletions lib/ircclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
})
Expand Down Expand Up @@ -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
Expand All @@ -81,4 +87,4 @@ IRCClient.prototype.start = function() {
self.client.say("NickServ", "IDENTIFY " + self.pass)
}, 5000)
}
};
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
1 change: 0 additions & 1 deletion www/js/internals.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
socket = io(IO_URL)

socket.on("connect", function() {
socket.emit("getInternals")
})
Expand Down

0 comments on commit 695b92c

Please sign in to comment.