3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 22:39:26 +01:00
This commit is contained in:
reality 2013-01-24 10:03:18 +00:00
commit 77490bbda5

View File

@ -34,11 +34,12 @@ var link = function(dbot) {
}, },
'~ud': function(event) { '~ud': function(event) {
var reqUrl = 'http://api.urbandictionary.com/v0/define?term=' + event.params[1]; var query = event.params.join(" ").substring(4);
var reqUrl = 'http://api.urbandictionary.com/v0/define?term=' + encodeURI(query);
request(reqUrl, function(error, response, body) { request(reqUrl, function(error, response, body) {
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(event.params[1] + ': ' + result.list[0].definition); event.reply(query + ': ' + result.list[0].definition);
} else { } else {
event.reply(event.user + ': No definition found.'); event.reply(event.user + ': No definition found.');
} }