mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
better ~lol
This commit is contained in:
parent
04fb1cc67b
commit
0473597b0a
@ -18,7 +18,6 @@ var wikipedia = function(dbot) {
|
||||
}, function(error, response, body) {
|
||||
if(body && body[1].length != 0) {
|
||||
request.get('https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&&titles='+body[1][0], {'json': true}, function(error, response, body) {
|
||||
|
||||
body = body.query.pages
|
||||
for(var prop in body) {
|
||||
break;
|
||||
@ -30,9 +29,17 @@ var wikipedia = function(dbot) {
|
||||
body = body.replace(/\{(.+)\}/g,'');
|
||||
body = body.replace(/(\[|\])/g,'');
|
||||
body = body.replace(/(\(|\))/g,'');
|
||||
body = body.replace(/\*\s?/g,'');
|
||||
body = body.replace(/<.+?>/g,'');
|
||||
|
||||
body = body.split('\n');
|
||||
|
||||
body = _.filter(body, function(line) {
|
||||
var spaces = line.match(/\s/g);
|
||||
return line != '' && !line.match(/^\s+$/) && !line.match(/^Category:/) && !line.match(/http:\/\//) && !line.match(/\|/) && spaces && spaces.length > 10 && spaces.length < 60;
|
||||
});
|
||||
|
||||
console.log(body);
|
||||
body = body.split('\n');
|
||||
|
||||
var sentence = body[_.random(0, body.length -1)];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user