2019-10-15 20:46:01 +02:00
|
|
|
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)=>{
|
|
|
|
|
2019-10-15 20:50:24 +02:00
|
|
|
return dic(message.text_arg).then(res=>{
|
2019-10-15 21:47:06 +02:00
|
|
|
console.log(res)
|
2019-10-15 20:46:01 +02:00
|
|
|
let txt = `*Definitions of ${message.text_arg}:\n`;
|
|
|
|
|
|
|
|
for(let r of res.definitions){
|
|
|
|
for(let l of r.lines){
|
|
|
|
txt+= `_${l.define}_\n`;
|
|
|
|
}
|
|
|
|
txt += `\n`;
|
|
|
|
}
|
|
|
|
return event.replyWithMarkdown(txt);
|
|
|
|
}).catch(err=>{
|
2019-10-15 20:52:31 +02:00
|
|
|
bot.error(err);
|
2019-10-15 20:46:01 +02:00
|
|
|
return event.reply("No word in dictionary");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
],
|
|
|
|
reply : [],
|
|
|
|
regex : [],
|
|
|
|
media : [],
|
|
|
|
callback : [],
|
|
|
|
inline : [],
|
|
|
|
new_member : (bot,event)=>{},
|
|
|
|
weburl : [],
|
|
|
|
cron : []
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|