From 29899adfc07733f4f61b7b09473a39dd3db626db Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 23 Jan 2013 18:56:07 +0000 Subject: [PATCH] remove one-word restriction on ~ud There's undoubtedly a better way to do this, but it works. ~ud now allows more than one word to be sent to UD's servers. --- modules/link/link.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/link/link.js b/modules/link/link.js index 0efbd02..a44acc8 100644 --- a/modules/link/link.js +++ b/modules/link/link.js @@ -34,11 +34,12 @@ var link = function(dbot) { }, '~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) { var result = JSON.parse(body); 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 { event.reply(event.user + ': No definition found.'); }