var _ = require('underscore')._, uuid = require('node-uuid'), databank = require('databank'), AlreadyExistsError = databank.AlreadyExistsError, NoSuchThingError = databank.NoSuchThingError, NotImplementedError = databank.NotImplementedError; var api = function(dbot) { var escapeRegexen = function(str) { return (str+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); }; var api = { // Return a user record given a primary nick or an alias 'resolveUser': function(server, nick, callback) { var user = false; this.db.search('users', { 'server': server }, function(result) { if(result.primaryNick == nick || _.include(result.aliases, nick)) { user = result; } }, function(err) { if(!err) { callback(user); } }); }, // Return many user records given primary nicks of aliases 'resolveUsers': function(server, nicks, callback) { var users = []; this.db.search('users', { 'server': server }, function(result) { var pNicks = result.aliases.slice(0).unshift(result.primaryNick); for(var i=0;i