mirror of
https://github.com/reality/dbot.git
synced 2024-11-24 04:49:25 +01:00
fix imgur for now
This commit is contained in:
parent
8e8953999d
commit
5eba864f22
@ -7,7 +7,6 @@ var _ = require('underscore')._,
|
|||||||
request = require('request');
|
request = require('request');
|
||||||
|
|
||||||
var imgur = function(dbot) {
|
var imgur = function(dbot) {
|
||||||
this.db = dbot.db.imgur;
|
|
||||||
this.internalAPI = {
|
this.internalAPI = {
|
||||||
'infoString': function(imgData) {
|
'infoString': function(imgData) {
|
||||||
info = '';
|
info = '';
|
||||||
@ -45,11 +44,11 @@ var imgur = function(dbot) {
|
|||||||
var testUrl = 'http://i.imgur.com/' +
|
var testUrl = 'http://i.imgur.com/' +
|
||||||
testSlug +
|
testSlug +
|
||||||
'.' + ext[_.random(0, ext.length - 1)];
|
'.' + ext[_.random(0, ext.length - 1)];
|
||||||
this.db.totalHttpRequests += 1;
|
dbot.db.imgur.totalHttpRequests += 1;
|
||||||
var image = request(testUrl, function(error, response, body) {
|
var image = request(testUrl, function(error, response, body) {
|
||||||
// 492 is body.length of a removed image
|
// 492 is body.length of a removed image
|
||||||
if(!error && response.statusCode == 200 && body.length != 492) {
|
if(!error && response.statusCode == 200 && body.length != 492) {
|
||||||
this.db.totalImages += 1;
|
dbot.db.imgur.totalImages += 1;
|
||||||
callback(testUrl, testSlug);
|
callback(testUrl, testSlug);
|
||||||
} else {
|
} else {
|
||||||
this.api.getRandomImage(callback);
|
this.api.getRandomImage(callback);
|
||||||
@ -71,7 +70,7 @@ var imgur = function(dbot) {
|
|||||||
'Authorization': 'Client-ID ' + dbot.config.imgur.apikey
|
'Authorization': 'Client-ID ' + dbot.config.imgur.apikey
|
||||||
}
|
}
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
this.db.totalApiRequests += 1;
|
dbot.db.imgur.totalApiRequests += 1;
|
||||||
callback(body);
|
callback(body);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user