mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
could it be?
This commit is contained in:
parent
dd7abf2fff
commit
397b732341
@ -10,18 +10,17 @@ var api = function(dbot) {
|
||||
var api = {
|
||||
// Return a user record given a primary nick or an alias
|
||||
'resolveUser': function(server, nick, callback) {
|
||||
var found = false;
|
||||
var user = false;
|
||||
if(_.has(this.userCache[server], nick)) {
|
||||
this.api.getUser(this.userCache[server][nick], callback);
|
||||
} else {
|
||||
this.db.search('users', { 'server': server }, function(result) {
|
||||
if(result.primaryNick == nick || _.include(result.aliases, nick)) {
|
||||
this.userCache[server][nick] = result.id;
|
||||
found = true;
|
||||
callback(result);
|
||||
user = result;
|
||||
}
|
||||
}.bind(this), function(err) {
|
||||
if(!found) callback(false);
|
||||
callback(user);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user