From ce6f9d28e3e39ab53f122431cb962b76d4de4c8a Mon Sep 17 00:00:00 2001 From: Cedric Hoelzl Date: Wed, 28 Aug 2019 09:59:09 +0900 Subject: [PATCH] Initiated code --- config.js | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ init.t | 0 2 files changed, 62 insertions(+) create mode 100644 config.js delete mode 100644 init.t diff --git a/config.js b/config.js new file mode 100644 index 0000000..55f0c99 --- /dev/null +++ b/config.js @@ -0,0 +1,62 @@ +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){ + return { + trigger : cmd, + requirements : (bot,event,message)=>{ + return new Promise((resolve, reject)=>{ + return resolve({error:false}); + }); + }, + action : (bot,event,message)=>{ + return event.reply(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[get_echo_obj(element.cmd,element.ans)] + } + for(var i in regex_list){ + var element = echo_list[i]; + echoobj.regex.push[get_echo_obj(element.cmd,element.ans)]; + } + + return echoobj; + +} \ No newline at end of file diff --git a/init.t b/init.t deleted file mode 100644 index e69de29..0000000