{"id":306845,"date":"2020-07-13T15:00:16","date_gmt":"2020-07-13T15:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=306845"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=306845","title":{"rendered":"\u041f\u0438\u0448\u0435\u043c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u043d\u0430 node.js"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/510760\/\">\u0421 \u043f\u043e\u043b\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/github.com\/Jendyy\/tgBot\" rel=\"nofollow\">\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u043d\u0430 node js, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u0435\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0437\u0430\u0440\u0430\u0436\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u043e\u043c \u043f\u043e \u0432\u0441\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0430\u043c.<\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0442\u0430\u043a\u0442-\u043b\u0438\u0441\u0442 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <b>@botFather<\/b> \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u043c\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <b>\/newBot<\/b>. \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u0434\u0430\u0435\u043c \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u043d\u0435 \u0437\u0430\u043d\u044f\u0442\u043e, \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u043e\u0442\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0442\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ib\/ow\/sv\/ibowsvk-jpczvvwc6taaeschdx0.png\"><\/div>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0435, \u043d\u0430\u0448 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442 \u0433\u043e\u0442\u043e\u0432 \u0438 botfather \u043f\u043e\u0434\u0435\u043b\u0438\u043b\u0441\u044f \u0441 \u043d\u0430\u043c\u0438 <b>API Token<\/b>, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u043e\u0442\u043e\u043c<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u0432\u0435\u0434\u0435\u043c npm init \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0430\u0439\u043b bot.js \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448 \u0431\u043e\u0442. <br \/>  <a name=\"habracut\"><\/a><br \/>  \u0417\u0430\u0442\u0435\u043c \u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u044e <b>telegraf<\/b> \u2014 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442\u0430. \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u0444\u0430, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0431\u043e\u0442\u0430 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043c\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<pre><code class=\"javascript\">const { Telegraf } = require('telegraf') const bot = new Telegraf(process.env.BOT_TOKEN) \/\/\u0441\u044e\u0434\u0430 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u043b botFather bot.start((ctx) =&gt; ctx.reply('Welcome')) \/\/\u043e\u0442\u0432\u0435\u0442 \u0431\u043e\u0442\u0430 \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \/start bot.help((ctx) =&gt; ctx.reply('Send me a sticker')) \/\/\u043e\u0442\u0432\u0435\u0442 \u0431\u043e\u0442\u0430 \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \/help bot.on('sticker', (ctx) =&gt; ctx.reply('')) \/\/bot.on \u044d\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0438\u043a\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u043b\u0438 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f bot.hears('hi', (ctx) =&gt; ctx.reply('Hey there')) \/\/ bot.hears \u044d\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430, \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e - &quot;hi&quot; bot.launch() \/\/ \u0437\u0430\u043f\u0443\u0441\u043a \u0431\u043e\u0442\u0430<\/code><\/pre>\n<p>  \u041f\u043e\u043c\u0435\u0441\u0442\u0438\u043c <b>api token<\/b> \u0432 \u043d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438 \u0437\u0430\u043f\u0443c\u0442\u0438\u043c \u0431\u043e\u0442\u0430.<\/p>\n<pre><code class=\"javascript\">node bot<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sb\/rr\/ha\/sbrrha7n_ynma05kt2fujn7x6ze.png\"><\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0447\u0442\u043e \u043b\u0435\u0436\u0438\u0442 \u0432 <b>ctx <\/b><\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b bot \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <b>log<\/b>:<\/p>\n<pre><code class=\"javascript\">ctx.message.from.first_name<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u0432\u0435\u0434\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <b>\/start<\/b> \u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u044e\u0437\u0435\u0440\u0435:<\/p>\n<pre><code class=\"javascript\">{  &quot;update_id&quot;: 375631294,  &quot;message&quot;: {    &quot;message_id&quot;: 11,    &quot;from&quot;: {      &quot;id&quot;: 222222,      &quot;is_bot&quot;: false,      &quot;first_name&quot;: &quot;\u0416\u0435\u043d\u044f&quot;,      &quot;username&quot;: &quot;Evgenii&quot;,      &quot;language_code&quot;: &quot;ru&quot;    },    &quot;chat&quot;: {      &quot;id&quot;: 386342082,      &quot;first_name&quot;: &quot;\u0416\u0435\u043d\u044f&quot;,      &quot;username&quot;: &quot;Evgenii&quot;,      &quot;type&quot;: &quot;private&quot;    },    &quot;date&quot;: 1593015188,    &quot;text&quot;: &quot;\/start&quot;,    &quot;entities&quot;: [      {        &quot;offset&quot;: 0,        &quot;length&quot;: 6,        &quot;type&quot;: &quot;bot_command&quot;      }    ]  } }<\/code><\/pre>\n<p>  \u041d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 message, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0438\u043c\u044f \u044e\u0437\u0435\u0440\u0430<\/p>\n<pre><code class=\"javascript\">ctx.message.from.first_name<\/code><\/pre>\n<p>  \u0418 \u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b \u0431\u043e\u0442\u0443:<\/p>\n<pre><code class=\"javascript\">ctx.message.text<\/code><\/pre>\n<p>  \u041c\u044b \u0437\u043d\u0430\u0435\u043c \u0447\u0442\u043e \u043b\u0435\u0436\u0438\u0442 \u0432 <b>ctx<\/b> \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0433\u043e api, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u0443. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <b>covid19-api<\/b>. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0435\u0435 \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0437\u0430\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u043c \u0432 \u0444\u0430\u0439\u043b <b>bot.js<\/b>:<\/p>\n<pre><code class=\"javascript\">const covidApi = require('covid19-api')<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0443\u0434\u0430\u043b\u0438\u043c \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u0442\u0438\u043a\u0435\u0440\u043e\u0432 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434 <b>getReportsByCountries<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <b>covid19-api<\/b>:<\/p>\n<pre><code class=\"javascript\">bot.on('text', async ctx =&gt; {    const covidData = await covidApi.getReportsByCountries(ctx.message.text) \/\/\u0441\u044e\u0434\u0430 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u044e\u0437\u0435\u0440\u0430    ctx.reply(covidData) \/\/\u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 })<\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0435\u043c\u0443 \u0431\u043e\u0442\u0443 \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0435: \u2018russia\u2019:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/g1\/jd\/bh\/g1jdbhw6ywjov-t1xtyxnynvnfa.png\"><\/div>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0446\u0435\u043b\u044b\u0439 \u0440\u044f\u0434 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0432\u0435\u0434\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u044b \u0441 \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u043e\u0439 \u043d\u0430\u0448 \u0431\u043e\u0442 \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/us\/x1\/lp\/usx1lpumoampadbjg3sgiwxnbmc.png\"><\/div>\n<p>  \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u043e\u043f\u043e\u0432\u0435\u0449\u0430\u0442\u044c \u044e\u0437\u0435\u0440\u0430, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u044b \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0422\u0430\u043a \u0436\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043a\u043e\u0434\u0430 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0431\u043e\u043b\u0435\u0435 \u0434\u0440\u0443\u0436\u0435\u043b\u044e\u0431\u043d\u044b\u043c, \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0432\u044b\u0432\u043e\u0434 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 <b>\/start<\/b>, \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0430\u043d \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0435 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <b>\/help<\/b>.<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">const { Telegraf } = require('telegraf'); const covidApi = require('covid19-api'); const COUNTRIES_LIST = require('.\/const') const bot = new Telegraf('1170363720:AAFJ4ALJebB8Luh5kt1DStmYYqV3TparhKc') bot.start( ctx =&gt; ctx.reply(`    \u041f\u0440\u0438\u0432\u0435\u0442 ${ctx.from.first_name}!    \u0423\u0437\u043d\u0430\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u041a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u0443.    \u0412\u0432\u0435\u0434\u0438 \u0441\u0442\u0440\u0430\u043d\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443.    \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0440\u0430\u043d \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \/help.&quot; `)) bot.help( ctx =&gt; ctx.reply(COUNTRIES_LIST)) \/\/ \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0430\u043d \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 covid19-api bot.on('text', async (ctx) =&gt; {    try {        const userText = ctx.message.text        const covidData = await covidApi.getReportsByCountries(userText)        const countryData = covidData[0][0]        const formatData = `            \u0421\u0442\u0440\u0430\u043d\u0430: ${countryData.country},            \u0421\u043b\u0443\u0447\u0430\u0438: ${countryData.cases},            \u0421\u043c\u0435\u0440\u0442\u0438: ${countryData.deaths},            \u0412\u044b\u0437\u0434\u043e\u0440\u043e\u0432\u0435\u043b\u043e: ${countryData.recovered}`        ctx.reply(formatData)    } catch(e) {        ctx.reply('\u0422\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u044b \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u0430\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \/help')    } }) bot.launch()<\/code><\/pre>\n<p>  \u041a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/aj\/t_\/c7\/ajt_c7kaunckhizlx7z9hbnctj0.png\"><\/div>\n<p>  \u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e! \u041c\u044b \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0437\u0430\u0431\u043e\u043b\u0435\u0432\u0448\u0438\u0445 \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u043e\u043c.<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/510760\/\"> https:\/\/habr.com\/ru\/post\/510760\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/510760\/\">\u0421 \u043f\u043e\u043b\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/github.com\/Jendyy\/tgBot\" rel=\"nofollow\">\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u043d\u0430 node js, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u0435\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0437\u0430\u0440\u0430\u0436\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u043e\u043c \u043f\u043e \u0432\u0441\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0430\u043c.<\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0442\u0430\u043a\u0442-\u043b\u0438\u0441\u0442 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <b>@botFather<\/b> \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u043c\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <b>\/newBot<\/b>. \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u0434\u0430\u0435\u043c \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u043d\u0435 \u0437\u0430\u043d\u044f\u0442\u043e, \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u043e\u0442\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0442\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ib\/ow\/sv\/ibowsvk-jpczvvwc6taaeschdx0.png\"><\/div>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0435, \u043d\u0430\u0448 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442 \u0433\u043e\u0442\u043e\u0432 \u0438 botfather \u043f\u043e\u0434\u0435\u043b\u0438\u043b\u0441\u044f \u0441 \u043d\u0430\u043c\u0438 <b>API Token<\/b>, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u043e\u0442\u043e\u043c<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u0432\u0435\u0434\u0435\u043c npm init \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0430\u0439\u043b bot.js \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448 \u0431\u043e\u0442.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-306845","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/306845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=306845"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/306845\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=306845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=306845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=306845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}