R
R
RedSs2018-04-26 19:13:29
Node.js
RedSs, 2018-04-26 19:13:29

How to pass the result of a function to a user in a Telegram bot?

There is an api function in node js that pulls the weather by coordinates

forecast.get([53.2608259,50.0579958], function (err, result) {
    if (err) {
       return console.dir(err);
   }
   console.log('Долгота: %s', result.latitude);
    console.log('Широта: %s', result.longitude);
   console.log('Временная зона: %s', result.timezone);
    console.log('Сейчас на улице: %s\nТемпература: %s°C\nВлажность воздуха: %s% ',
          result.currently.summary,
         Math.round(parseFloat(result.currently.temperature, 10)),
          result.currently.humidity * 100
   );
});

It is necessary to transfer the values ​​for output to the user in the telegram. The problem is how to push
all these results into an html variable to format the result and send it to the user.
forecast.get([53.2608259,50.0579958], function (err, result) {
                if (err) {
                    return console.dir(err);
                }

            const html= `<i>Погода на сегодня</i>`;
                      
            bot.sendMessage(helper.getChatId(msg), html,{
                parse_mode:'HTML'
            })
            );
    });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question