mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 22:39:26 +01:00
Update modules/link/link.js
Tab fix attempt 2
This commit is contained in:
parent
8d3d5d08a5
commit
5f0bcd7710
@ -35,10 +35,9 @@ var link = function(dbot) {
|
|||||||
|
|
||||||
'~xkcd': function(event) {
|
'~xkcd': function(event) {
|
||||||
var comicId = event.params[1];
|
var comicId = event.params[1];
|
||||||
|
if(comicId == "*"){
|
||||||
if(comicId == "*"){
|
request("http://xkcd.com/info.0.json", function(error, response, body){
|
||||||
request("http://xkcd.com/info.0.json", function(error, response, body){
|
if (response.statusCode == "200") {
|
||||||
if (response.statusCode == "200") {
|
|
||||||
data = JSON.parse(body);
|
data = JSON.parse(body);
|
||||||
comicId = data.num;
|
comicId = data.num;
|
||||||
comicId = (Math.floor(Math.random() * comicId) + 1);
|
comicId = (Math.floor(Math.random() * comicId) + 1);
|
||||||
@ -47,21 +46,21 @@ var link = function(dbot) {
|
|||||||
event.params = event.message.split(' ');
|
event.params = event.message.split(' ');
|
||||||
dbot.instance.emit(event);
|
dbot.instance.emit(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else {
|
}else {
|
||||||
if(comicId){
|
if(comicId){
|
||||||
comicId = comicId + "/";
|
comicId = comicId + "/";
|
||||||
} else {
|
} else {
|
||||||
comicId = "";
|
comicId = "";
|
||||||
}
|
}
|
||||||
var link = "http://xkcd.com/"+comicId+"info.0.json";
|
var link = "http://xkcd.com/"+comicId+"info.0.json";
|
||||||
request(link, function(error, response, body) {
|
request(link, function(error, response, body) {
|
||||||
if (response.statusCode == "200") {
|
if (response.statusCode == "200") {
|
||||||
data = JSON.parse(body);
|
data = JSON.parse(body);
|
||||||
event.reply(dbot.t("xkcd",data));
|
event.reply(dbot.t("xkcd",data));
|
||||||
} else {
|
} else {
|
||||||
event.reply(dbot.t("no-hits"));
|
event.reply(dbot.t("no-hits"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user