/list command working properly
authorDarren <darren@darrenwhitlen.com>
Wed, 30 Jan 2013 13:42:30 +0000 (13:42 +0000)
committerDarren <darren@darrenwhitlen.com>
Thu, 31 Jan 2013 14:58:44 +0000 (14:58 +0000)
server/irc/commands.js
server/irc/server.js

index 0ec67858b2beedd935a072e0ecf10871ba89b54a..b18799cedff147b65fa0078186c909886c4ca5a6 100644 (file)
@@ -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
         });
     },
index afd4d68ffe85292abc31030101787d40351af4b2..2a431e6796421267713131df622747372b2d4163 100755 (executable)
@@ -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', {});
 };