From d579d0a2caccaded476ad3c6318bce2096f1cec3 Mon Sep 17 00:00:00 2001 From: Christopher Rose Date: Thu, 18 Jul 2019 18:23:44 +0530 Subject: [PATCH] Test output and getUpdates --- index.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/index.js b/index.js index 6f0da79..4eba381 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,22 @@ +// TOREAD: https://core.telegram.org/bots/api const request = require('request') +const fs = require('fs') +const path = require('path') + + +const token = JSON.parse( fs.readFileSync('api-token.json')).token +const base = `https://api.telegram.org/bot${token}/` +console.log(`Token: ${token}`) +request(`${base}getUpdates`,(err,res,body)=>{ + if(err){ + throw err; + } + // If response malformed then move into next + let contents = JSON.parse(res.body||{'ok':false}) + if(!contents.ok){ + throw new Error("Not Ok") + } + console.log(`${JSON.stringify(contents.result)}`) +}) \ No newline at end of file