{"id":321321,"date":"2021-04-12T21:00:25","date_gmt":"2021-04-12T21:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=321321"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=321321","title":{"rendered":"\u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c-\u0431\u043e\u0442 \u043d\u0430 Python"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043f\u043e\u043f\u0430\u043b \u043d\u0430 \u0441\u0442\u0430\u0436\u0438\u0440\u043e\u0432\u043a\u0443 \u0432 \u043d\u043e\u0432\u0443\u044e \u0434\u043b\u044f \u0441\u0435\u0431\u044f IT-\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e \u0438 \u043d\u0430\u0448 (\u043c\u043e\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b) \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u044b\u043b &#8212; \u0431\u043e\u0442 \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b hr-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432. \u041f\u0435\u0440\u0432\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u043d\u0430\u043c \u0434\u0430\u043b\u0438 \u043d\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u043c (\u0430 \u044f \u0443\u0431\u0435\u0436\u0434\u0435\u043d, \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0447\u0442\u043e-\u0442\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c &#8212; \u044d\u0442\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430), \u0442\u0430\u043a \u0447\u0442\u043e \u044f \u043d\u0430\u0447\u0430\u043b \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c. \u042f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d python (\u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u043e\u0431\u043b\u043e\u0436\u043a\u0438 \u043f\u043e\u0447\u0435\u043c\u0443), \u0442\u0430\u043a \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u043d\u0438\u043c.<\/p>\n<h2>BotFather<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c-\u0431\u043e\u0442\u0430, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e <em>@BotFather <\/em>\u043a\u043e\u043c\u0430\u043d\u0434\u0443 <em>\/newbot<\/em>. \u041e\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438 <em>@username<\/em> \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0422\u0443\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e &#8212; \u043e\u043d \u0432\u0441\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 (\u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b <em>@username<\/em> \u0431\u044b\u043b \u043d\u0435 \u0437\u0430\u043d\u044f\u0442 \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u043b\u0441\u044f \u043d\u0430 &#171;bot&#187;). BotFather \u043f\u0440\u0438\u0448\u043b\u0435\u0442 HTTP API \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u043e\u0442\u043e\u043c.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/285\/3a1\/62f\/2853a162f49019b79f2cda6fa14d1081.png\" alt=\"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u043e\u0442\u0430\" title=\"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u043e\u0442\u0430\" width=\"377\" height=\"521\"><figcaption>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u043e\u0442\u0430<\/figcaption><\/figure>\n<h2>Telebot \u0438 \u0441\u0438\u043b\u0430 python<\/h2>\n<p>\u041c\u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u0442\u0430 &#8212; \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0434\u0430\u0432\u043d\u043e \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u0442\u043e \u043b\u0438 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430\u0439\u043c\u0435\u0442 \u043d\u0435 \u043e\u0434\u0438\u043d \u0432\u0435\u0447\u0435\u0440), \u0442\u043e \u043b\u0438 \u043d\u0435 \u043c\u043e\u0433 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e (\u043a\u0430\u043a-\u0442\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u0434\u043b\u044f c#), \u043d\u0443 \u0430 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0435\u043d\u044c. \u041d\u043e \u0442\u0443\u0442 \u043c\u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u044d\u0442\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u0442\u0430\u043a \u0447\u0442\u043e \u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0441\u043c\u0435\u043b \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0421\u0438\u043b\u0430 python \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0435\u0433\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438. \u0410, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0432 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434 \u0432\u0441\u0435 \u043d\u0443\u0436\u0434\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u043e \u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f) \u0432 6 (\u0428\u0415\u0421\u0422\u042c!) \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430. \u0410 \u0438\u043c\u0435\u043d\u043d\u043e:<\/p>\n<pre><code class=\"python\">import telebot bot = telebot.TeleBot('1111105161:AAHIjyAKY4fj62whM5vEAfotuixC5syA-j8') @bot.message_handler(commands=['start']) def start_command(message):     bot.send_message(message.chat.id, \"Hello!\") bot.polling()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8c7\/053\/fd7\/8c7053fd70a0788f609cb23912c3cfab.png\" alt=\"\u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\" title=\"\u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\" width=\"448\" height=\"222\"><figcaption>\u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435<\/figcaption><\/figure>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <em>\/start<\/em>, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e. \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 telebot (\u0434\u043b\u044f \u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442 pyTelegramBotAPI \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>pip install pyTelegramBotAPI<\/code> (\u041d\u0415 <code>pip install telebot<\/code>!), \u0434\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u043e\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043f\u0440\u0438\u0441\u043b\u0430\u043b BotFather. \u0422\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <em>\u201c\/start\u201d<\/em>), \u0438, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430, \u0442\u043e \u0431\u043e\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u201cHello!\u201d. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0441\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0438 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445 \u044f \u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0443. \u0421\u0435\u0439\u0447\u0430\u0441 \u0436\u0435 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0430\u0436\u0443 \u043e \u0435\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 &#8212; \u043e\u043d\u0430 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u043e\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c &#171;\u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c&#187; \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/p>\n<h2>Flask &amp; Requests<\/h2>\n<p>Telebot, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u0440\u0443\u0442\u043e, \u043d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u201c\u041d\u041e\u201d. \u041f\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0443 hr-\u043e\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 (\u0441\u0430\u0439\u0442), \u0433\u0434\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\/\u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\/\u043e\u0442 \u043d\u0438\u0445. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0430\u043c\u0438\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 python &#8212; \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a flask. \u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u043d\u0430 5000-\u043e\u043c \u043f\u043e\u0440\u0442\u0443 (<a href=\"http:\/\/localhost:5000\/\" rel=\"noopener noreferrer nofollow\"><u>http:\/\/localhost:5000\/<\/u><\/a>):<\/p>\n<pre><code class=\"python\">from flask import Flask   app = Flask(__name__)   @app.route(\"\/\", methods=[\"GET\"]) def index():     return \"Hello, World!\"     if __name__ == \"__main__\":     app.run()<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043e\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u042f \u043d\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e (<a href=\"https:\/\/habr.com\/ru\/post\/495036\/\" rel=\"noopener noreferrer nofollow\"><u>habr<\/u><\/a>), \u0430 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0438 \u043f\u043e\u0439\u0434\u0443 \u0441 \u043a\u043e\u043d\u0446\u0430. \u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u043e\u0442\u0430 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u201cHello!\u201d \u043d\u0430 \u043b\u044e\u0431\u043e\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\">from flask import Flask, request import requests  app = Flask(__name__)   def send_message(chat_id, text):     method = \"sendMessage\"     token = \"1111105161:AAHIjyAKY4fj62whM5vEAfotuixC5syA-j8\"     url = f\"https:\/\/api.telegram.org\/bot{token}\/{method}\"     data = {\"chat_id\": chat_id, \"text\": text}     requests.post(url, data=data)   @app.route(\"\/\", methods=[\"POST\"]) def receive_update():     chat_id = request.json[\"message\"][\"chat\"][\"id\"]     send_message(chat_id, \"Hello!\")     return \"ok\"   if __name__ == \"__main__\":     app.run()<\/code><\/pre>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0422\u043e\u0447\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442, \u043d\u043e \u043d\u0435 \u0441\u0440\u0430\u0437\u0443. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043a\u0443\u0434\u0430 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u0445. \u0414\u043b\u044f \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0443 telegram API \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/core.telegram.org\/bots\/api#setwebhook\" rel=\"noopener noreferrer nofollow\">setWebhook<\/a>. \u0421\u0443\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0443 url, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f\u0445 \u043a \u0431\u043e\u0442\u0443 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <a href=\"http:\/\/localhost:5000\/\" rel=\"noopener noreferrer nofollow\"><u>http:\/\/localhost:5000\/<\/u><\/a>). \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0443: &#171;\u041f\u043e\u0441\u044b\u043b\u0430\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 localhost&#187;, \u0432\u0435\u0434\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 localhost \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u043c. \u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 setWebhook \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e https url-\u044b. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 ngrok, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u0438\u0442 \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u0434\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u043e\u0441\u0442\u0430. \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"https:\/\/dashboard.ngrok.com\/get-started\/setup\" rel=\"noopener noreferrer nofollow\"><u>ngrok<\/u><\/a>, \u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0443\u043d\u043d\u0435\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u201cngrok http 5000\u201d. \u0414\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d60\/412\/461\/d60412461b98c55d716fd44874b6efe1.png\" alt=\"ngrok\" title=\"ngrok\" width=\"1194\" height=\"482\"><figcaption>ngrok<\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 setWebhook, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0435\u0440\u0435\u0437 postman. \u041d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c post \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 https:\/\/api.telegram.org\/bot&lt;\u0422\u041e\u041a\u0415\u041d&gt;\/setWebhook \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0432 \u0442\u0435\u043b\u0435 \u043d\u0443\u0436\u043d\u043e\u0433\u043e url. \u0414\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cbb\/7e7\/55d\/cbb7e755dea7ad140e8bbbbe84aeda39.png\" alt=\"setWebhook\" title=\"setWebhook\" width=\"1436\" height=\"780\"><figcaption>setWebhook<\/figcaption><\/figure>\n<h2>\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 telebot, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u043d\u0430 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c. \u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 flask\u2019e, \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u044d\u0442\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c. \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c? \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 send_message \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a: <\/p>\n<pre><code class=\"python\">from flask import Flask, request import telebot  app = Flask(__name__)   bot = telebot.TeleBot('1111105161:AAHIjyAKY4fj62whM5vEAfotuixC5syA-j8')   @app.route(\"\/\", methods=[\"POST\"]) def receive_update():     chat_id = request.json[\"message\"][\"chat\"][\"id\"]     bot.send_message(chat_id, \"Hello!\")     return \"ok\"   if __name__ == \"__main__\":     app.run()<\/code><\/pre>\n<p>\u041d\u043e, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 \u0447\u0430\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e @bot.message_handler &#8212; \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u044e\u0442 \u0442\u0438\u043f \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f (\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442, \u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0438 \u0442. \u0434.). \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430\u0448\u0435 flask \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0442\u043e \u043c\u044b \u0442\u0435\u0440\u044f\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 telebot. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c bot.polling(), \u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u201c\u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b\u201d. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043a\u0430\u043a-\u0442\u043e \u0432\u0441\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u043d\u0430\u0448\u0435\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0441\u0442\u044b\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043e\u0434\u043d\u0430\u043a\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0439:<\/p>\n<pre><code class=\"python\">from flask import Flask, request import telebot  bot = telebot.TeleBot('1111105161:AAHIjyAKY4fj62whM5vEAfotuixC5syA-j8') bot.set_webhook(url=\"https:\/\/8c6f687b75c9.ngrok.io\") app = Flask(__name__)   @app.route('\/', methods=[\"POST\"]) def webhook():     bot.process_new_updates(         [telebot.types.Update.de_json(request.stream.read().decode(\"utf-8\"))]     )     return \"ok\"   @bot.message_handler(commands=['start']) def start_command(message):     bot.send_message(message.chat.id, 'Hello!')   if __name__ == \"__main__\":     app.run()<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c set_webhook, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0440\u0430\u043d\u0435\u0435 \u0447\u0435\u0440\u0435\u0437 postman, \u0430 \u043d\u0430 \u043f\u0443\u0441\u0442\u043e\u043c \u0440\u043e\u0443\u0442\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c &#171;\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0433\u0438\u0438&#187;, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u043e\u0442\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043b\u0443\u0447\u0448\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c-\u0431\u043e\u0442\u0430 \u043d\u0430 python \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0441\u043b\u043e\u0436\u043d\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u0442\u044c \u0438 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u043e, \u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c-\u0431\u043e\u0442\u043e\u043c. \u0414\u0430\u043b\u044c\u0448\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0440\u0430\u0449\u0438\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u043e \u0412\u0430\u0448\u0435\u043c\u0443 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e.<\/p>\n<\/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\/552052\/\"> https:\/\/habr.com\/ru\/post\/552052\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043f\u043e\u043f\u0430\u043b \u043d\u0430 \u0441\u0442\u0430\u0436\u0438\u0440\u043e\u0432\u043a\u0443 \u0432 \u043d\u043e\u0432\u0443\u044e \u0434\u043b\u044f \u0441\u0435\u0431\u044f IT-\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e \u0438 \u043d\u0430\u0448 (\u043c\u043e\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b) \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u044b\u043b &#8212; \u0431\u043e\u0442 \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b hr-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432. \u041f\u0435\u0440\u0432\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u043d\u0430\u043c \u0434\u0430\u043b\u0438 \u043d\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u043c (\u0430 \u044f \u0443\u0431\u0435\u0436\u0434\u0435\u043d, \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0447\u0442\u043e-\u0442\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c &#8212; \u044d\u0442\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430), \u0442\u0430\u043a \u0447\u0442\u043e \u044f \u043d\u0430\u0447\u0430\u043b \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c. \u042f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d python (\u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u043e\u0431\u043b\u043e\u0436\u043a\u0438 \u043f\u043e\u0447\u0435\u043c\u0443), \u0442\u0430\u043a \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u043d\u0438\u043c.<\/p>\n<h2>BotFather<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c-\u0431\u043e\u0442\u0430, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e <em>@BotFather <\/em>\u043a\u043e\u043c\u0430\u043d\u0434\u0443 <em>\/newbot<\/em>. \u041e\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438 <em>@username<\/em> \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0422\u0443\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e &#8212; \u043e\u043d \u0432\u0441\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 (\u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b <em>@username<\/em> \u0431\u044b\u043b \u043d\u0435 \u0437\u0430\u043d\u044f\u0442 \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u043b\u0441\u044f \u043d\u0430 &#171;bot&#187;). BotFather \u043f\u0440\u0438\u0448\u043b\u0435\u0442 HTTP API \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u043e\u0442\u043e\u043c.<\/p>\n<figure class=\"\"><figcaption>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u043e\u0442\u0430<\/figcaption><\/figure>\n<h2>Telebot \u0438 \u0441\u0438\u043b\u0430 python<\/h2>\n<p>\u041c\u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u0442\u0430 &#8212; \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0434\u0430\u0432\u043d\u043e \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u0442\u043e \u043b\u0438 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430\u0439\u043c\u0435\u0442 \u043d\u0435 \u043e\u0434\u0438\u043d \u0432\u0435\u0447\u0435\u0440), \u0442\u043e \u043b\u0438 \u043d\u0435 \u043c\u043e\u0433 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e (\u043a\u0430\u043a-\u0442\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u0434\u043b\u044f c#), \u043d\u0443 \u0430 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0435\u043d\u044c. \u041d\u043e \u0442\u0443\u0442 \u043c\u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u044d\u0442\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u0442\u0430\u043a \u0447\u0442\u043e \u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0441\u043c\u0435\u043b \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0421\u0438\u043b\u0430 python \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0435\u0433\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438. \u0410, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0432 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434 \u0432\u0441\u0435 \u043d\u0443\u0436\u0434\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u043e \u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f) \u0432 6 (\u0428\u0415\u0421\u0422\u042c!) \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430. \u0410 \u0438\u043c\u0435\u043d\u043d\u043e:<\/p>\n<pre><code class=\"python\">import telebot bot = telebot.TeleBot('1111105161:AAHIjyAKY4fj62whM5vEAfotuixC5syA-j8') @bot.message_handler(commands=['start']) def start_command(message):     bot.send_message(message.chat.id, \"Hello!\") bot.polling()<\/code><\/pre>\n<figure class=\"\"><figcaption>\u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435<\/figcaption><\/figure>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <em>\/start<\/em>, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e. \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 telebot (\u0434\u043b\u044f \u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442 pyTelegramBotAPI \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>pip install pyTelegramBotAPI<\/code> (\u041d\u0415 <code>pip install telebot<\/code>!), \u0434\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u043e\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043f\u0440\u0438\u0441\u043b\u0430\u043b BotFather. \u0422\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <em>\u201c\/start\u201d<\/em>), \u0438, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430, \u0442\u043e \u0431\u043e\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u201cHello!\u201d. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0441\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0438 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445 \u044f \u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0443. \u0421\u0435\u0439\u0447\u0430\u0441 \u0436\u0435 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0430\u0436\u0443 \u043e \u0435\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 &#8212; \u043e\u043d\u0430 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u043e\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c &#171;\u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c&#187; \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/p>\n<h2>Flask &amp; Requests<\/h2>\n<p>Telebot, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u0440\u0443\u0442\u043e, \u043d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u201c\u041d\u041e\u201d. \u041f\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0443 hr-\u043e\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 (\u0441\u0430\u0439\u0442), \u0433\u0434\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\/\u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\/\u043e\u0442 \u043d\u0438\u0445. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0430\u043c\u0438\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 python &#8212; \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a flask. \u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u043d\u0430 5000-\u043e\u043c \u043f\u043e\u0440\u0442\u0443 (<a href=\"http:\/\/localhost:5000\/\" rel=\"noopener noreferrer nofollow\"><u>http:\/\/localhost:5000\/<\/u><\/a>):<\/p>\n<pre><code class=\"python\">from flask import Flask   app = Flask(__name__)   @app.route(\"\/\", methods=[\"GET\"]) def index():     return \"Hello, World!\"     if __name__ == \"__main__\":     app.run()<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043e\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u042f \u043d\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e (<a href=\"https:\/\/habr.com\/ru\/post\/495036\/\" rel=\"noopener noreferrer nofollow\"><u>habr<\/u><\/a>), \u0430 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0438 \u043f\u043e\u0439\u0434\u0443 \u0441 \u043a\u043e\u043d\u0446\u0430. \u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u043e\u0442\u0430 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u201cHello!\u201d \u043d\u0430 \u043b\u044e\u0431\u043e\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\">from flask import Flask, request import requests  app = Flask(__name__)   def send_message(chat_id, text):     method = \"sendMessage\"     token = \"1111105161:AAHIjyAKY4fj62whM5vEAfotuixC5syA-j8\"     url = f\"https:\/\/api.telegram.org\/bot{token}\/{method}\"     data = {\"chat_id\": chat_id, \"text\": text}     requests.post(url, data=data)   @app.route(\"\/\", methods=[\"POST\"]) def receive_update():     chat_id = request.json[\"message\"][\"chat\"][\"id\"]     send_message(chat_id, \"Hello!\")     return \"ok\"   if __name__ == \"__main__\":     app.run()<\/code><\/pre>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0422\u043e\u0447\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442, \u043d\u043e \u043d\u0435 \u0441\u0440\u0430\u0437\u0443. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043a\u0443\u0434\u0430 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u0445. \u0414\u043b\u044f \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0443 telegram API \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/core.telegram.org\/bots\/api#setwebhook\" rel=\"noopener noreferrer nofollow\">setWebhook<\/a>. \u0421\u0443\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0443 url, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f\u0445 \u043a \u0431\u043e\u0442\u0443 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <a href=\"http:\/\/localhost:5000\/\" rel=\"noopener noreferrer nofollow\"><u>http:\/\/localhost:5000\/<\/u><\/a>). \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0443: &#171;\u041f\u043e\u0441\u044b\u043b\u0430\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 localhost&#187;, \u0432\u0435\u0434\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 localhost \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u043c. \u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 setWebhook \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e https url-\u044b. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 ngrok, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u0438\u0442 \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u0434\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u043e\u0441\u0442\u0430. \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"https:\/\/dashboard.ngrok.com\/get-started\/setup\" rel=\"noopener noreferrer nofollow\"><u>ngrok<\/u><\/a>, \u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0443\u043d\u043d\u0435\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u201cngrok http 5000\u201d. \u0414\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><figcaption>ngrok<\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 setWebhook, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0435\u0440\u0435\u0437 postman. \u041d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c post \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 https:\/\/api.telegram.org\/bot&lt;\u0422\u041e\u041a\u0415\u041d&gt;\/setWebhook \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0432 \u0442\u0435\u043b\u0435 \u043d\u0443\u0436\u043d\u043e\u0433\u043e url. \u0414\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e:<\/p>\n<figure class=\"full-width\"><figcaption>setWebhook<\/figcaption><\/figure>\n<h2>\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 telebot, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u043d\u0430 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c. \u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 flask\u2019e, \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u044d\u0442\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c. \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c? \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 send_message \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a: <\/p>\n<pre><code class=\"python\">from flask import Flask, request import telebot  app = Flask(__name__)   bot = telebot.TeleBot('1111105161:AAHIjyAKY4fj62whM5vEAfotuixC5syA-j8')   @app.route(\"\/\", methods=[\"POST\"]) def receive_update():     chat_id = request.json[\"message\"][\"chat\"][\"id\"]     bot.send_message(chat_id, \"Hello!\")     return \"ok\"   if __name__ == \"__main__\":     app.run()<\/code><\/pre>\n<p>\u041d\u043e, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 \u0447\u0430\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e @bot.message_handler &#8212; \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u044e\u0442 \u0442\u0438\u043f \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f (\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442, \u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0438 \u0442. \u0434.). \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430\u0448\u0435 flask \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0442\u043e \u043c\u044b \u0442\u0435\u0440\u044f\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 telebot. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c bot.polling(), \u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u201c\u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b\u201d. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043a\u0430\u043a-\u0442\u043e \u0432\u0441\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u043d\u0430\u0448\u0435\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0441\u0442\u044b\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043e\u0434\u043d\u0430\u043a\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0439:<\/p>\n<pre><code class=\"python\">from flask import Flask, request import telebot  bot = telebot.TeleBot('1111105161:AAHIjyAKY4fj62whM5vEAfotuixC5syA-j8') bot.set_webhook(url=\"https:\/\/8c6f687b75c9.ngrok.io\") app = Flask(__name__)   @app.route('\/', methods=[\"POST\"]) def webhook():     bot.process_new_updates(         [telebot.types.Update.de_json(request.stream.read().decode(\"utf-8\"))]     )     return \"ok\"   @bot.message_handler(commands=['start']) def start_command(message):     bot.send_message(message.chat.id, 'Hello!')   if __name__ == \"__main__\":     app.run()<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c set_webhook, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0440\u0430\u043d\u0435\u0435 \u0447\u0435\u0440\u0435\u0437 postman, \u0430 \u043d\u0430 \u043f\u0443\u0441\u0442\u043e\u043c \u0440\u043e\u0443\u0442\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c &#171;\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0433\u0438\u0438&#187;, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u043e\u0442\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043b\u0443\u0447\u0448\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c-\u0431\u043e\u0442\u0430 \u043d\u0430 python \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0441\u043b\u043e\u0436\u043d\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u0442\u044c \u0438 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u043e, \u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c-\u0431\u043e\u0442\u043e\u043c. \u0414\u0430\u043b\u044c\u0448\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0440\u0430\u0449\u0438\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u043e \u0412\u0430\u0448\u0435\u043c\u0443 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e.<\/p>\n<\/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\/552052\/\"> https:\/\/habr.com\/ru\/post\/552052\/<\/a><br \/><\/br><\/br><\/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-321321","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/321321","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=321321"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/321321\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=321321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=321321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=321321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}