return fbman to ri results

This commit is contained in:
reality 2015-02-07 21:53:27 +00:00
parent e9e1e61540
commit 2f9133fcee

View File

@ -90,7 +90,8 @@ var imgur = function(dbot) {
var testSlug = random(5); var testSlug = random(5);
var testUrl = 'http://i.imgur.com/' + var testUrl = 'http://i.imgur.com/' +
testSlug + testSlug +
'.' + ext[_.random(0, ext.length - 1)]; '.' + ext[_.random(0, ext.length - 1)],
fbman = false;
dbot.db.imgur.totalHttpRequests += 1; dbot.db.imgur.totalHttpRequests += 1;
request(testUrl, function(error, response, body) { request(testUrl, function(error, response, body) {
@ -101,6 +102,7 @@ var imgur = function(dbot) {
if(_.has(dbot.modules, 'quotes')){ if(_.has(dbot.modules, 'quotes')){
// autoadd: {"abcdef": "facebookman"} // autoadd: {"abcdef": "facebookman"}
if(_.has(dbot.config.modules.imgur.autoadd,hash)){ if(_.has(dbot.config.modules.imgur.autoadd,hash)){
fbman = true;
var category = this.config.autoadd[hash]; var category = this.config.autoadd[hash];
if (_.contains(category, testUrl)){ if (_.contains(category, testUrl)){
// there's probably less than 62^5 chance of this happening // there's probably less than 62^5 chance of this happening
@ -110,7 +112,7 @@ var imgur = function(dbot) {
} }
} }
} }
callback(testUrl, testSlug, hash); callback(testUrl, testSlug, hash, fbman);
} else { } else {
this.api.getRandomImage(callback); this.api.getRandomImage(callback);
} }
@ -127,7 +129,9 @@ var imgur = function(dbot) {
return imgData.data.height == res.h && imgData.data.width == res.w; return imgData.data.height == res.h && imgData.data.width == res.w;
})) { })) {
callback(url, imgData); callback(url, imgData);
} else { } else if(fbman === true) {
callback(url, imgData);
} else {
this.api.getGoodRandomImage(callback); this.api.getGoodRandomImage(callback);
} }
}.bind(this)); }.bind(this));