2013-06-11 19:24:42 +02:00
|
|
|
var Wordnik = require('wordnik');
|
|
|
|
|
|
|
|
var words = function(dbot) {
|
|
|
|
this.commands = {
|
|
|
|
'~define': function(event) {
|
|
|
|
var query = event.params[1];
|
2013-07-28 23:26:04 +02:00
|
|
|
this.wn.definitions(encodeURIComponent(query), function(err, defs) {
|
2013-06-11 19:24:42 +02:00
|
|
|
if(!err && defs[0]) {
|
|
|
|
event.reply(query + ': ' + defs[0].text);
|
|
|
|
} else {
|
|
|
|
event.reply('No definitions found for ' + query);
|
|
|
|
}
|
|
|
|
});
|
2013-07-08 13:02:27 +02:00
|
|
|
},
|
2013-12-27 17:24:16 +01:00
|
|
|
|
|
|
|
'~etymology': function(event) {
|
|
|
|
var query = event.params[1];
|
|
|
|
this.wn.etymologies(encodeURIComponent(query), function(err, defs) {
|
|
|
|
if(!err && defs[0]) {
|
2013-12-27 17:35:42 +01:00
|
|
|
event.reply(query + ' etymology: ' +
|
|
|
|
defs[0].replace(/<\/?[^>]+(>|$)/g, ""));
|
2013-12-27 17:24:16 +01:00
|
|
|
} else {
|
|
|
|
event.reply('No etymology found for ' + query);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2013-07-08 13:02:27 +02:00
|
|
|
|
|
|
|
'~jimble': function(event) {
|
|
|
|
event.reply(event.params[1].split('').sort(function() {
|
|
|
|
return (Math.round(Math.random()) - 0.5);
|
|
|
|
}).join(''));
|
|
|
|
}
|
2013-06-11 19:24:42 +02:00
|
|
|
};
|
2013-07-08 13:02:27 +02:00
|
|
|
this.commands['~jimble'].regex = [/^~jimble (.+)$/, 2];
|
2013-06-11 19:24:42 +02:00
|
|
|
|
|
|
|
this.onLoad = function() {
|
|
|
|
this.wn = new Wordnik({
|
|
|
|
'api_key': this.config.api_key
|
|
|
|
});
|
|
|
|
}.bind(this);
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return new words(dbot);
|
|
|
|
};
|