From 8d9b5a3986de778c8d8ecc08dd01b69b9902feb9 Mon Sep 17 00:00:00 2001 From: Christopher Rose Date: Mon, 5 Aug 2019 18:20:32 +0530 Subject: [PATCH] Build basic Process code --- index.js | 6 +++--- scripts/process.js | 3 +++ scripts/respond.js | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 scripts/process.js diff --git a/index.js b/index.js index 3dd6143..9e479cf 100644 --- a/index.js +++ b/index.js @@ -36,17 +36,17 @@ setInterval(()=>{ } // contents - Now work on response if(contents.result.length>0){ - console.log(`Update:${JSON.stringify(contents.result)}`) + //console.log(`Update:${JSON.stringify(contents.result)}`) // Ready to work on if(parameters.offset===null){ - parameters.offset = contents[0].update_id + 1 + parameters.offset = contents.result[0].update_id + 1 } contents.result.forEach(e=>{ if(e.update_id + 1 > parameters.offset) { parameters.offset = e.update_id + 1 } - console.log(e.update_id) + //console.log(e.update_id) respond.call(e) }) diff --git a/scripts/process.js b/scripts/process.js new file mode 100644 index 0000000..f386053 --- /dev/null +++ b/scripts/process.js @@ -0,0 +1,3 @@ +module.exports.process = (updateObject)=>{ + return updateObject.message.text +} \ No newline at end of file diff --git a/scripts/respond.js b/scripts/respond.js index 99614d8..b6f26ea 100644 --- a/scripts/respond.js +++ b/scripts/respond.js @@ -1,3 +1,6 @@ module.exports.call = (updateObject)=>{ - + if('message' in updateObject){ + console.log(updateObject.message.text) + //console.log("New Message") + } } \ No newline at end of file