mirror of
https://github.com/reality/dbot.git
synced 2024-11-24 04:49:25 +01:00
faster and includes uppercase characters (which are apparently the larger images)
This commit is contained in:
parent
d82108de83
commit
8f977f8923
@ -9,8 +9,13 @@ var _ = require('underscore')._,
|
|||||||
var imgur = function(dbot) {
|
var imgur = function(dbot) {
|
||||||
this.api = {
|
this.api = {
|
||||||
'getRandomImage': function(callback) {
|
'getRandomImage': function(callback) {
|
||||||
|
var random = function(len) {
|
||||||
|
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
||||||
|
return len ? chars.charAt(~~(Math.random()*chars.length)) + random(len-1) : "";
|
||||||
|
};
|
||||||
|
|
||||||
var testUrl = 'http://i.imgur.com/' +
|
var testUrl = 'http://i.imgur.com/' +
|
||||||
Math.random().toString(36).substr(2,6) +
|
random(5) +
|
||||||
'.png';
|
'.png';
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user