2
0
telebot-wiktionary/config.js

64 lines
1.3 KiB
JavaScript
Raw Normal View History

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:49:50 +02:00
let txt = `*Definitions of ${res.word}:*\n\n`;
2019-10-15 21:58:26 +02:00
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`;
2019-10-15 20:46:01 +02:00
}
}
return event.replyWithMarkdown(txt);
}).catch(err=>{
2019-10-15 21:59:50 +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 : []
}
}