telebot-basicecho/config.js
2019-08-28 10:27:44 +09:00

64 lines
1.3 KiB
JavaScript

const fs = require('fs');
const Markup = require('telegraf/markup');
const Extra = require('telegraf/extra');
//const db_js = require('./db.js');
//var db = new db_js("dbname");
//=== TOOL FUNCTIONS
function get_echo_obj(cmd,ans){
this.ans = ans;
this.cmd = cmd;
return {
trigger : this.cmd,
requirements : (bot,event,message)=>{
return new Promise((resolve, reject)=>{
return resolve({error:false});
});
},
action : (bot,event,message)=>{
return event.reply(this.ans);
}
};
}
//=== MAIN MODULE CONFIG
module.exports = function(echo_list,regex_list){
let echoobj = {
name : "BasicEcho",
version : 0.1,
requirements : {
gps: false,
},
text : [],
reply : [],
regex : [],
media : [],
callback : [],
inline : [],
new_member : (bot,event)=>{
//return event.replyWithMarkdown("Welcome !");
},
weburl : [],
cron : [],
cron_register : function(cron_f,bot,c){
new cron_f(c.cstr, new c.action(bot), c.params[0], c.params[1], c.timezone);
},
};
for(var i in echo_list){
var element = echo_list[i];
echoobj.text.push(new get_echo_obj(element.cmd,element.ans));
}
for(var i in regex_list){
var element = regex_list[i];
echoobj.regex.push(new get_echo_obj(element.cmd,element.ans));
}
return echoobj;
}