mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 12:29:26 +01:00
Urban dictionary API changed - removed result_type
This commit is contained in:
parent
09f8f525e6
commit
1657e7cc02
@ -47,14 +47,19 @@ var link = function(dbot) {
|
|||||||
encodeURI(query);
|
encodeURI(query);
|
||||||
|
|
||||||
request(reqUrl, function(error, response, body) {
|
request(reqUrl, function(error, response, body) {
|
||||||
|
console.log(reqUrl);
|
||||||
|
|
||||||
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, 'list') && result.list.length > 0) {
|
||||||
callback(result.list[0].word, result.list[0].definition.split('\n')[0]);
|
callback(result.list[0].word, result.list[0].definition.split('\n')[0]);
|
||||||
} else {
|
} else {
|
||||||
callback(false);
|
callback(false);
|
||||||
}
|
}
|
||||||
} catch(err) { callback(false); }
|
} catch(err) {
|
||||||
|
console.log(err);
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user