From 6db6c804e5347a92c3866b38f86414f11989b9b3 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 23 Dec 2012 17:11:56 +0000 Subject: [PATCH] nicks are server-wide, not channel-specific --- modules/users/users.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/modules/users/users.js b/modules/users/users.js index 5dfd216..623bb07 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -4,23 +4,18 @@ */ var users = function(dbot) { var knownUsers = dbot.db.knownUsers; - var getChanUsers = function(event) { - if(!knownUsers.hasOwnProperty(event.server)) { + var getServerUsers = function(event) { + if(!knownUsers.hasOwnProperty(event.server)) { knownUsers[event.server] = {}; } - var serverUsers = knownUsers[event.server]; - - if(!serverUsers.hasOwnProperty(event.channel.name)) { - serverUsers[event.channel.name] = []; - } - return serverUsers[event.channel.name]; + return knownUsers[event.server]; }; dbot.instance.addListener('366', 'users', function(event) { - var chanUsers = getChanUsers(event); + var knownUsers = getServerUsers(event); for(var nick in event.channel.nicks) { - if(!chanUsers.include(nick) && event.channel.nicks.hasOwnProperty(nick)) { - chanUsers.push(nick); + if(!knownUsers.hasOwnProperty(nick) && event.channel.nicks.hasOwnProperty(nick)) { + knownUsers[nick] = {}; } } }); @@ -30,9 +25,9 @@ var users = function(dbot) { 'ignorable': false, 'listener': function(event) { - var chanusers = getChanUsers(event); - if(!chanUsers.include(event.user)) { - chanUsers.push(event.user); + var knownUsers = getServerUsers(event); + if(!knownUsers.hasOwnProperty(event.user)) { + knownUsers[event.user] = {}; } }, 'on': 'JOIN',