From 506ca60682de269731527ad18dfb7dbcc27d2f9c Mon Sep 17 00:00:00 2001 From: reality Date: Wed, 21 Aug 2013 14:55:44 +0000 Subject: [PATCH] onyl accept ~ri images bigger than 300x300 --- modules/imgur/imgur.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index f7e7854..fbbf102 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -94,7 +94,7 @@ var imgur = function(dbot) { } } } - callback(testUrl, testSlug,hash); + callback(testUrl, testSlug, hash); } else { this.api.getRandomImage(callback); } @@ -153,12 +153,19 @@ var imgur = function(dbot) { this.commands = { '~ri': function(event) { - this.api.getRandomImage(function(link, slug) { - this.api.getImageInfo(slug, function(imgData) { - var info = this.internalAPI.infoString(imgData); - event.reply(event.user + ': ' + link + ' [' + info + ']'); + var getImage = function() { + this.api.getRandomImage(function(link, slug) { + this.api.getImageInfo(slug, function(imgData) { + 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); } }