forked from GitHub/dbot
etymology
This commit is contained in:
parent
f7fbbc7bd0
commit
1a144c6459
@ -13,5 +13,8 @@
|
|||||||
},
|
},
|
||||||
"no_similar": {
|
"no_similar": {
|
||||||
"en": "No related words found for {word}"
|
"en": "No related words found for {word}"
|
||||||
|
},
|
||||||
|
"origin": {
|
||||||
|
"en": "{word} origin: {origin}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
var Wordnik = require('wordnik');
|
var Wordnik = require('wordnik'),
|
||||||
|
parseString = require('xml2js').parseString;
|
||||||
|
|
||||||
var words = function(dbot) {
|
var words = function(dbot) {
|
||||||
this.commands = {
|
this.commands = {
|
||||||
@ -78,13 +79,22 @@ var words = function(dbot) {
|
|||||||
|
|
||||||
'~etymology': function(event) {
|
'~etymology': function(event) {
|
||||||
var query = event.params[1];
|
var query = event.params[1];
|
||||||
this.wn.etymologies(encodeURIComponent(query), {
|
this.wn.word(query, {}, function(err, word) {
|
||||||
'format': 'json'
|
if(!err && word) {
|
||||||
}, function(err, defs) {
|
word.etymologies({},function(err, origin) {
|
||||||
if(!err && defs[0]) {
|
if(!err && origin[0]) {
|
||||||
event.reply(query + ' etymology: ' + defs[0]);
|
parseString(origin[0], function(err, string) {
|
||||||
|
event.reply(dbot.t('origin', {
|
||||||
|
'word': query,
|
||||||
|
'origin': string.ety._
|
||||||
|
}));
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
event.reply('No etymology found for ' + query);
|
event.reply(dbot.t('no_def', { 'word': query }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('no_word', { 'word': query }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user