forked from GitHub/dbot
implement xkcd functionality
The strings.json file is extensible; other fields that can be placed in the xkcd string include the {year}, {month} and {day} of the comic; the {alt} text; and links to the {img}. A {transcript} is also available.
This commit is contained in:
parent
1a7825d8c6
commit
e3074d8054
@ -33,6 +33,24 @@ var link = function(dbot) {
|
||||
this.fetchTitle(event, link);
|
||||
},
|
||||
|
||||
'~xkcd': function(event) {
|
||||
var comicId = event.params[1];
|
||||
if(comicId){
|
||||
comicId = comicId + "/";
|
||||
} else {
|
||||
comicId = "";
|
||||
}
|
||||
var link = "http://xkcd.com/"+comicId+"info.0.json";
|
||||
request(link, function(error, response, body) {
|
||||
if (response.statusCode == "200") {
|
||||
data = JSON.parse(body);
|
||||
event.reply(dbot.t("xkcd",data));
|
||||
} else {
|
||||
event.reply(dbot.t("no-hits"));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
'~ud': function(event) {
|
||||
var query = event.input[1];
|
||||
var reqUrl = 'http://api.urbandictionary.com/v0/define?term=' + encodeURI(query);
|
||||
|
@ -2,5 +2,11 @@
|
||||
"title_not_found": {
|
||||
"english": "No page title found.",
|
||||
"na'vi": "Oel ke tsun run 'upxare atxin."
|
||||
},
|
||||
"xkcd": {
|
||||
"english": "xkcd {num}: {title} https://xkcd.com/{num}"
|
||||
},
|
||||
"no-hits": {
|
||||
"english": "No hits."
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user