-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoges.js
53 lines (47 loc) · 1.25 KB
/
doges.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var request = require('request');
var shibes = [];
var numberOfDoges = 50;
exports.manyDoge = () => {
cacheShibes();
}
function cacheShibes() {
request('http://shibe.online/api/shibes?count=' + numberOfDoges + '&urls=true', function (error, response, body) {
if (!error && response.statusCode == 200) {
var data = JSON.parse(body);
var dogesSoFar = shibes.length;
for (var i = 0; i < numberOfDoges; i++) {
var url = data[i];
if (shibes.indexOf(url) === - 1) {
shibes[dogesSoFar] = url;
dogesSoFar++;
}
}
if (cacheShibes < 20) {
cacheShibes();
}
console.log(dogesSoFar + ' Shibes! Many doge such wow');
}
});
}
function getRandomDoge() {
if (shibes.length === 0) {
return 'http://comicsandmemes.com/wp-content/uploads/2013/12/shebe-doge-pokemon.png';
}
var index = Math.floor(shibes.length * Math.random());
return shibes[index];
}
exports.blacklist = (url) => {
var index = shibes.indexOf(url);
if (index > -1) {
var shibes = shibes.splice(index, 1);
console.log('Shibe number ' + index + ' removed');
}
}
exports.getDogeObject = () => {
return {
'text': getRandomDoge(),
'icon_emoji': ':suchwow:',
'username': 'DogeBot',
'unfurl_links': true
};
}