that will soh wye

This commit is contained in:
reality 2014-01-04 17:59:14 +00:00
parent a4a6689d38
commit 2204c910b9
2 changed files with 21 additions and 18 deletions

View File

@ -24,12 +24,18 @@ var api = function(dbot) {
} }
if(result.primaryNick == nick || _.include(result.aliases, nick)) { if(result.primaryNick == nick || _.include(result.aliases, nick)) {
this.userCache[server][nick] = result.id;
user = result; user = result;
} }
}.bind(this), function(err) { }.bind(this), function(err) {
if(user) {
if(!_.has(this.userCache[server], nick)) {
this.userCache[server][nick] = user.id;
} else if(this.userCache[server][nick] !== user.id) {
this.userCache[server][nick] = user.id;
}
}
callback(user); callback(user);
}); }.bind(this));
} }
}, },

View File

@ -97,7 +97,6 @@ var users = function(dbot) {
this.listener = function(event) { this.listener = function(event) {
this.api.isKnownUser(event.server, event.newNick, function(isKnown) { this.api.isKnownUser(event.server, event.newNick, function(isKnown) {
event.rUser.currentNick = event.newNick; event.rUser.currentNick = event.newNick;
dbot.api.event.emit('new_current_nick', [ event.rUser ]);
if(!isKnown) { if(!isKnown) {
event.rUser.aliases.push(event.newNick); event.rUser.aliases.push(event.newNick);
@ -120,6 +119,7 @@ var users = function(dbot) {
// 6. Update staff channel lists // 6. Update staff channel lists
var checkChannel = function(done) { var checkChannel = function(done) {
if(event.channel) {
this.api.resolveChannel(event.server, event.channel.name, function(channel) { this.api.resolveChannel(event.server, event.channel.name, function(channel) {
if(!channel) { if(!channel) {
this.internalAPI.createChannel(event.server, event.channel.name, done); this.internalAPI.createChannel(event.server, event.channel.name, done);
@ -127,13 +127,16 @@ var users = function(dbot) {
done(channel); done(channel);
} }
}.bind(this)); }.bind(this));
} else {
done(null);
}
}.bind(this); }.bind(this);
var checkUser = function(done) { var checkUser = function(done) {
this.api.resolveUser(event.server, event.user, function(user) { this.api.resolveUser(event.server, event.user, function(user) {
if(!user) { if(!user) {
this.internalAPI.createUser(event.server, event.user, done); this.internalAPI.createUser(event.server, event.user, done);
} else { } else {
if(event.user != user.currentNick) { if(event.user !== user.currentNick) {
user.currentNick = event.user; user.currentNick = event.user;
this.db.save('users', user.id, user, function() { this.db.save('users', user.id, user, function() {
dbot.api.event.emit('new_current_nick', [ user ]); dbot.api.event.emit('new_current_nick', [ user ]);
@ -189,18 +192,12 @@ var users = function(dbot) {
} }
}.bind(this); }.bind(this);
if(event.user && event.channel && _.include(['JOIN', 'MODE', 'NICK', 'PRIVMSG'], event.action)) { if(event.user && _.include(['JOIN', 'MODE', 'NICK', 'PRIVMSG'], event.action)) {
checkChannel(function(channel) { checkChannel(function(channel) {
event.rChannel = channel; event.rChannel = channel;
checkUser(function(user) { checkUser(function(user) {
event.rUser = user; event.rUser = user;
if(!_.has(this.userCache[event.server], event.rUser.currentNick)) {
this.userCache[event.server][event.rUser.currentNick] = event.rUser.id;
} else if(this.userCache[event.server][event.rUser.currentNick] != event.rUser.id) {
this.userCache[event.server][event.rUser.currentNick] = event.rUser.id;
}
if(event.channel) { if(event.channel) {
checkChannelUsers(function() { checkChannelUsers(function() {
callback(); callback();