From 25edd4416c387c4b5bd10c6f0897be6367ac1960 Mon Sep 17 00:00:00 2001 From: Darren Date: Wed, 30 Jan 2013 13:42:30 +0000 Subject: [PATCH] /list command working properly --- server/irc/commands.js | 3 +-- server/irc/server.js | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/server/irc/commands.js b/server/irc/commands.js index 0ec6785..b18799c 100644 --- a/server/irc/commands.js +++ b/server/irc/commands.js @@ -174,7 +174,6 @@ var listeners = { }, 'RPL_LISTSTART': function (command) { this.irc_connection.emit('server:' + this.irc_connection.irc_host.hostname + ':list_start', {}); - this.client.buffer.list = []; }, 'RPL_LISTEND': function (command) { this.irc_connection.emit('server:' + this.irc_connection.irc_host.hostname + ':list_end', {}); @@ -182,7 +181,7 @@ var listeners = { 'RPL_LIST': function (command) { this.irc_connection.emit('server:' + this.irc_connection.irc_host.hostname + ':list_channel', { channel: command.params[1], - num_users: parseint(command.params[2], 10), + num_users: parseInt(command.params[2], 10), topic: command.trailing }); }, diff --git a/server/irc/server.js b/server/irc/server.js index afd4d68..2a431e6 100755 --- a/server/irc/server.js +++ b/server/irc/server.js @@ -1,5 +1,6 @@ var util = require('util'), - EventBinder = require('./eventbinder.js'); + EventBinder = require('./eventbinder.js'), + _ = require('lodash'); var IrcServer = function (irc_connection, host, port) { this.irc_connection = irc_connection; @@ -63,6 +64,7 @@ function onOptions(event) { function onListStart(event) { this.irc_connection.clientEvent('list_start', {}); + this.list_buffer = []; }; function onListChannel(event) { @@ -82,20 +84,21 @@ function onListChannel(event) { chans: buf }); this.list_buffer = []; - }; + } }; function onListEnd(event) { - if (this.list_buffer.length > 200) { - buf = _.sortBy(this.list_buffer, function (channel) { - // sortBy sorts in ascending order, we want to sort by descending, hence using 0 - num_users. - return 0 - channel.num_users; - }); - this.irc_connection.clientEvent('list_channel', { - chans: buf - }); - this.list_buffer = []; - }; + var buf; + + buf = _.sortBy(this.list_buffer, function (channel) { + // sortBy sorts in ascending order, we want to sort by descending, hence using 0 - num_users. + return 0 - channel.num_users; + }); + this.irc_connection.clientEvent('list_channel', { + chans: buf + }); + this.list_buffer = []; + this.irc_connection.clientEvent('list_end', {}); }; -- 2.25.1