From 46de1a5facb43d8c4652515fa929b899b72d1086 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 9 Sep 2013 19:30:23 +0000 Subject: [PATCH] present for roi --- modules/imgur/imgur.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js index 3cab59c..4047290 100644 --- a/modules/imgur/imgur.js +++ b/modules/imgur/imgur.js @@ -167,6 +167,28 @@ var imgur = function(dbot) { }.bind(this)); }, + '~sri': function(event) { + var local = event.user; + if(event.params[1]) { + local = event.params.splice(1, event.params.length - 1).join(' ').trim(); + } + request.get({ + 'url': this.ApiRoot + 'gallery/random/random/', + 'json': true, + 'headers': { + 'Authorization': 'Client-ID ' + this.config.apikey + } + }, function(err, response, body) { + if(body.data && body.data[0] != undefined) { + var num = _.random(0, body.data.length - 1); + this.api.getGalleryInfo(body.data[num].id, function(gal) { + event.reply(local + ': ' + gal.data.link + ' [' + + this.internalAPI.galleryInfoString(gal) + ']'); + }.bind(this)); + } + }.bind(this)); + }, + '~imgur': function(event) { var term = event.input[1]; request.get({