diff --git a/install.sh b/install.sh index 70cf91c..9c1ae68 100755 --- a/install.sh +++ b/install.sh @@ -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 diff --git a/modules/words/config.json b/modules/words/config.json new file mode 100644 index 0000000..649e069 --- /dev/null +++ b/modules/words/config.json @@ -0,0 +1,3 @@ +{ + "api_key": "http://developer.wordnik.com/" +} diff --git a/modules/words/words.js b/modules/words/words.js new file mode 100644 index 0000000..eac90b0 --- /dev/null +++ b/modules/words/words.js @@ -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); +};