redirects

This commit is contained in:
reality 2016-03-22 22:54:17 +00:00
parent 5e8ccb6bcc
commit bc114a10e6

View File

@ -24,6 +24,7 @@ var wikipedia = function(dbot) {
}
body = body[prop].revisions[0]['*'];
var oBody = body;
var redirect = body.match(/#redirect \[\[(.+)\]\]/i);
if(redirect) {
@ -53,6 +54,11 @@ var wikipedia = function(dbot) {
var sentence = body[_.random(0, body.length -1)];
if(_.isUndefined(sentence)) {
var links = oBody.match(/\[\[(.+)\]\]/g);
return this.api.randomSentence(links[_.random(0,links.length-1)], cb);
}
cb(sentence);
}.bind(this));
}