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 = {
|
var api = {
|
||||||
// Return a user record given a primary nick or an alias
|
// Return a user record given a primary nick or an alias
|
||||||
'resolveUser': function(server, nick, callback) {
|
'resolveUser': function(server, nick, callback) {
|
||||||
var found = false;
|
var user = false;
|
||||||
if(_.has(this.userCache[server], nick)) {
|
if(_.has(this.userCache[server], nick)) {
|
||||||
this.api.getUser(this.userCache[server][nick], callback);
|
this.api.getUser(this.userCache[server][nick], callback);
|
||||||
} else {
|
} else {
|
||||||
this.db.search('users', { 'server': server }, function(result) {
|
this.db.search('users', { 'server': server }, function(result) {
|
||||||
if(result.primaryNick == nick || _.include(result.aliases, nick)) {
|
if(result.primaryNick == nick || _.include(result.aliases, nick)) {
|
||||||
this.userCache[server][nick] = result.id;
|
this.userCache[server][nick] = result.id;
|
||||||
found = true;
|
user = result;
|
||||||
callback(result);
|
|
||||||
}
|
}
|
||||||
}.bind(this), function(err) {
|
}.bind(this), function(err) {
|
||||||
if(!found) callback(false);
|
callback(user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user