{"id":333024,"date":"2022-05-12T09:00:05","date_gmt":"2022-05-12T09:00:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=333024"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=333024","title":{"rendered":"<span>Node.js: \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0431\u043e\u0442\u0430 \u0434\u043b\u044f Telegram<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/cc\/tl\/u0\/cctlu0pn6hxld1s63lnvgr7a1mq.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/cc\/tl\/u0\/cctlu0pn6hxld1s63lnvgr7a1mq.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0434\u043b\u044f <a href=\"https:\/\/web.telegram.org\/k\/\">Telegram<\/a>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0431\u043e\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>BotFather<\/em>, \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 <a href=\"https:\/\/expressjs.com\/ru\/\">Express<\/a>, \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 <a href=\"https:\/\/www.heroku.com\/\">Heroku<\/a> \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0431\u043e\u0442\u0430 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u0431-\u0445\u0443\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0431\u043e\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 <em>joke<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0441\u043a\u0430\u044f \u0448\u0443\u0442\u043a\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: &#171;Algorithm: a word used by programmers when they don&#8217;t want to explain how their code works.&#187; (\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u044d\u0442\u043e \u0441\u043b\u043e\u0432\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043d\u0435 \u0445\u043e\u0442\u044f\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0445 \u043a\u043e\u0434));<\/li>\n<li>\u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u0441\u043e\u0431\u043e\u0439 \u0434\u0430\u0442\u0443 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <em>\u0414\u0414.\u041c\u041c<\/em>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u043b, \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u044d\u0442\u0443 \u0434\u0430\u0442\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Google (\u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432), \u043b\u0438\u0431\u043e \u0444\u0440\u0430\u0437\u0430 &#171;You have nothing to do on this day.&#187;, \u0435\u0441\u043b\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0434\u0430\u0442\u0443 \u043d\u0435 \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0435\u043b;<\/li>\n<li>\u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043b\u044e\u0431\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0444\u0440\u0430\u0437\u0430 &#171;I have nothing to say.&#187;.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u0442\u0430 \u044f \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0430 <a href=\"https:\/\/core.telegram.org\/bots\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>.<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/harryheman\/Blog-Posts\/telegram-bot-server\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043a\u043e\u0434\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0431\u043e\u0442\u0430<\/a>.<\/li>\n<li>\u0411\u043e\u0442 \u2014 @aio350_reminder_bot.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"registraciya-i-kastomizaciya-bota\">\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u043e\u0442\u0430<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0431\u043e\u0442\u0430 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e Telegram (\u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e). \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0435\u043c <em>BotFather<\/em> (<a href=\"https:\/\/habr.com\/ru\/users\/botfather\/\" class=\"user_link\">BotFather<\/a>):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/o3\/ca\/yo\/o3cayo0nllqv4zon8advwgfluyi.png\" data-src=\"https:\/\/habrastorage.org\/webt\/o3\/ca\/yo\/o3cayo0nllqv4zon8advwgfluyi.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 <em>Start<\/em> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043c\u0430\u043d\u0434:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ui\/4n\/4v\/ui4n4v12uvfcov2njnx44ldt9hc.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ui\/4n\/4v\/ui4n4v12uvfcov2njnx44ldt9hc.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <em>\/newbot<\/em> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u043e\u0442\u0430, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u043c\u044f \u0438 <em>username<\/em> \u0431\u043e\u0442\u0430 (<em>username<\/em> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 <em>Telegram<\/em>), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: &#171;Neo&#187; \u0438 &#171;aio350_reminder_bot&#187;.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/su\/0s\/mo\/su0smomium-nrapuom1k-xhq7pe.png\" data-src=\"https:\/\/habrastorage.org\/webt\/su\/0s\/mo\/su0smomium-nrapuom1k-xhq7pe.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0430: 5372263544:&#8230;<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <em>\/mybots<\/em> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0448\u0438\u0445 \u0431\u043e\u0442\u043e\u0432, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c <em>Edit Bot<\/em>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/_y\/9z\/7i\/_y9z7igoskdkmjdbqmuotrlifz4.png\" data-src=\"https:\/\/habrastorage.org\/webt\/_y\/9z\/7i\/_y9z7igoskdkmjdbqmuotrlifz4.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0431\u043e\u0442\u0443 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 (<em>Edit Description<\/em>), \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0443 (<em>Edit About<\/em>) \u0438 \u0430\u0432\u0430\u0442\u0430\u0440 (<em>Edit Botpic<\/em>):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/yh\/qq\/wg\/yhqqwgnj5k_udyksktgspmgfhvk.png\" data-src=\"https:\/\/habrastorage.org\/webt\/yh\/qq\/wg\/yhqqwgnj5k_udyksktgspmgfhvk.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0410\u0432\u0430\u0442\u0430\u0440 (\u0441\u043f\u0430\u0441\u0438\u0431\u043e <a href=\"https:\/\/www.flaticon.com\/\">FlatIcon<\/a>):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/lc\/c3\/zn\/lcc3znengvta9ngykz9njbletmc.png\" data-src=\"https:\/\/habrastorage.org\/webt\/lc\/c3\/zn\/lcc3znengvta9ngykz9njbletmc.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0431\u043e\u0442\u0430 \u0432 Telegram \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0435\u0433\u043e. \u041f\u043e\u0437\u0434\u043e\u0440\u043e\u0432\u0430\u0435\u043c\u0441\u044f \u0441 \u043d\u0438\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ow\/ee\/66\/owee66mhhrebmfmn47scrs6xwsg.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ow\/ee\/66\/owee66mhhrebmfmn47scrs6xwsg.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/zf\/2r\/hv\/zf2rhveirjlqklnn695rwdi1rke.png\" data-src=\"https:\/\/habrastorage.org\/webt\/zf\/2r\/hv\/zf2rhveirjlqklnn695rwdi1rke.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0411\u043e\u0442 \u043c\u043e\u043b\u0447\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 &#171;\u043c\u043e\u0437\u0433\u043e\u0432&#187;) \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c.<\/p>\n<p>  <\/p>\n<h2 id=\"razrabotka-i-deploy-servera-dlya-bota\">\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438 \u0434\u0435\u043f\u043b\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0431\u043e\u0442\u0430<\/h2>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0435\u0435 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c <em>Node.js-\u043f\u0440\u043e\u0435\u043a\u0442<\/em>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mkdir telegram-bot-server cd telegram-bot-server  yarn init -yp # or npm init -y<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 yarn add axios dotenv express fs-extra google-spreadsheet  # \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 yarn add -D nodemon<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/axios\/axios\">axios<\/a>: \u043a\u043b\u0438\u0435\u043d\u0442-\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f <em>HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/em>;<\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/dotenv\">dotenv<\/a>: \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0441\u0440\u0435\u0434\u044b \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f;<\/li>\n<li><a href=\"https:\/\/expressjs.com\/ru\/\">express<\/a>: <em>Node.js-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a<\/em> \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432;<\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/fs-extra\">fs-extra<\/a>: \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 <em>Node.js-\u043c\u043e\u0434\u0443\u043b\u044c<\/em> <a href=\"https:\/\/nodejs.org\/api\/fs.html\">fs<\/a>;<\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/google-spreadsheet\">google-spreadsheet<\/a>: \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0433\u0443\u0433\u043b-\u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438;<\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/nodemon\">nodemon<\/a>: \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0438\u043f \u043a\u043e\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (\u043c\u043e\u0434\u0443\u043b\u044c) \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 (<em>start<\/em>) \u0438 \u0440\u0435\u0436\u0438\u043c\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 (<em>dev<\/em>) \u0432 \u0444\u0430\u0439\u043b\u0435 <em>package.json<\/em>:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">\"type\": \"module\", \"scripts\": {   \"start\": \"node index.js\",   \"dev\": \"nodemon index.js\" },<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <em>.env<\/em> \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0442\u0443\u0434\u0430 \u0442\u043e\u043a\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">TELEGRAM_API_TOKEN=5348751300:...<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0443\u0433\u043b-\u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0438 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 <a href=\"https:\/\/docs.google.com\/spreadsheets\/u\/0\/\">Google Spreadsheets<\/a> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/mf\/rr\/o2\/mfrro2wgxx7pvriidldozbmgrqy.png\" data-src=\"https:\/\/habrastorage.org\/webt\/mf\/rr\/o2\/mfrro2wgxx7pvriidldozbmgrqy.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u0437 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 (\u043d\u0430\u0431\u043e\u0440 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 <em>d\/<\/em> \u0438 <em>\/edit<\/em>) \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 <em>.env<\/em>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">GOOGLE_SPREADSHEET_ID=1HG60...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0434\u0435\u043c \u0432 <a href=\"https:\/\/console.cloud.google.com\/\">Google Cloud Platform<\/a>, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b <em>IAM &amp; Admin<\/em> -> <em>Service Accounts<\/em> \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441-\u0430\u043a\u043a\u0430\u0443\u043d\u0442 (<em>Create Service Account<\/em>), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <em>Telegram Bot Spreadsheet<\/em>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/bq\/na\/jp\/bqnajplo7qmrqbewmiw9f2lhcug.png\" data-src=\"https:\/\/habrastorage.org\/webt\/bq\/na\/jp\/bqnajplo7qmrqbewmiw9f2lhcug.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/gy\/pk\/o-\/gypko-ncrrsytolxg_uxry3srxs.png\" data-src=\"https:\/\/habrastorage.org\/webt\/gy\/pk\/o-\/gypko-ncrrsytolxg_uxry3srxs.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441-\u0430\u043a\u043a\u0430\u0443\u043d\u0442, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b <em>Keys<\/em> \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u044e\u0447 (<em>Add Key<\/em> -> <em>Create new key<\/em>) \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <em>JSON<\/em>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/5p\/u5\/bx\/5pu5bxiy_jq3dn-vg_odmeo95bs.png\" data-src=\"https:\/\/habrastorage.org\/webt\/5p\/u5\/bx\/5pu5bxiy_jq3dn-vg_odmeo95bs.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/_q\/ip\/vp\/_qipvp0ucvtfzeswzvxjlbhg5rc.png\" data-src=\"https:\/\/habrastorage.org\/webt\/_q\/ip\/vp\/_qipvp0ucvtfzeswzvxjlbhg5rc.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0412 \u0441\u043a\u0430\u0447\u0430\u043d\u043d\u043e\u043c <em>JSON-\u0444\u0430\u0439\u043b\u0435<\/em> \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u043f\u043e\u043b\u044f <em>client_email<\/em> \u0438 <em>private_key<\/em>. \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 \u0432 <em>.env<\/em>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">GOOGLE_SERVICE_ACCOUNT_EMAIL=telegram-bot-spreadsheet@telegram-bot-spreadsheet.iam.gserviceaccount.com GOOGLE_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b <em>APIs &amp; Services<\/em> -> <em>Enabled APIs &amp; services<\/em> \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u0441\u0435\u0440\u0432\u0438\u0441-\u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0443 (<em>Enable APIs and Services<\/em>):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/sh\/np\/fx\/shnpfx1zt2hofo9k4n3h6mxclws.png\" data-src=\"https:\/\/habrastorage.org\/webt\/sh\/np\/fx\/shnpfx1zt2hofo9k4n3h6mxclws.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/za\/pq\/u3\/zapqu3bjhcbhmmb7e4bgoxa-xxq.png\" data-src=\"https:\/\/habrastorage.org\/webt\/za\/pq\/u3\/zapqu3bjhcbhmmb7e4bgoxa-xxq.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0433\u0443\u0433\u043b-\u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044e (\u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0430\u043a\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/www.npmjs.com\/package\/@googleapis\/calendar\">@googleapis\/calendar<\/a>).<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <em>index.js<\/em> \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import axios from 'axios' import { config } from 'dotenv' import express from 'express' import { GoogleSpreadsheet } from 'google-spreadsheet'<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0441\u0440\u0435\u0434\u044b \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <em>Express<\/em> \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0443\u0442\u0438 \u043a \u0448\u0443\u0442\u043a\u0430\u043c \u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">config() const app = express()  const JOKE_API = 'https:\/\/v2.jokeapi.dev\/joke\/Programming?type=single' const TELEGRAM_URI = `https:\/\/api.telegram.org\/bot${process.env.TELEGRAM_API_TOKEN}\/sendMessage`<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u043e\u0432 (middleware) <em>Express<\/em> \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">app.use(express.json()) app.use(   express.urlencoded({     extended: true   }) )  const doc = new GoogleSpreadsheet(process.env.GOOGLE_SPREADSHEET_ID) await doc.useServiceAccountAuth({   client_email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL,   private_key: process.env.GOOGLE_PRIVATE_KEY.replace(\/\\\\n\/g, '\\n') })<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0440\u043e\u0443\u0442 \u0434\u043b\u044f <em>POST-\u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/em> \u043a <em>\/new-message<\/em>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">app.post('\/new-message', async (req, res) => {   \/\/ ... })<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438\u0437 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0447\u0430\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { message } = req.body  const messageText = message?.text?.toLowerCase()?.trim() const chatId = message?.chat?.id if (!messageText || !chatId) {   return res.sendStatus(400) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">await doc.loadInfo() const sheet = doc.sheetsByIndex[0] const rows = await sheet.getRows() const dataFromSpreadsheet = rows.reduce((obj, row) => {   if (row.date) {     const todo = { text: row.text, done: row.done }     obj[row.date] = obj[row.date] ? [...obj[row.date], todo] : [todo]   }   return obj }, {})<\/code><\/pre>\n<p>  <\/p>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u043e\u0442\u0432\u0435\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let responseText = 'I have nothing to say.' if (messageText === 'joke') {   try {     const response = await axios(JOKE_API)     responseText = response.data.joke   } catch (e) {     console.log(e)     res.send(e)   } } else if (\/\\d\\d\\.\\d\\d\/.test(messageText)) {   responseText =     dataFromSpreadsheet[messageText] || 'You have nothing to do on this day.' }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442\u0432\u0435\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">try {   await axios.post(TELEGRAM_URI, {     chat_id: chatId,     text: responseText   })   res.send('Done') } catch (e) {   console.log(e)   res.send(e) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u043e\u0440\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const PORT = process.env.PORT || 3000 app.listen(PORT, () => {   console.log(`Server running on port ${PORT}`) })<\/code><\/pre>\n<p>  <\/p>\n<p>\u0411\u043e\u0442 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0433\u0434\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 <em>Heroku<\/em>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u043c \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <em>my-telegram-bot-server<\/em> (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 <em>Heroku<\/em>):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/sk\/1i\/k_\/sk1ik_m312f0y3fi11pcuwn85cm.png\" data-src=\"https:\/\/habrastorage.org\/webt\/sk\/1i\/k_\/sk1ik_m312f0y3fi11pcuwn85cm.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/i7\/sm\/hj\/i7smhjf9qhxbsuib42czwcq_rfg.png\" data-src=\"https:\/\/habrastorage.org\/webt\/i7\/sm\/hj\/i7smhjf9qhxbsuib42czwcq_rfg.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c <em>Heroku CLI<\/em> \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0443\u0435\u043c\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">yarn global add heroku  heroku login # \u0434\u0430\u043b\u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u0445\u043e\u0434\u044f\u0441\u044c \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <em>Git-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/em>, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a <em>Heroku<\/em>, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u0445 \u0432 <em>Heroku<\/em> (\u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b <em>.gitignore<\/em> \u0441 <em>node_modules<\/em> \u0438 <em>.env<\/em>):<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">git init  # \u0443 \u0432\u0430\u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u043c heroku git:remote -a my-telegram-bot-server  git add . git commit -m \"create app\" git push heroku master<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0434\u0435\u043f\u043b\u043e\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <em>URL<\/em> \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <em><a href=\"https:\/\/my-telegram-bot-server.herokuapp.com\/\">https:\/\/my-telegram-bot-server.herokuapp.com\/<\/a><\/em> (\u043e\u043d \u043d\u0430\u043c \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f).<\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <em>Settings<\/em> \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u044b \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <em>Config Vars<\/em> (<em>Reveal Config Vars<\/em>):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/4b\/vs\/nj\/4bvsnjmsbhcvkflymi9kyzus1le.png\" data-src=\"https:\/\/habrastorage.org\/webt\/4b\/vs\/nj\/4bvsnjmsbhcvkflymi9kyzus1le.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043d\u0430 \u044d\u0442\u043e\u043c \u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0438 \u0434\u0435\u043f\u043b\u043e\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0431\u043e\u0442\u0430.<\/p>\n<p>  <\/p>\n<h2 id=\"podklyuchenie-bota-k-serveru\">\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u043e\u0442\u0430 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443<\/h2>\n<p>  <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u0442\u0430 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443, \u043d\u043e \u0441\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0435\u0431-\u0445\u0443\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 (\"url=...\") \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c `URL` \u043f\u0440\u043e\u0435\u043a\u0442\u0430 + `\/new-message` # \u043f\u043e\u0441\u043b\u0435 `bot` \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 `TELEGRAM_API_TOKEN` curl -F \"url=https:\/\/my-telegram-bot-server.herokuapp.com\/new-message\" https:\/\/api.telegram.org\/bot5372263544:...\/setWebhook<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/r0\/64\/ew\/r064ewdletkrax4g4zzlrnma4z0.png\" data-src=\"https:\/\/habrastorage.org\/webt\/r0\/64\/ew\/r064ewdletkrax4g4zzlrnma4z0.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0445\u0443\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u0431\u043e\u0442\u0443.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c <em>\/start<\/em>, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442 \u0431\u043e\u0442\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 &#171;I have nothing to say.&#187;. \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 &#171;joke&#187;, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0448\u0443\u0442\u043a\u0443. \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c &#171;11.05&#187;, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c &#171;12.05&#187;, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c &#171;You have nothing to do on this day.&#187;.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/a5\/oa\/lr\/a5oalrieet_8kcikjw9c5eceubw.png\" data-src=\"https:\/\/habrastorage.org\/webt\/a5\/oa\/lr\/a5oalrieet_8kcikjw9c5eceubw.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/em>: \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u0442\u0430 \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0447\u0430\u0442\u0430\u043b\u0441\u044f (\u0432\u043c\u0435\u0441\u0442\u043e &#171;to do&#187; \u043d\u0430\u043f\u0438\u0441\u0430\u043b &#171;to to&#187;), \u043d\u043e \u0443\u0436\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>It&#8217;s alive!)<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u044d\u0442\u043e \u0432\u0441\u0435, \u0447\u0435\u043c \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0447\u0442\u043e-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0438 \u043d\u0435 \u0437\u0440\u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  <\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 happy coding!<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p><a href=\"https:\/\/cloud.timeweb.com\/vds-promo-10-rub?utm_source=habr&amp;utm_medium=banner&amp;utm_campaign=vds-promo-10-rub\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/co\/e2\/kh\/coe2kha8u8_pypip-2k3wk3ppa0.png\" data-src=\"https:\/\/habrastorage.org\/webt\/co\/e2\/kh\/coe2kha8u8_pypip-2k3wk3ppa0.png\"\/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \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\/company\/timeweb\/blog\/665124\/\"> https:\/\/habr.com\/ru\/company\/timeweb\/blog\/665124\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/cc\/tl\/u0\/cctlu0pn6hxld1s63lnvgr7a1mq.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/cc\/tl\/u0\/cctlu0pn6hxld1s63lnvgr7a1mq.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0434\u043b\u044f <a href=\"https:\/\/web.telegram.org\/k\/\">Telegram<\/a>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0431\u043e\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>BotFather<\/em>, \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 <a href=\"https:\/\/expressjs.com\/ru\/\">Express<\/a>, \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 <a href=\"https:\/\/www.heroku.com\/\">Heroku<\/a> \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0431\u043e\u0442\u0430 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u0431-\u0445\u0443\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0431\u043e\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 <em>joke<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0441\u043a\u0430\u044f \u0448\u0443\u0442\u043a\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: &#171;Algorithm: a word used by programmers when they don&#8217;t want to explain how their code works.&#187; (\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u044d\u0442\u043e \u0441\u043b\u043e\u0432\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043d\u0435 \u0445\u043e\u0442\u044f\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0445 \u043a\u043e\u0434));<\/li>\n<li>\u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u0441\u043e\u0431\u043e\u0439 \u0434\u0430\u0442\u0443 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <em>\u0414\u0414.\u041c\u041c<\/em>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u043b, \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u044d\u0442\u0443 \u0434\u0430\u0442\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Google (\u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432), \u043b\u0438\u0431\u043e \u0444\u0440\u0430\u0437\u0430 &#171;You have nothing to do on this day.&#187;, \u0435\u0441\u043b\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0434\u0430\u0442\u0443 \u043d\u0435 \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0435\u043b;<\/li>\n<li>\u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043b\u044e\u0431\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0444\u0440\u0430\u0437\u0430 &#171;I have nothing to say.&#187;.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u0442\u0430 \u044f \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0430 <a href=\"https:\/\/core.telegram.org\/bots\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>.<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/harryheman\/Blog-Posts\/telegram-bot-server\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043a\u043e\u0434\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0431\u043e\u0442\u0430<\/a>.<\/li>\n<li>\u0411\u043e\u0442 \u2014 @aio350_reminder_bot.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\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-333024","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333024","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=333024"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333024\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}