nicks are server-wide, not channel-specific

This commit is contained in:
reality 2012-12-23 17:11:56 +00:00
parent bd6c42d57e
commit 6db6c804e5

View File

@ -4,23 +4,18 @@
*/ */
var users = function(dbot) { var users = function(dbot) {
var knownUsers = dbot.db.knownUsers; var knownUsers = dbot.db.knownUsers;
var getChanUsers = function(event) { var getServerUsers = function(event) {
if(!knownUsers.hasOwnProperty(event.server)) { if(!knownUsers.hasOwnProperty(event.server)) {
knownUsers[event.server] = {}; knownUsers[event.server] = {};
} }
var serverUsers = knownUsers[event.server]; return knownUsers[event.server];
if(!serverUsers.hasOwnProperty(event.channel.name)) {
serverUsers[event.channel.name] = [];
}
return serverUsers[event.channel.name];
}; };
dbot.instance.addListener('366', 'users', function(event) { dbot.instance.addListener('366', 'users', function(event) {
var chanUsers = getChanUsers(event); var knownUsers = getServerUsers(event);
for(var nick in event.channel.nicks) { for(var nick in event.channel.nicks) {
if(!chanUsers.include(nick) && event.channel.nicks.hasOwnProperty(nick)) { if(!knownUsers.hasOwnProperty(nick) && event.channel.nicks.hasOwnProperty(nick)) {
chanUsers.push(nick); knownUsers[nick] = {};
} }
} }
}); });
@ -30,9 +25,9 @@ var users = function(dbot) {
'ignorable': false, 'ignorable': false,
'listener': function(event) { 'listener': function(event) {
var chanusers = getChanUsers(event); var knownUsers = getServerUsers(event);
if(!chanUsers.include(event.user)) { if(!knownUsers.hasOwnProperty(event.user)) {
chanUsers.push(event.user); knownUsers[event.user] = {};
} }
}, },
'on': 'JOIN', 'on': 'JOIN',