3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00
This commit is contained in:
reality 2013-08-27 23:32:31 +00:00
parent d718b81d79
commit 8aa9842091

View File

@ -9,12 +9,20 @@ var api = function(dbot) {
var api = {
// Return a user record given a primary nick or an alias
'resolveUser': function(server, nick, callback) {
'resolveUser': function(server, nick, callback, lc) {
var user = false;
if(lc) nick = nick.toLowerCase();
if(_.has(this.userCache[server], nick)) {
this.api.getUser(this.userCache[server][nick], callback);
} else {
this.db.search('users', { 'server': server }, function(result) {
if(lc) {
result.primaryNick = result.primaryNick.toLowerCase();
_.each(result.aliases, function(v, k) {
result.aliases[k] = v.toLowerCase();
});
}
if(result.primaryNick == nick || _.include(result.aliases, nick)) {
this.userCache[server][nick] = result.id;
user = result;