From 01b2d2205954ee12be8b08107a0462e96449d64e Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 7 Jul 2014 11:06:38 +0000 Subject: [PATCH] test --- jsbot | 2 +- modules/users/api.js | 7 ++++++- modules/users/users.js | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/jsbot b/jsbot index c8bfa1b..14868e9 160000 --- a/jsbot +++ b/jsbot @@ -1 +1 @@ -Subproject commit c8bfa1bd838d8ff074c266055e373e63506e647b +Subproject commit 14868e9d935bfd39ba698f6c610fc0c049da2b8a diff --git a/modules/users/api.js b/modules/users/api.js index 4458bbb..00ec82e 100644 --- a/modules/users/api.js +++ b/modules/users/api.js @@ -68,6 +68,10 @@ var api = function(dbot) { }, 'resolveChannel': function(server, channelName, callback) { + if(_.has(this.chanCache[server], channelName)) { + return this.api.getChannel(this.chanCache[server][channelName], callback); + } + var channel = false; this.db.search('channel_users', { 'server': server, @@ -76,9 +80,10 @@ var api = function(dbot) { channel = result; }, function(err) { if(!err) { + this.chanCache[server][channelName] = channel.id; callback(channel); } - }); + }.bind(this)); }, 'getChannel': function(uuid, callback) { diff --git a/modules/users/users.js b/modules/users/users.js index 2fd2a71..5192cff 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -11,6 +11,10 @@ var users = function(dbot) { _.each(dbot.config.servers, function(v, k) { this.userCache[k] = {}; }.bind(this)); + this.chanCache = {}; + _.each(dbot.config.servers, function(v, k) { + this.chanCache[k] = {}; + }.bind(this)); /*** Internal API ***/ this.internalAPI = {