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:
parent
dc6489767f
commit
f6aebb61b4
@ -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
|
||||
|
3
modules/words/config.json
Normal file
3
modules/words/config.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"api_key": "http://developer.wordnik.com/"
|
||||
}
|
26
modules/words/words.js
Normal file
26
modules/words/words.js
Normal 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);
|
||||
};
|
Loading…
Reference in New Issue
Block a user