diff --git a/modules/command/api.js b/modules/command/api.js index e42d3cb..5a757a5 100644 --- a/modules/command/api.js +++ b/modules/command/api.js @@ -26,7 +26,6 @@ var api = function(dbot) { }) .pluck('name') .value()); - console.log(allowedNicks); } if(!_.include(allowedNicks, user.primaryNick)) { diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index 4047290..74a09c9 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -79,7 +79,8 @@ var imgur = function(dbot) { testSlug + '.' + ext[_.random(0, ext.length - 1)]; dbot.db.imgur.totalHttpRequests += 1; - var image = request(testUrl, function(error, response, body) { + + request(testUrl, function(error, response, body) { // 492 is body.length of a removed image if(!error && response.statusCode == 200 && body.length != 492) { dbot.db.imgur.totalImages += 1; @@ -103,6 +104,18 @@ var imgur = function(dbot) { }.bind(this)); }, + 'getGoodRandomImage': function(callback) { + this.api.getRandomImage(function(url, slug, hash) { + this.api.getImageInfo(slug, function(imgData) { + if(imgData.data && imgData.data.height > 500 && imgData.data.width > 500) { + callback(url, imgData); + } else { + this.api.getGoodRandomImage(callback); + } + }.bind(this)); + }.bind(this)); + }, + 'getImageInfoString': function(slug, callback) { this.api.getImageInfo(slug, function(imgData) { callback(this.internalAPI.infoString(imgData)); @@ -167,6 +180,19 @@ var imgur = function(dbot) { }.bind(this)); }, + // Super Slow RI + '~ssri': function(event) { + var local = event.user; + if(event.params[1]) { + local = event.params.splice(1, event.params.length - 1).join(' ').trim(); + } + this.api.getGoodRandomImage(function(link, imgData) { + var info = this.internalAPI.infoString(imgData); + event.reply(local + ': ' + link + ' [' + info + ']'); + }.bind(this)); + }, + + // Super RI '~sri': function(event) { var local = event.user; if(event.params[1]) {