This commit is contained in:
Cedric Hoelzl 2019-08-28 10:24:08 +09:00
parent ce6f9d28e3
commit 080e625066

View File

@ -10,15 +10,17 @@ const Extra = require('telegraf/extra');
//=== TOOL FUNCTIONS //=== TOOL FUNCTIONS
function get_echo_obj(cmd,ans){ function get_echo_obj(cmd,ans){
this.ans = ans;
this.cmd = cmd;
return { return {
trigger : cmd, trigger : this.cmd,
requirements : (bot,event,message)=>{ requirements : (bot,event,message)=>{
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
return resolve({error:false}); return resolve({error:false});
}); });
}, },
action : (bot,event,message)=>{ action : (bot,event,message)=>{
return event.reply(ans); return event.reply(this.ans);
} }
}; };
} }
@ -50,11 +52,11 @@ module.exports = function(echo_list,regex_list){
for(var i in echo_list){ for(var i in echo_list){
var element = echo_list[i]; var element = echo_list[i];
echoobj.text.push[get_echo_obj(element.cmd,element.ans)] echoobj.text.push[new get_echo_obj(element.cmd,element.ans)]
} }
for(var i in regex_list){ for(var i in regex_list){
var element = echo_list[i]; var element = regex_list[i];
echoobj.regex.push[get_echo_obj(element.cmd,element.ans)]; echoobj.regex.push[new get_echo_obj(element.cmd,element.ans)];
} }
return echoobj; return echoobj;