onyl accept ~ri images bigger than 300x300

This commit is contained in:
reality 2013-08-21 14:55:44 +00:00
parent d71906838d
commit 506ca60682

View File

@ -94,7 +94,7 @@ var imgur = function(dbot) {
} }
} }
} }
callback(testUrl, testSlug,hash); callback(testUrl, testSlug, hash);
} else { } else {
this.api.getRandomImage(callback); this.api.getRandomImage(callback);
} }
@ -153,12 +153,19 @@ var imgur = function(dbot) {
this.commands = { this.commands = {
'~ri': function(event) { '~ri': function(event) {
this.api.getRandomImage(function(link, slug) { var getImage = function() {
this.api.getImageInfo(slug, function(imgData) { this.api.getRandomImage(function(link, slug) {
var info = this.internalAPI.infoString(imgData); this.api.getImageInfo(slug, function(imgData) {
event.reply(event.user + ': ' + link + ' [' + info + ']'); if(imgData && _.has(imgData, 'data')
&& imgData.data.height > 300 && imgData.data.width > 300) {
var info = this.internalAPI.infoString(imgData);
event.reply(event.user + ': ' + link + ' [' + info + ']');
} else {
getImage();
}
}.bind(this));
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this);
} }
} }