const fs = require('fs'); const Markup = require('telegraf/markup'); const Extra = require('telegraf/extra'); const dic = require('./wiktionary.js'); //=== MAIN MODULE CONFIG module.exports = function(){ return { name : "Wiktionary", key : "wikt", version : 0.1, requirements : { gps: false, }, text : [ { trigger : ["/define"], public : true, desc : {0:"Search meaning", 1:"Search signification", }, requirements : (bot,event,message)=>{ return new Promise((resolve, reject)=>{ return resolve(200); }); }, action : (bot,event,message)=>{ if(message.text_arg && message.text_arg.length >0){ return dic(message.text_arg).then(res=>{ let txt = `*Definitions of ${res.word}:*\n\n`; if(res.definitions.length ==0){ txt+= "_No definition found_"; }else{ for(let r of res.definitions){ let t = r.speech!=''?r.speech:"Other" txt+= `*${t}:*\n`; for(let l of r.lines){ txt+= `${l.define}\n\n`; } txt += `\n`; } } return event.replyWithMarkdown(txt); }).catch(err=>{ //bot.error(err); return event.reply("No word in dictionary"); }) }else{ return event.reply("No word given"); } } }, ], reply : [], regex : [], media : [], callback : [], inline : [], new_member : (bot,event)=>{}, weburl : [], cron : [] } }