From dff4a1ffd7cf9ca3097ea0227a82d18184bbca25 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 4 Jun 2012 13:09:40 +0200 Subject: o Updating the atom plugin to the latest API. --- irc-client.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'irc-client.js') diff --git a/irc-client.js b/irc-client.js index bd8edb8..ad21a5e 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: ' + _.size(client.channels)); + info('Connected, channels: ' + _.keys(client.channels).join(', ')); _.each(client.channels, function(channel) { info('JOINing ' + channel.name); irc.join(channel.name); @@ -54,13 +54,16 @@ IrcClient.prototype.init = function(irc) { client.connect(); }); irc.on('join', function(nick, channelName) { - _.each(client.channels, function(channel) { - info('JOINed ' + channel.name); - channel.fire(channelName); - }); + info('JOINed ' + channelName); + client.getChannel(channelName).fire(channelName); }); irc.on('privmsg', function(nick, channel, message) { - client.emit('privmsg', 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)); }); return irc; } @@ -92,12 +95,18 @@ IrcClient.prototype.join = function(name, cb) { c.addListener(cb); } if(this.connected) { + info('join: already connected: ' + name); c.fire(name); } } -IrcClient.prototype.notice = function(to, message) { - this.irc.notice(to, message); +// TODO: fix +function dispatch(name) { + this.irc[name].apply(this.irc, arguments); } +IrcClient.prototype.notice = function() { this.irc.notice.apply(this.irc, arguments); } +IrcClient.prototype.privmsg = function() { this.irc.privmsg.apply(this.irc, arguments); } +IrcClient.prototype.topic = function() { this.irc.topic.apply(this.irc, arguments); } + module.exports.IrcClient = IrcClient; -- cgit v1.2.3