diff options
-rw-r--r-- | irc-client.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/irc-client.js b/irc-client.js index ad21a5e..9d0e616 100644 --- a/irc-client.js +++ b/irc-client.js @@ -43,7 +43,7 @@ IrcClient.prototype.init = function(irc) { var client = this; this.debugLevel && irc.setDebugLevel(this.debugLevel); irc.on('connected', function() { - info('Connected, channels: ' + _.keys(client.channels).join(', ')); + info('Connected'); _.each(client.channels, function(channel) { info('JOINing ' + channel.name); irc.join(channel.name); @@ -51,19 +51,25 @@ IrcClient.prototype.init = function(irc) { }); irc.on('disconnected', function() { info('Disconnected, reconnecting...'); - client.connect(); + // A small sleep here is nice + setTimeout(function() { + info('Connecting'); + client.connect(); + }, 1000); }); irc.on('join', function(nick, channelName) { + if(nick != irc.whoami()) { + return; + } info('JOINed ' + channelName); client.getChannel(channelName).fire(channelName); }); - irc.on('privmsg', function(nick, channel, message) { - client.emit.call(['privmsg'].slice.apply(arguments)); -// client.emit('privmsg', nick, channel, message); - }); - irc.on('topic', function() { - console.log('topic: ' + util.inspect(arguments)); - client.emit.call(null, ['topic'].slice.apply(arguments)); + _.each(['privmsg', 'topic', 'join'], function(e) { + irc.on(e, function() { + var args = [e]; + args.push.apply(args, arguments); + client.emit.apply(client, args); + }); }); return irc; } |