mirror of
https://github.com/reality/dbot.git
synced 2024-11-30 07:59:25 +01:00
~xkcd command now finds relevant XKCDs when given text instead of a number
This commit is contained in:
parent
c298813b28
commit
0c8c377b08
@ -109,6 +109,30 @@ var link = function(dbot) {
|
||||
}
|
||||
} catch(err) { };
|
||||
});
|
||||
} else {
|
||||
if (isNaN(parseInt(comicId))) {
|
||||
var relevantUrl = 'https://relevantxkcd.appspot.com/process';
|
||||
request({
|
||||
url: relevantUrl,
|
||||
qs: {
|
||||
action:'xkcd',
|
||||
query: comicId
|
||||
}
|
||||
}, function(err, res, body) {
|
||||
comicId = body.split(' ').slice(2)[0].trim();
|
||||
|
||||
var link = "http://xkcd.com/"+comicId+"/info.0.json";
|
||||
request(link, function(error, response, body) {
|
||||
try {
|
||||
if (response.statusCode == "200") {
|
||||
data = JSON.parse(body);
|
||||
event.reply(dbot.t("xkcd", data));
|
||||
} else {
|
||||
event.reply(dbot.t("no-hits"));
|
||||
}
|
||||
} catch(err) { };
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if(comicId !== "") {
|
||||
comicId = comicId + "/";
|
||||
@ -126,7 +150,7 @@ var link = function(dbot) {
|
||||
} catch(err) { };
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
'~ud': function(event) {
|
||||
|
Loading…
Reference in New Issue
Block a user