3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00

~ud was surprisingly easy [#192]

This commit is contained in:
reality 2013-01-22 19:52:26 +00:00
parent f7acd2e01b
commit fba8edef18

View File

@ -31,6 +31,18 @@ var link = function(dbot) {
} }
} }
this.fetchTitle(event, link); this.fetchTitle(event, link);
},
'~ud': function(event) {
var reqUrl = 'http://api.urbandictionary.com/v0/define?term=' + event.params[1];
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);
} else {
event.reply(event.user + ': No definition found.');
}
});
} }
}; };
this.commands = commands; this.commands = commands;