From dfaa795b8f1c4c84b2255875f2cd5c2750387f68 Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 26 Jul 2013 17:01:22 +0000 Subject: [PATCH] put eachseries in process.nextTick --- modules/users/users.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/modules/users/users.js b/modules/users/users.js index e8c376e..3270fcf 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -196,23 +196,25 @@ var users = function(dbot) { dbot.instance.addListener('366', 'users', function(event) { var checkChannel = function(channel) { async.eachSeries(_.keys(event.channel.nicks), function(nick, next) { - var staff = event.channel.nicks[nick]; - - this.api.resolveUser(event.server, nick, function(user) { - var checkChannelUser = function(user) { - if(!_.include(channel.users, user.id)) { - this.internalAPI.addChannelUser(channel, user, staff, next); - } else { - this.internalAPI.modChannelStaff(channel, user, staff, next); - } - }.bind(this); + process.nextTick(function() { + var staff = event.channel.nicks[nick]; + + this.api.resolveUser(event.server, nick, function(user) { + var checkChannelUser = function(user) { + if(!_.include(channel.users, user.id)) { + this.internalAPI.addChannelUser(channel, user, staff, next); + } else { + this.internalAPI.modChannelStaff(channel, user, staff, next); + } + }.bind(this); - if(user) { - checkChannelUser(user); - } else { - this.internalAPI.createUser(event.server, nick, checkChannelUser); - } - }.bind(this)); + if(user) { + checkChannelUser(user); + } else { + this.internalAPI.createUser(event.server, nick, checkChannelUser); + } + }.bind(this)); + }); }.bind(this), function(err) { console.log('finished checking ' + channel); });