mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
~ud regex and only use first response line [#197]
This commit is contained in:
parent
77490bbda5
commit
68f78cad9c
@ -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) {
|
||||
|
@ -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" ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user