{"id":300791,"date":"2020-03-26T15:00:38","date_gmt":"2020-03-26T15:00:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=300791"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=300791","title":{"rendered":"COVID-19 Telegram-\u0431\u043e\u0442 \/\/ \u041e\u0442\u0432\u0435\u0447\u0430\u0435\u043c \u043d\u0430 FAQ \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/494118\/\">\u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u0441\u0435\u043e\u0431\u0449\u0435\u0433\u043e \u0445\u0430\u0439\u043f\u0430 \u043d\u0430 \u041a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u0435, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 (\u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0445\u0430\u0439\u043f\u043e\u0432\u043e\u0435). \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0437\u0430 2.5 \u0447\u0430\u0441\u0430 (\u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043c\u0435\u043d\u044f \u0443\u0448\u043b\u043e) \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c Telegram \u0411\u043e\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Rule-Based NLP \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043d\u0430 FAQ-\u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 \u043a\u0435\u0439\u0441\u043e\u043c COVID-19.<\/p>\n<p>  \u0412 \u0445\u043e\u0434\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u043e\u0431\u0440\u044b\u0439 Python, Telegram API, \u043f\u0430\u0440\u0443 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 NLP-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 Docker.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/68\/e4\/tw\/68e4twfyppio_uy1o1dojajfeca.jpeg\"><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h2>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e Telegram \u0411\u043e\u0442\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043d\u0430 FAQ \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e COVID-19. \u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0430 \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430, \u0438 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u0435\u0439\u0441\u043e\u0432. \u0415\u0449\u0451 \u0440\u0430\u0437 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443, \u0447\u0442\u043e \u044f \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044e \u043d\u0430 State of the Art, \u0430 \u043b\u0438\u0448\u044c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u044b\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Python, \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d Python 3.X \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 (PyCharm, VS Code), \u0432\u044b \u0443\u043c\u0435\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0411\u043e\u0442\u0430 \u0432 Telegram \u0447\u0435\u0440\u0435\u0437 BotFather, \u0430 \u043f\u043e \u0441\u0435\u043c\u0443, \u043f\u0440\u043e\u043f\u0443\u0449\u0443 \u044d\u0442\u0438 \u0432\u0435\u0449\u0438.<\/p>\n<h2>1. \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c API<\/h2>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c, \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443-\u043e\u0431\u0451\u0440\u0442\u043a\u0443 \u0434\u043b\u044f Telegram API &quot;<a href=\"https:\/\/github.com\/python-telegram-bot\/python-telegram-bot\" rel=\"nofollow\">python-telegram-bot<\/a>&quot;. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e: <\/p>\n<pre><code class=\"python\">pip install python-telegram-bot --upgrade<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043a\u0430\u0440\u043a\u0430\u0441 \u043d\u0430\u0448\u0435\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u00ab\u0445\u044d\u043d\u0434\u043b\u0435\u0440\u044b\u00bb \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0411\u043e\u0442\u0430:<\/p>\n<ul>\n<li>start \u2014 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0411\u043e\u0442\u0430;<\/li>\n<li>help \u2014 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u043e\u043c\u043e\u0449\u0438 (\u0441\u043f\u0440\u0430\u0432\u043a\u0430);<\/li>\n<li>message \u2014 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f;<\/li>\n<li>error \u2014 \u043e\u0448\u0438\u0431\u043a\u0430.<\/li>\n<\/ul>\n<p>  \u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">def start(update, context):     #\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0431\u043e\u0442\u0430     pass   def help(update, context):     #\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u043e\u043c\u043e\u0449\u0438     pass   def message(update, context):     #\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f     pass   def error(update, context):     #\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438     pass<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u043c \u0432\u0441\u0435 \u044d\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0431\u043e\u0442\u0430:<\/p>\n<pre><code class=\"python\">def get_answer():     &quot;&quot;&quot;Start the bot.&quot;&quot;&quot;     # Create the Updater and pass it your bot's token.     # Make sure to set use_context=True to use the new context based callbacks     # Post version 12 this will no longer be necessary     updater = Updater(&quot;Token&quot;, use_context=True)      # Get the dispatcher to register handlers     dp = updater.dispatcher      # on different commands - answer in Telegram     dp.add_handler(CommandHandler(&quot;start&quot;, start))     dp.add_handler(CommandHandler(&quot;help&quot;, help))      # on noncommand i.e message - echo the message on Telegram     dp.add_handler(MessageHandler(Filters.text, message))      # log all errors     dp.add_error_handler(error)      # Start the Bot     updater.start_polling()      # Run the bot until you press Ctrl-C or the process receives SIGINT,     # SIGTERM or SIGABRT. This should be used most of the time, since     # start_polling() is non-blocking and will stop the bot gracefully.     updater.idle()   if __name__ == &quot;__main__&quot;:     get_answer()<\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0449\u0430\u044e \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c 2 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0431\u043e\u0442\u0430:<\/p>\n<ul>\n<li>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 Polling \u2014 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u043f\u0440\u043e\u0441 \u0411\u043e\u0442\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 Telegram API \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 (<code>updater.start_polling()<\/code>);<\/li>\n<li>Webhook \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0432\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 endpoint&#8217;\u043e\u043c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438\u0437 \u0431\u043e\u0442\u0430, \u0442\u0440\u0435\u0431\u0443\u0435\u0442 HTTPS.<\/li>\n<\/ul>\n<p>  \u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 Polling.<\/p>\n<h2>2. \u041d\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043b\u043e\u0433\u0438\u043a\u043e\u0439<\/h2>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 start \u0438 help \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u043e\u0442\u0432\u0435\u0442\u0430\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code class=\"python\">def start(update, context):     &quot;&quot;&quot;Send a message when the command \/start is issued.&quot;&quot;&quot;     update.message.reply_text(&quot;&quot;&quot; \u041f\u0440\u0438\u0432\u0435\u0442! \u042f \u043c\u043e\u0433\u0443 \u043f\u0440\u043e\u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0431\u044f \u043f\u043e \u043b\u044e\u0431\u043e\u043c\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u043e COVID-19. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: - *\u041a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441?* - *\u0417\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043b\u0438 \u043c\u0430\u0441\u043a\u0430?* - *\u041a\u0430\u043a\u0438\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u0442\u0440\u0430\u043d\u044b \u0440\u0438\u0441\u043a\u0430?* \u0438 \u0442.\u0434. \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043f\u0440\u043e\u0441\u0438!     &quot;&quot;&quot;, parse_mode=telegram.ParseMode.MARKDOWN)   def help(update, context):     &quot;&quot;&quot;Send a message when the command \/help is issued.&quot;&quot;&quot;     update.message.reply_text(&quot;&quot;&quot; \u0421\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0439 \u043c\u0435\u043d\u044f \u043e \u0447\u0451\u043c \u0445\u043e\u0447\u0435\u0448\u044c (\u0432 \u0440\u0430\u043c\u043a\u0430\u0445 COVID-19). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: - *\u041a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441?* - *\u0417\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043b\u0438 \u043c\u0430\u0441\u043a\u0430?* - *\u041a\u0430\u043a\u0438\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u0442\u0440\u0430\u043d\u044b \u0440\u0438\u0441\u043a\u0430?* \u0438 \u0442.\u0434. \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043f\u0440\u043e\u0441\u0438!     &quot;&quot;&quot;, parse_mode=telegram.ParseMode.MARKDOWN)<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434 \/start \u0438\u043b\u0438 \/help \u2014 \u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u043e\u0442\u0432\u0435\u0442, \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438. \u041e\u0431\u0440\u0430\u0449\u0430\u044e \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043a\u0441\u0442 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0432 Markdown<\/p>\n<pre><code class=\"python\">parse_mode=telegram.ParseMode.MARKDOWN<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a error \u043b\u043e\u0433\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<pre><code class=\"python\">def error(update, context):     &quot;&quot;&quot;Log Errors caused by Updates.&quot;&quot;&quot;     logger.warning('Update &quot;%s&quot; caused error &quot;%s&quot;', update, context.error)<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u043d\u0430\u0448 \u0411\u043e\u0442. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0432\u0435\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/Perevalov\/covid19_bot_public\/blob\/master\/app.py\" rel=\"nofollow\">app.py<\/a>. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 <a href=\"https:\/\/github.com\/Perevalov\/covid19_bot_public\/blob\/master\/app.py\" rel=\"nofollow\">import&#8217;\u044b<\/a>.<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 Telegram (<u>\u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 Token \u0432 \u043a\u043e\u0434<\/u>). \u041f\u0438\u0448\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \/start \u0438 \/help \u0438 \u0440\u0430\u0434\u0443\u0435\u043c\u0441\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/hn\/jf\/bo\/hnjfbobptb1e1no0h-nl5cdegt4.jpeg\"><\/p>\n<h2>3. \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0442\u0432\u0435\u0442<\/h2>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u044d\u0442\u043e \u00ab\u0411\u0430\u0437\u0430 \u0437\u043d\u0430\u043d\u0438\u0439\u00bb. \u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 json-\u0444\u0430\u0439\u043b \u0432 \u0432\u0438\u0434\u0435 Key-Value \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0433\u0434\u0435 Key \u2014 \u044d\u0442\u043e \u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430, \u0430 Value \u2014 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441. \u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u0430\u0437\u044b \u0437\u043d\u0430\u043d\u0438\u0439:<\/p>\n<pre><code class=\"json\">{   &quot;\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441 \u0438 \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u0440\u0430\u0436\u0435\u043d\u0438\u0435?&quot;: &quot;\u041d\u043e\u0432\u044b\u0439 \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441 \u2014 \u0440\u0435\u0441\u043f\u0438\u0440\u0430\u0442\u043e\u0440\u043d\u044b\u0439 \u0432\u0438\u0440\u0443\u0441. \u041e\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u043e\u0437\u0434\u0443\u0448\u043d\u043e-\u043a\u0430\u043f\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0434\u044b\u0445\u0430\u043d\u0438\u044f \u043a\u0430\u043f\u0435\u043b\u044c, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0445 \u0438\u0437 \u0434\u044b\u0445\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0443\u0442\u0435\u0439 \u0431\u043e\u043b\u044c\u043d\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u043a\u0430\u0448\u043b\u0435 \u0438\u043b\u0438 \u0447\u0438\u0445\u0430\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043f\u0435\u043b\u044c \u0441\u043b\u044e\u043d\u044b \u0438\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0438\u0437 \u043d\u043e\u0441\u0430. \u0422\u0430\u043a\u0436\u0435 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0431\u043e\u043b\u044c\u043d\u043e\u0439 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0432\u0435\u0440\u043d\u043e\u0439 \u0440\u0443\u0447\u043a\u0438. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043a\u0430\u0441\u0430\u043d\u0438\u0438 \u0440\u0442\u0430, \u043d\u043e\u0441\u0430 \u0438\u043b\u0438 \u0433\u043b\u0430\u0437 \u0433\u0440\u044f\u0437\u043d\u044b\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438.&quot;,   &quot;\u041a\u0430\u043a\u0438\u0435 \u0441\u0438\u043c\u043f\u0442\u043e\u043c\u044b \u0443 \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u0430?&quot;: &quot;\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u0438\u043c\u043f\u0442\u043e\u043c\u044b \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u0430:\\n    \u041f\u043e\u0432\u044b\u0448\u0435\u043d\u043d\u0430\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430\\n    \u0427\u0438\u0445\u0430\u043d\u0438\u0435\\n    \u041a\u0430\u0448\u0435\u043b\u044c\\n    \u0417\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u043d\u043e\u0435 \u0434\u044b\u0445\u0430\u043d\u0438\u0435\\n\\n\u0412 \u043f\u043e\u0434\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0438\u043c\u043f\u0442\u043e\u043c\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043d\u0435 \u0441 \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u043e\u043c, \u0430 \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u041e\u0420\u0412\u0418.&quot;,   &quot;\u041a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441?&quot;: &quot;\u041f\u0443\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438:\\n\u0412\u043e\u0437\u0434\u0443\u0448\u043d\u043e-\u043a\u0430\u043f\u0435\u043b\u044c\u043d\u044b\u0439 (\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0438\u0440\u0443\u0441\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043a\u0430\u0448\u043b\u0435, \u0447\u0438\u0445\u0430\u043d\u0438\u0438, \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0435)\\n\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u043e-\u0431\u044b\u0442\u043e\u0432\u043e\u0439 (\u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u043e\u0431\u0438\u0445\u043e\u0434\u0430)&quot;,   }<\/code><\/pre>\n<p>  \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<ol>\n<li>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f;<\/li>\n<li>\u041b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f;<\/li>\n<li>\u041d\u0435\u0447\u0451\u0442\u043a\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0437\u043d\u0430\u043d\u0438\u0439 (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D1%81%D1%81%D1%82%D0%BE%D1%8F%D0%BD%D0%B8%D0%B5_%D0%9B%D0%B5%D0%B2%D0%B5%D0%BD%D1%88%D1%82%D0%B5%D0%B9%D0%BD%D0%B0\" rel=\"nofollow\">\u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u041b\u0435\u0432\u0435\u043d\u0448\u0442\u0435\u0439\u043d\u0430<\/a>);<\/li>\n<li>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u00ab\u043f\u043e\u0445\u043e\u0436\u0438\u0439\u00bb \u0432\u043e\u043f\u0440\u043e\u0441 \u0438\u0437 \u0431\u0430\u0437\u044b \u0437\u043d\u0430\u043d\u0438\u0439;<\/li>\n<li>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/li>\n<\/ol>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0438\u0445 \u043f\u043b\u0430\u043d\u043e\u0432, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: <a href=\"https:\/\/github.com\/seatgeek\/fuzzywuzzy\" rel=\"nofollow\">fuzzywuzzy<\/a> (\u0434\u043b\u044f \u043d\u0435\u0447\u0435\u0442\u043a\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f) \u0438 <a href=\"https:\/\/pymorphy2.readthedocs.io\/en\/latest\/\" rel=\"nofollow\">pymorphy2<\/a> (\u0434\u043b\u044f \u043b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438).<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u0438\u043c\u043f\u043b\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c \u043e\u0437\u0432\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c:<\/p>\n<pre><code class=\"python\">import json from fuzzywuzzy import fuzz import pymorphy2  #\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 morph = pymorphy2.MorphAnalyzer() #\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u0430\u0437\u044b \u0437\u043d\u0430\u043d\u0438\u0439 with open(&quot;faq.json&quot;) as json_file:     faq = json.load(json_file)   def classify_question(text):     #\u043b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u044e\u0437\u0435\u0440\u0430     text = ' '.join(morph.parse(word)[0].normal_form for word in text.split())     questions = list(faq.keys())     scores = list()     #\u0446\u0438\u043a\u043b \u043f\u043e \u0432\u0441\u0435\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c \u0438\u0437 \u0431\u0430\u0437\u044b \u0437\u043d\u0430\u043d\u0438\u0439     for question in questions:         #\u043b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u0438\u0437 \u0431\u0430\u0437\u044b \u0437\u043d\u0430\u043d\u0438\u0439         norm_question = ' '.join(morph.parse(word)[0].normal_form for word in question.split())         #\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u044e\u0437\u0435\u0440\u0430 \u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u0438\u0437 \u0431\u0430\u0437\u044b \u0437\u043d\u0430\u043d\u0438\u0439         scores.append(fuzz.token_sort_ratio(norm_question.lower(), text.lower()))     #\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430     answer = faq[questions[scores.index(max(scores))]]      return answer<\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a message, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0438 \u0432 tsv \u0444\u0430\u0439\u043b:<\/p>\n<pre><code class=\"python\">def dump_data(user, question, answer):     username = user.username     full_name = user.full_name     id = user.id      str = &quot;&quot;&quot;{username}\\t{full_name}\\t{id}\\t{question}\\t{answer}\\n&quot;&quot;&quot;.format(username=username,                                                                  full_name=full_name,                                                                  id=id,                                                                  question=question,                                                                  answer=answer)      with open(&quot;\/data\/dump.tsv&quot;, &quot;a&quot;) as myfile:         myfile.write(str)<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f message:<\/p>\n<pre><code class=\"python\">def message(update, context):     &quot;&quot;&quot;Answer the user message.&quot;&quot;&quot;     #\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430     answer = classify_question(update.message.text)     #\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 \u0444\u0430\u0439\u043b     dump_data(update.message.from_user, update.message.text, answer)     #\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f     update.message.reply_text(answer)<\/code><\/pre>\n<p>  \u0412\u0443\u0430\u043b\u044f, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 Telegram \u0438 \u0440\u0430\u0434\u0443\u0435\u043c\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/id\/fj\/2h\/idfj2hjue-vkxmusxsd6hibl-zu.jpeg\" width=\"300\"><\/p>\n<h2>4. \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c Docker \u0438 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u043a\u043b\u0430\u0441\u0441\u0438\u043a: \u00ab\u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e.\u00bb, \u0442\u0430\u043a \u0432\u043e\u0442, \u0447\u0442\u043e\u0431\u044b \u0443 \u043d\u0430\u0441 \u0432\u0441\u0451 \u0431\u044b\u043b\u043e \u043a\u0430\u043a \u0443 \u043b\u044e\u0434\u0435\u0439, \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Docker Compose.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ol>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c Dockerfile \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0438 \u0432\u0445\u043e\u0434\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443;<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c docker-compose.yml \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0435\u0434\u0438\u043d\u044b\u0439 Dockerfile (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e.)<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c boot.sh (\u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430 \u0437\u0430\u043f\u0443\u0441\u043a).<\/li>\n<\/ol>\n<p>  \u0418\u0442\u0430\u043a, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 Dockerfile:<\/p>\n<pre><code class=\"plaintext\">#\u043e\u0431\u0440\u0430\u0437 FROM python:3.6.6-slim  #\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 WORKDIR \/home\/alex\/covid-bot  #\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b requirements.txt COPY requirements.txt .\/  # Install required libs RUN pip install --upgrade pip -r requirements.txt; exit 0  #\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u043f\u043a\u0443 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 COPY data data  # \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 COPY app.py faq.json reply_generator.py boot.sh  .\/  # \u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u043f\u043e\u0436\u0430\u0440\u043d\u044b\u0439 RUN apt-get clean &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/* \/tmp\/* \/var\/tmp\/*  #\u0440\u0430\u0437\u0434\u0430\u0451\u043c \u043f\u0440\u0430\u0432\u0430 RUN chmod +x boot.sh  #\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 ENTRYPOINT [&quot;.\/boot.sh&quot;]<\/code><\/pre>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 docker-compose.yml:<\/p>\n<pre><code class=\"plaintext\">#\u0432\u0435\u0440\u0441\u0438\u044f docker-compose version: '2' #\u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 services:   bot:     restart: unless-stopped     image: covid19_rus_bot:latest     container_name: covid19_rus_bot     #\u0437\u0430\u0434\u0430\u0451\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u044b \u0434\u043b\u044f boot.sh     environment:       - SERVICE_TYPE=covid19_rus_bot     #\u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c volume \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043f\u0430\u043f\u043a\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438     volumes:          - .\/data:\/data <\/code><\/pre>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 boot.sh:<\/p>\n<pre><code class=\"plaintext\">#!\/bin\/bash if [ -n $SERVICE_TYPE ] then   if [ $SERVICE_TYPE == &quot;covid19_rus_bot&quot; ]   then     exec python app.py     exit   fi else   echo -e &quot;SERVICE_TYPE not set\\n&quot; fi<\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0451 \u044d\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"bash\">sudo docker build -t covid19_rus_bot:latest . sudo docker-compose up<\/code><\/pre>\n<p>  \u0412\u0441\u0451, \u043d\u0430\u0448 \u0431\u043e\u0442 \u0433\u043e\u0442\u043e\u0432.<\/p>\n<h2>\u0412\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/h2>\n<p>  \u041a\u0430\u043a \u0438 \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 <a href=\"https:\/\/github.com\/Perevalov\/covid19_bot_public\" rel=\"nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u043c\u043d\u043e\u0439, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u0432 \u043b\u044e\u0431\u043e\u043c \u043a\u0435\u0439\u0441\u0435 \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 FAQ \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0431\u0430\u0437\u0443 \u0437\u043d\u0430\u043d\u0438\u0439! \u041a\u0430\u0441\u0430\u0435\u043c\u043e \u0431\u0430\u0437\u044b \u0437\u043d\u0430\u043d\u0438\u0439, \u0435\u0451 \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 Key \u0438 Value \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0430\u0436\u0434\u0430\u044f \u043f\u0430\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0431\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043e\u0434\u043d\u0443 \u0442\u0435\u043c\u0443 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u043d\u0438\u0445 (\u0434\u043b\u044f \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c). \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, Rule-Based \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0433\u0438\u0431\u043e\u043a \u043a \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e, \u043e\u0434\u043d\u0430\u043a\u043e \u044f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432\u044b\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u0430\u0437\u0443 \u0437\u043d\u0430\u043d\u0438\u0439 \u0441 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 500-\u043c\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438.<\/p>\n<p>  \u0422\u0435\u0445, \u043a\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0435\u0433\u043e \u0411\u043e\u0442\u0430 <a href=\"http:\/\/t.me\/covid19_rus_bot\" rel=\"nofollow\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/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\/494118\/\"> https:\/\/habr.com\/ru\/post\/494118\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/494118\/\">\u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u0441\u0435\u043e\u0431\u0449\u0435\u0433\u043e \u0445\u0430\u0439\u043f\u0430 \u043d\u0430 \u041a\u043e\u0440\u043e\u043d\u0430\u0432\u0438\u0440\u0443\u0441\u0435, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 (\u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0445\u0430\u0439\u043f\u043e\u0432\u043e\u0435). \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0437\u0430 2.5 \u0447\u0430\u0441\u0430 (\u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043c\u0435\u043d\u044f \u0443\u0448\u043b\u043e) \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c Telegram \u0411\u043e\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Rule-Based NLP \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043d\u0430 FAQ-\u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 \u043a\u0435\u0439\u0441\u043e\u043c COVID-19.<\/p>\n<p>  \u0412 \u0445\u043e\u0434\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u043e\u0431\u0440\u044b\u0439 Python, Telegram API, \u043f\u0430\u0440\u0443 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 NLP-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 Docker.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/68\/e4\/tw\/68e4twfyppio_uy1o1dojajfeca.jpeg\">  <\/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-300791","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/300791","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=300791"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/300791\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=300791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=300791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=300791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}