I start to learn a little javascript and, as a very "smart" one, I started with the bot telegram)

A bot should link to the chat certain information from the directory. At the same time, he analyzes the number of text files in the directory and, in the case of replenishment, links the latter. The code looks like this:

const TelegramBot = require('node-telegram-bot-api'); const token = ******; const fs = require('fs'); const puth = "D:/lol/" ; bot = new TelegramBot(token, {polling: true}); dirsize = 0; while(true){ fileContent = fs.readdirSync( puth,) i = fileContent.length - 1; if (i > dirsize){ fileread = fs.readFileSync(puth+fileContent[i], "utf8",) bot.sendMessage("тут id чата, куда бот линкует" ,fileread); console.log(fileread); } dirsize = i; } 

Refuses to work with infinite while loop. If the cycle is removed, the bot starts working, but makes only one link, and then stops.

I understand that everything looks wretched and scary for the experienced, but still I ask for help).

  • what does console.log show? - Anatol

0