mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
couple of formatting fixes + fix indentation [Close #258]
This commit is contained in:
parent
b02fe22d02
commit
d7c193cbe9
2
jsbot
2
jsbot
@ -1 +1 @@
|
|||||||
Subproject commit 35910d9025fa3af15b24cecc3f6e7ee897aee4dc
|
Subproject commit 9477dc33ff1b940f8c07225f00d0648de2a41cb4
|
@ -20,7 +20,7 @@ var link = function(dbot) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var commands = {
|
var commands = {
|
||||||
'~title': function(event) {
|
'~title': function(event) {
|
||||||
var link = this.links[event.channel.name];
|
var link = this.links[event.channel.name];
|
||||||
@ -34,49 +34,53 @@ var link = function(dbot) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'~xkcd': function(event) {
|
'~xkcd': function(event) {
|
||||||
var comicId;
|
var comicId = event.params[1] || "";
|
||||||
if(!_.isUndefined(event.params[1])) {
|
|
||||||
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") {
|
try {
|
||||||
data = JSON.parse(body);
|
if(response.statusCode == "200") {
|
||||||
event.params[1] = (Math.floor(Math.random() * data.num) + 1);
|
data = JSON.parse(body);
|
||||||
dbot.commands['~xkcd'](event);
|
event.params[1] = (Math.floor(Math.random() * data.num) + 1);
|
||||||
}
|
dbot.commands['~xkcd'](event);
|
||||||
});
|
}
|
||||||
}else {
|
} catch(err) { };
|
||||||
if(comicId){
|
});
|
||||||
|
} else {
|
||||||
|
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") {
|
try {
|
||||||
data = JSON.parse(body);
|
if (response.statusCode == "200") {
|
||||||
event.reply(dbot.t("xkcd",data));
|
data = JSON.parse(body);
|
||||||
} else {
|
event.reply(dbot.t("xkcd",data));
|
||||||
event.reply(dbot.t("no-hits"));
|
} else {
|
||||||
}
|
event.reply(dbot.t("no-hits"));
|
||||||
|
}
|
||||||
|
} catch(err) { };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'~ud': function(event) {
|
'~ud': function(event) {
|
||||||
var query = event.input[1];
|
var query = event.input[1];
|
||||||
var reqUrl = 'http://api.urbandictionary.com/v0/define?term=' + encodeURI(query);
|
var reqUrl = 'http://api.urbandictionary.com/v0/define?term=' + encodeURI(query);
|
||||||
|
|
||||||
request(reqUrl, function(error, response, body) {
|
request(reqUrl, function(error, response, body) {
|
||||||
try {
|
try {
|
||||||
var result = JSON.parse(body);
|
var result = JSON.parse(body);
|
||||||
if(_.has(result, 'result_type') && result.result_type != 'no_results') {
|
if(_.has(result, 'result_type') && result.result_type != 'no_results') {
|
||||||
event.reply(query + ': ' + result.list[0].definition.split('\n')[0]);
|
event.reply(query + ': ' + result.list[0].definition.split('\n')[0]);
|
||||||
} else {
|
} else {
|
||||||
event.reply(event.user + ': No definition found.');
|
event.reply(event.user + ': No definition found.');
|
||||||
}
|
}
|
||||||
} catch(err) { }
|
} catch(err) { }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit ea795e4d17aa500923468366e73a10f6fbc94ade
|
Subproject commit a803be39a19a09bed1fcb0586a882b046ae29c99
|
Loading…
Reference in New Issue
Block a user