This commit is contained in:
reality 2013-09-10 16:29:23 +00:00
parent 46de1a5fac
commit df7d4149c6
2 changed files with 27 additions and 2 deletions

View File

@ -26,7 +26,6 @@ var api = function(dbot) {
})
.pluck('name')
.value());
console.log(allowedNicks);
}
if(!_.include(allowedNicks, user.primaryNick)) {

View File

@ -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]) {