From 96db56a25c889091f720448a7481bbe4ebc0356d Mon Sep 17 00:00:00 2001 From: reality Date: Wed, 16 Oct 2013 08:15:00 +0000 Subject: [PATCH] exclude common screenshot resolutions for ~ri --- modules/imgur/imgur.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index cd773cc..f0ad8f6 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -10,6 +10,16 @@ var _ = require('underscore')._, var imgur = function(dbot) { this.ApiRoot = 'https://api.imgur.com/3/'; + this.ExcludeRes = [ + { 'w': 800, 'h': 600 }, + { 'w': 1024, 'h': 768 }, + { 'w': 1280, 'h': 768 }, + { 'w': 1280, 'h': 960 }, + { 'w': 1366, 'h': 768 }, + { 'w': 1600, 'h': 900 }, + { 'w': 1680, 'h': 1050 }, + { 'w': 1920, 'h': 1080 } + ]; this.riCache = []; this.internalAPI = { @@ -109,7 +119,12 @@ var imgur = function(dbot) { 'getGoodRandomImage': function(callback) { this.api.getRandomImage(function(url, slug, hash) { this.api.getImageInfo(slug, function(imgData) { - if(!_.isUndefined(imgData) && imgData.data && imgData.data.height > 500 && imgData.data.width > 500) { + if(!_.isUndefined(imgData) && + imgData.data && + imgData.data.height > 500 && imgData.data.width > 500 && + !_.any(this.ExcludeRes, function(res) { + return imgData.data.height == res.h && imgData.data.width == res.w; + })) { callback(url, imgData); } else { this.api.getGoodRandomImage(callback);