3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 03:33:07 +01:00

initial draft of word definition thing [#503]

This commit is contained in:
reality 2013-06-11 17:24:42 +00:00
parent dc6489767f
commit f6aebb61b4
3 changed files with 30 additions and 1 deletions

View File

@ -14,7 +14,7 @@ then
exit 1
fi
npm install ent underscore request sandbox express moment jade@0.25
npm install wordnik ent underscore request sandbox express moment jade@0.25
cd public/
wget http://twitter.github.com/bootstrap/assets/bootstrap.zip

View File

@ -0,0 +1,3 @@
{
"api_key": "http://developer.wordnik.com/"
}

26
modules/words/words.js Normal file
View File

@ -0,0 +1,26 @@
var Wordnik = require('wordnik');
var words = function(dbot) {
this.commands = {
'~define': function(event) {
var query = event.params[1];
this.wn.definitions(query, function(err, defs) {
if(!err && defs[0]) {
event.reply(query + ': ' + defs[0].text);
} else {
event.reply('No definitions found for ' + query);
}
});
}
};
this.onLoad = function() {
this.wn = new Wordnik({
'api_key': this.config.api_key
});
}.bind(this);
};
exports.fetch = function(dbot) {
return new words(dbot);
};