{"id":310888,"date":"2020-10-02T15:01:01","date_gmt":"2020-10-02T15:01:01","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=310888"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=310888","title":{"rendered":"\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a \u043d\u0430 Python"},"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\/521742\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/un\/fa\/yr\/unfayrvb-ga463ak4uelpx5o9gw.jpeg\"><\/p>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043b\u0430\u0434\u0435\u0442\u044c. \u041c\u043d\u043e\u0433\u0438\u0435 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0438\u0445 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0437\u0432\u043e\u043d\u043a\u043e\u0432. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0412\u0430\u0448\u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0430\u0442-\u0431\u043e\u0442\u0430, \u0430 \u0435\u0441\u043b\u0438 \u0442\u043e\u0447\u043d\u0435\u0435 \u2013 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434. \u0421 \u0435\u0435 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u043c\u044b\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u043e\u0432.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043d\u0430\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">import speech_recognition as sr import os import sys import webbrowser import pyttsx3 as p from datetime import datetime import time import datetime import random<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u0435\u043c \u0432\u0435\u0441\u0442\u0438 \u043b\u043e\u0433 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u043c, \u0435\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0440\u0435\u0448\u0438\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0431\u043e\u0442\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u044c\u044e. \u041c\u043d\u043e\u0433\u0438\u0435 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0443\u044e \u0441\u0435\u0442\u044c \u0432 \u0441\u0432\u043e\u0438\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430\u0445 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u044d\u043c\u043e\u0446\u0438\u0439 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043d\u0438\u0445. <\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043b\u043e\u0433\u043e\u0432, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u043b\u0430\u0431\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0431\u043e\u0442\u0430 \u0438 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"python\">#\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043b\u043e\u0433 chat_log = [['SESSION_ID', 'DATE', 'AUTHOR', 'TEXT', 'AUDIO_NUM']] #\u0423\u0437\u043d\u0430\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0441\u0435\u0441\u0441\u0438\u0438 i = 1 exit = 0 while exit == 0:     session_id = str(i)     if session_id not in os.listdir():         os.mkdir(session_id)         exit = 1     else:         i = i + 1 #\u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0438\u0448\u0435\u0442 bot author = 'Bot' text = '\u041f\u0440\u0438\u0432\u0435\u0442! \u0427\u0435\u043c \u044f \u043c\u043e\u0433\u0443 \u0432\u0430\u043c \u043f\u043e\u043c\u043e\u0447\u044c?'<\/code><\/pre>\n<p>  \u0412 \u043b\u043e\u0433 \u0444\u0430\u0439\u043b \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0430\u0432\u0442\u043e\u0440\u0430 (\u0431\u043e\u0442 \u0438\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c) \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u0441\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<pre><code class=\"python\">#\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a \u043b\u043e\u0433\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b def log_me(author, text, audio):      now = datetime.datetime.now()     i = 1     exit = 0     while exit == 0:         audio_num = str(i)+'.wav'         if audio_num not in os.listdir(session_id):             exit = 1         else:             i = i + 1     os.chdir(session_id)     with open(audio_num , &quot;wb&quot;) as file:         file.write(audio.get_wav_data())     chat_log.append([now.strftime(&quot;%Y-%m-%d %H:%M:%S&quot;), author, text, audio_num])<\/code><\/pre>\n<p>  \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0437\u0430 \u0430\u0432\u0442\u043e\u0440\u0441\u0442\u0432\u043e\u043c \u0431\u043e\u0442\u0430: \u041f\u0440\u0438\u0432\u0435\u0442! \u0427\u0435\u043c \u044f \u043c\u043e\u0433\u0443 \u0432\u0430\u043c \u043f\u043e\u043c\u043e\u0447\u044c?<\/p>\n<pre><code class=\"python\"># \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u043b\u043e\u0433     print(&quot;Bot: &quot;+ text) log_me(author, text, audio)<\/code><\/pre>\n<p>  \u0410 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0432 Jupyter Notebook \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0437\u0432\u0443\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0441\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430:<\/p>\n<pre><code class=\"python\">#\u041f\u0440\u043e\u0438\u0437\u043d\u043e\u0448\u0435\u043d\u0438\u0435 words def talk(words):     engine.say(words)     engine.runAndWait()<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043e\u0437\u0432\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0432\u044b\u0448\u0435, \u043d\u043e \u043a\u0430\u043a \u0436\u0435 \u043c\u044b \u0441\u0432\u043e\u0439 \u0433\u043e\u043b\u043e\u0441 \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0442\u0435\u043a\u0441\u0442? \u0422\u0443\u0442 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 \u043e\u0442 Google \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d\u043e\u043c.<\/p>\n<pre><code class=\"python\">#\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d\u0430     def command():     rec = sr.Recognizer()     with sr.Microphone() as source:         #\u0411\u043e\u0442 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u0430         print('Bot: ...')         #\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0432 \u0437\u0430\u043f\u0438\u0441\u0438         rec.pause_threshold = 1         #\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0444\u043e\u043d\u043e\u0432\u043e\u0433\u043e \u0448\u0443\u043c\u0430 \u0441 \u0437\u0430\u043f\u0438\u0441\u0438         rec.adjust_for_ambient_noise(source, duration=1)         audio = rec.listen(source)     try:         #\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 GOOGLE         text = rec.recognize_google(audio, language=&quot;ru-RU&quot;).lower()         #\u0412\u044b\u0432\u043e\u0434 \u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d         print('\u0412\u044b:  ' + text[0].upper() + text[1:])         log_me('User', text, audio)     #\u0415\u0441\u043b\u0438 \u043d\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043b\u0441\u044f \u0442\u0435\u0441\u0442 \u0438\u0437 \u0430\u0443\u0434\u0438\u043e     except sr.UnknownValueError:         text = '\u041d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e. \u041f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u0435.'         print('Bot: ' + text)         talk(text)         #\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0437\u0430\u043d\u043e\u0432\u043e \u0441\u043b\u0443\u0448\u0430\u0442\u044c         text = command()         log_me('Bot', text, , Null)     return text<\/code><\/pre>\n<p>  \u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0448 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0441 \u0441\u043b\u0443\u0448\u0430\u0442\u044c? \u0412\u0441\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043e \u043d\u0430\u0448\u0435\u0439 \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0435\u0439! \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u043f\u0443\u0441\u0442\u044c \u043f\u0440\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0441\u0430\u0439\u0442 \u2013 \u043e\u043d \u043e\u0442\u043a\u0440\u043e\u0435\u0442 \u0441\u0430\u0439\u0442 (\u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u043b\u0438?).<\/p>\n<pre><code class=\"python\">#\u0422\u0443\u0442 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u043e\u0432\u043e\u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0439 def makeSomething(text):     if '\u043e\u0442\u043a\u0440\u043e\u0439 \u0441\u0430\u0439\u0442' in text:         print('Bot: \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u044e \u0441\u0430\u0439\u0442 NewTechAudit.')         talk('\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u044e \u0441\u0430\u0439\u0442 NewTechAudit.')         log_me('Bot','\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u044e \u0441\u0430\u0439\u0442 NewTechAudit.', Null)         webbrowser.open('https:\/\/newtechaudit.ru\/')<\/code><\/pre>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u043e\u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043b\u043e\u0432\u0430, \u0434\u0430 \u0447\u0443\u0436\u0438\u043c\u0438 \u0443\u0441\u0442\u0430\u043c\u0438. \u041f\u0443\u0441\u0442\u044c \u0431\u043e\u0442 \u0435\u0449\u0435 \u0443\u043c\u0435\u0435\u0442 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0437\u0430 \u043d\u0430\u043c\u0438:<\/p>\n<pre><code class=\"python\">#\u041f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u0444\u0440\u0430\u0437\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f     elif '\u043f\u0440\u043e\u0438\u0437\u043d\u0435\u0441\u0438' in text or '\u0441\u043a\u0430\u0436\u0438' in text or '\u043f\u043e\u0432\u0442\u043e\u0440\u0438' in text:         print('Bot: ' + text[10].upper() + text[11:])         talk(text[10:])         log_me('Bot', text[10].upper() + text[11:] , Null)<\/code><\/pre>\n<p>  \u041f\u0443\u0441\u0442\u044c \u0435\u0449\u0435 \u0438 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043d\u0438\u043a\u043e\u043c \u0431\u0443\u0434\u0435\u0442, \u043d\u043e \u043d\u0430\u0447\u043d\u0435\u043c \u043c\u044b \u043f\u043e\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430:<\/p>\n<pre><code class=\"python\">#\u041e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441     elif '\u0441\u0432\u043e\u0451 \u0438\u043c\u044f' in text or '\u043a\u0430\u043a \u0442\u0435\u0431\u044f \u0437\u043e\u0432\u0443\u0442' in text or '\u043d\u0430\u0437\u043e\u0432\u0438 \u0441\u0435\u0431\u044f' in text:         print('Bot: \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 Bot.')         talk('\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 Bot')         log_me('Bot', '\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 Bot', Null)<\/code><\/pre>\n<p>  \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430 \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u043c\u0438 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435: \u041d\u0430\u0437\u043e\u0432\u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0442 (1\u043e\u0435 \u0447\u0438\u0441\u043b\u043e) \u0434\u043e (2\u043e\u0435 \u0447\u0438\u0441\u043b\u043e).<\/p>\n<pre><code class=\"python\">#\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430     elif '\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e' in text:         ot=text.find('\u043e\u0442')         do=text.find('\u0434\u043e')         f_num=int(text[ot+3:do-1])         l_num=int(text[do+3:])         r=str(random.randint(f_num, l_num))         print('Bot: ' + r)         talk(r)         log_me('Bot', r, Null)<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043f\u0440\u043e\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u0431\u043e\u0442\u043e\u043c:<\/p>\n<pre><code class=\"python\">#\u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b     elif '\u043f\u043e\u043a\u0430' in text or '\u0434\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f' in text:         print('Bot: \u0414\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f!')         talk('\u0414\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f')         log_me('Bot', '\u041a\u043e\u043d\u0435\u0446 \u0441\u0435\u0441\u0441\u0438\u0438', Null)         os.chdir(session_id)         log_file = open( session_id + &quot;.txt&quot;, &quot;w&quot;)         for row in chat_log:             np.savetxt(log_file, row)         log_file.close()         sys.exit()<\/code><\/pre>\n<p>  \u0410 \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0431\u0435\u0441\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b.<\/p>\n<pre><code class=\"python\">#\u0411\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b while True:     makeSomething(command())<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0434\u0438\u0430\u043b\u043e\u0433:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/oz\/-v\/pu\/oz-vpu1juvyelyhmeiowisiypxo.png\"><\/p>\n<p>  \u0412 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435-\u0441\u0435\u0441\u0441\u0438\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b-\u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u0430 \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uc\/hl\/ad\/uchlad0tnnxgkhyluaaoz-1kxsc.png\"><\/p>\n<p>  \u0412 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wk\/d5\/uv\/wkd5uvnccz37eskouldz8nr0fji.png\"><\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043e\u0442\u0430 \u0441 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u044c\u044e. \u0414\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u043c\u043e\u0449\u0438 \u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043b\u043e\u0433 \u0444\u0430\u0439\u043b.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u0431\u043e\u0442 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0414\u0436\u0430\u0440\u0432\u0438\u0441\u0430!<\/p><\/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\/521742\/\"> https:\/\/habr.com\/ru\/post\/521742\/<\/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\/521742\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/un\/fa\/yr\/unfayrvb-ga463ak4uelpx5o9gw.jpeg\"><\/p>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043b\u0430\u0434\u0435\u0442\u044c. \u041c\u043d\u043e\u0433\u0438\u0435 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0438\u0445 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0437\u0432\u043e\u043d\u043a\u043e\u0432. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0412\u0430\u0448\u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0430\u0442-\u0431\u043e\u0442\u0430, \u0430 \u0435\u0441\u043b\u0438 \u0442\u043e\u0447\u043d\u0435\u0435 \u2013 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434. \u0421 \u0435\u0435 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u043c\u044b\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u043e\u0432.  <\/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-310888","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/310888","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=310888"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/310888\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=310888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=310888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=310888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}