From c44e376d9c3a0321b78a833fa29a99289b252ee5 Mon Sep 17 00:00:00 2001 From: Cedric Hoelzl Date: Tue, 15 Oct 2019 21:54:46 +0200 Subject: [PATCH] init wiki --- config.js | 3 ++- wiktionary.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/config.js b/config.js index e6a49f1..02f0306 100644 --- a/config.js +++ b/config.js @@ -33,7 +33,8 @@ module.exports = function(){ let txt = `*Definitions of ${res.word}:*\n\n`; for(let r of res.definitions){ - txt+= `*${r.speech}:*\n`; + let t = r.speech!=''?r.speech:"Other" + txt+= `*${t}:*\n`; for(let l of r.lines){ txt+= ` - _${l.define}_\n\n`; } diff --git a/wiktionary.js b/wiktionary.js index 3c74ed0..c40610f 100644 --- a/wiktionary.js +++ b/wiktionary.js @@ -145,3 +145,20 @@ var wiki = function () { module.exports = wiki; +return wiki('gay').then(res=>{ + let txt = `*Definitions of ${res.word}:*\n\n`; + + for(let r of res.definitions){ + console.log(r) + let t = r.speech!=''?r.speech:"Other" + txt+= `*${r.speech}:*\n`; + for(let l of r.lines){ + txt+= ` - _${l.define}_\n\n`; + } + txt += `\n`; + } + console.log(txt); + }).catch(err=>{ + }) + +