From 68f78cad9c2ed138614c4b89829a80df9ab26eda Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 24 Jan 2013 10:05:50 +0000 Subject: [PATCH] ~ud regex and only use first response line [#197] --- modules/link/link.js | 5 +++-- modules/poll/config.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/link/link.js b/modules/link/link.js index a44acc8..f3f39aa 100644 --- a/modules/link/link.js +++ b/modules/link/link.js @@ -34,18 +34,19 @@ var link = function(dbot) { }, '~ud': function(event) { - var query = event.params.join(" ").substring(4); + var query = event.input[1]; 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(query + ': ' + result.list[0].definition); + event.reply(query + ': ' + result.list[0].definition.split('\n')[0]; } else { event.reply(event.user + ': No definition found.'); } }); } }; + commands['~ud'].regex = [/~ud (.+)/, 2]; this.commands = commands; this.listener = function(event) { diff --git a/modules/poll/config.json b/modules/poll/config.json index 7b0f48b..12dc9ae 100644 --- a/modules/poll/config.json +++ b/modules/poll/config.json @@ -1,6 +1,6 @@ { "help": "http://github.com/reality/depressionbot/blob/master/modules/poll/README.md", "dbKeys": [ "polls" ], - "ignorable": true, + "ignorable true, "dependencies": [ "users", "command" ] }