forked from GitHub/dbot
~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) {
|
'~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);
|
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(query + ': ' + result.list[0].definition);
|
event.reply(query + ': ' + result.list[0].definition.split('\n')[0];
|
||||||
} else {
|
} else {
|
||||||
event.reply(event.user + ': No definition found.');
|
event.reply(event.user + ': No definition found.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
commands['~ud'].regex = [/~ud (.+)/, 2];
|
||||||
this.commands = commands;
|
this.commands = commands;
|
||||||
|
|
||||||
this.listener = function(event) {
|
this.listener = function(event) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"help": "http://github.com/reality/depressionbot/blob/master/modules/poll/README.md",
|
"help": "http://github.com/reality/depressionbot/blob/master/modules/poll/README.md",
|
||||||
"dbKeys": [ "polls" ],
|
"dbKeys": [ "polls" ],
|
||||||
"ignorable": true,
|
"ignorable true,
|
||||||
"dependencies": [ "users", "command" ]
|
"dependencies": [ "users", "command" ]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user