{"id":362754,"date":"2024-05-21T01:41:31","date_gmt":"2024-05-21T01:41:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=362754"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=362754","title":{"rendered":"<span>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0447\u0430\u0442-\u0431\u043e\u0442\u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 \u0441 GPT Engineer \u0437\u0430 2 \u0447\u0430\u0441\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f2b\/831\/c9d\/f2b831c9d58d4e7b752c83874bab3ca8.png\" alt=\"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e AI, \u043d\u0438 \u043e\u0434\u0438\u043d \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043d\u0435 \u043f\u043e\u0441\u0442\u0440\u0430\u0434\u0430\u043b\" title=\"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e AI, \u043d\u0438 \u043e\u0434\u0438\u043d \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043d\u0435 \u043f\u043e\u0441\u0442\u0440\u0430\u0434\u0430\u043b\" width=\"1024\" height=\"1024\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f2b\/831\/c9d\/f2b831c9d58d4e7b752c83874bab3ca8.png\"\/><\/p>\n<div><figcaption>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e AI, \u043d\u0438 \u043e\u0434\u0438\u043d \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043d\u0435 \u043f\u043e\u0441\u0442\u0440\u0430\u0434\u0430\u043b<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0430\u0440\u0443 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0439 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 Highload, \u0438 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0447\u0442\u043e-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0438 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0432\u043b\u0435\u0447\u044c \u043b\u044e\u0434\u0435\u0439 \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0441\u0442\u0435\u043d\u0434\u0443. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0437\u0434\u0443\u043c\u0438\u0439 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 <strong>\u0447\u0430\u0442-\u0431\u043e\u0442\u0430.<\/strong> \u041d\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e: \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0435\u0433\u043e \u0446\u0435\u043b\u044c &#8212; \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0432 \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0411\u043e\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 AI, \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u043c\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u043b \u044d\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430?<\/p>\n<p>\u0421\u0440\u043e\u043a\u0438 \u043f\u043e\u0434\u0436\u0438\u043c\u0430\u043b\u0438, \u0434\u043e \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u0434\u043d\u044f, \u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u043d\u044f\u0442\u044b, \u044f \u0432\u044b\u0437\u0432\u0430\u043b\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c\u00a0 Telegram \u0431\u043e\u0442\u0430. \u0427\u0435\u0441\u0442\u043d\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u044c\u0441\u044f, \u0442\u0430\u043a\u043e\u0439 \u043e\u043f\u044b\u0442 \u0431\u044b\u043b \u0443 \u043c\u0435\u043d\u044f \u0432\u043f\u0435\u0440\u0432\u044b\u0435, \u043d\u043e \u044f \u0432\u0435\u0440\u0438\u043b \u0432 \u0441\u0438\u043b\u0443 \u0432\u0441\u0435\u043c\u043e\u0433\u0443\u0449\u0435\u0433\u043e \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0430, \u0438 \u043f\u0440\u0438\u043d\u044f\u043b\u0441\u044f \u0437\u0430 \u0434\u0435\u043b\u043e! \u00a0<\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c, <a href=\"https:\/\/github.com\/AntonOsika\/gpt-engineer\"><u>GPT Engineer<\/u><\/a> &#8212; \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u0441\u0445\u043e\u0436\u0438\u0439 \u0441 Auto-GPT. \u041e\u043d \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0446\u0435\u043b\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043b\u0438\u0448\u044c \u043d\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438. \u041f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0442\u0430\u043a\u043e\u0432\u0430 \u0442\u0435\u043e\u0440\u0438\u044f. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0432\u0441\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435: \u0434\u0430, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e &#8212; \u0443\u0436\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f. \u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u0430\u043c, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0435. \u041e\u0431 \u044d\u0442\u043e\u043c, \u0438 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0441\u043a\u043e\u0440\u043e AI \u0437\u0430\u043c\u0435\u043d\u0438\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 &#8212; \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c GPT Engineer, \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/AntonOsika\/gpt-engineer\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 <\/u><\/a>\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e, \u0441\u043b\u0435\u0434\u0443\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c \u0432 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u043c \u0444\u0430\u0439\u043b\u0435 README. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043d\u0430 Python, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442. \u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u043e, \u043e\u043f\u0438\u0448\u0438\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 &#8216;main_prompt&#8217;, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 projects. \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438 \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u043f\u043e\u043a\u0430 \u043e\u043d \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438 \u0441\u0442\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e API OpenAI (\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432\u0435\u0440\u0441\u0438\u044e 4), \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438. \u0412\u043e\u0442 \u043c\u043e\u0439 \u0433\u0435\u043d\u0438\u0430\u043b\u044c\u043d\u044b\u0439 <strong>\u043f\u0440\u043e\u043c\u0442<\/strong>:<\/p>\n<details class=\"spoiler\">\n<summary>Bot design prompt<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>Overview<\/strong><\/p>\n<p>This document outlines the design for a game where players guess the textual prompts used to generate images by DALLE-3. The game will be implemented using the OpenAI API, Python programming language, and Telegram API. It is a guessing game where players are shown an image generated by DALLE-3 and must guess the prompt used to create it.<\/p>\n<p><strong>Game Flow<\/strong><br \/>Start: The player starts the game through a Telegram bot.<br \/>Image Presentation: A DALLE-3 generated image is presented to the player.<br \/>Guessing Phase: The player has 3 attempts to guess the prompt.<br \/>Submission: After 3 attempts, the player submits their final guess.<br \/>Data Storage: The game stores the player\u2019s guess and other relevant data.<\/p>\n<p><strong>Technical Components<\/strong><\/p>\n<p>OpenAI API<\/p>\n<p>Purpose: To generate images based on textual prompts.<br \/>Integration: Python scripts will interact with the OpenAI API to request image generation.<\/p>\n<p>Python Backend<\/p>\n<p>Functionality:<br \/>Communicate with the OpenAI API.<br \/>Handle Telegram bot interactions.<br \/>Manage game logic and state.<br \/>Store and retrieve data.<\/p>\n<p>Libraries:<br \/>python-telegram-bot: For Telegram bot interactions.<br \/>requests: For making API calls to OpenAI.<br \/>os, json: For file handling and configuration management.<\/p>\n<p>Telegram API<br \/>Purpose: To provide a platform for users to play the game.<br \/>Integration:<br \/>The game will be accessible through a Telegram bot.<br \/>The bot will handle user inputs and display images and messages.<\/p>\n<p>Game Logic<br \/>Starting Image:<br \/>Read an image name from the config file, load it from the root folder.<br \/>User Interaction:<br \/>Present the image to the user via Telegram bot. <br \/>Receive guesses from the user.<br \/>After each guess &#8212; use OpenAI API to generate an image from that prompt and <br \/>show this image to the user.<br \/>Allow up to 3 attempts per image.<br \/>Data Handling:<br \/>After 3 attempts or final submission, save the user\u2019s guess.<br \/>Store the image, prompt, user\u2019s guess, Telegram username, and account info.<\/p>\n<p>Data Storage<br \/>Location: user_data folder in the bot\u2019s root directory.<br \/>Structure:<br \/>Subfolders named after the user\u2019s Telegram username.<br \/>Filder contains info.txt file with all user data and an image generated by the user.<\/p>\n<p>Configuration File<br \/>File Name: bot_config.json<br \/>Contents:<br \/>API keys.<br \/>Game settings (e.g., time limits, number of attempts).<br \/>Other configurable parameters.  <\/p>\n<p>Internationalization<br \/>gettext should be used for all text messages<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u043b\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c &#8212; \u0431\u0435\u0437\u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0431\u0443\u0447\u0430\u043b\u0441\u044f OpenAI, \u0431\u044b\u043b\u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c\u0438. Telegram API \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434, \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0437\u043d\u0430\u043b\u0430 \u043e\u0431 \u044d\u0442\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u043e\u043a\u043e\u043f\u0430\u0432\u0448\u0438\u0441\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Telegram (\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u043a\u043b\u0438\u043d\u0430\u044f \u0414\u0443\u0440\u043e\u0432\u0430 \u0438 \u0432\u0441\u044e \u0435\u0433\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0437\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u0442\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043c\u0435\u043d\u044f\u0435\u0442 API), \u044f \u0441\u043c\u043e\u0433 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u043e\u0434.<\/p>\n<p>\u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u0442\u0430 \u0432 Telegram. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043e\u0431\u0440\u0430\u0442\u0438\u0432\u0448\u0438\u0441\u044c \u043a \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0431\u043e\u0442\u0443 Telegram \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <strong>BotFather<\/strong>.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e47\/de3\/2b2\/e47de32b2a3f4ce80b44113742c8a926.png\" width=\"512\" height=\"288\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e47\/de3\/2b2\/e47de32b2a3f4ce80b44113742c8a926.png\"\/><\/figure>\n<p>BotFather &#8212; \u044d\u0442\u043e <s>\u043a\u0440\u0435\u0441\u0442\u043d\u044b\u0439 \u043e\u0442\u0435\u0446<\/s> \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043e\u0442 Telegram, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u043e\u0442\u0430\u043c\u0438. \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c, \u043d\u0430\u0439\u0434\u0438\u0442\u0435 &#8216;@BotFather&#8217; \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 Telegram \u0438 \u043d\u0430\u0447\u043d\u0438\u0442\u0435 \u0441 \u043d\u0438\u043c \u0447\u0430\u0442. \u0414\u0430\u043b\u0435\u0435:<\/p>\n<p>1. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430: \u043e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 BotFather \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \/newbot. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e BotFather \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442 \u0432\u0430\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0438\u043c\u044f \u0438 \u044e\u0437\u0435\u0440\u043d\u0435\u0439\u043c \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0418\u043c\u044f &#8212; \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0431\u0435\u0441\u0435\u0434\u0430\u0445, \u0430 \u044e\u0437\u0435\u0440\u043d\u0435\u0439\u043c &#8212; \u0442\u043e, \u043a\u0430\u043a \u0432\u0430\u0448 \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0434\u0435\u043d \u0432 Telegram. \u042e\u0437\u0435\u0440\u043d\u0435\u0439\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 &#171;bot&#187;, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &#171;examplebot&#187;.<\/p>\n<p>2. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0442\u043e\u043a\u0435\u043d: \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0432\u044b \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u0431\u043e\u0442\u0443 \u0438\u043c\u044f, BotFather \u0434\u0430\u0441\u0442 \u0435\u0433\u043e \u0442\u043e\u043a\u0435\u043d. \u042d\u0442\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u0430\u0448\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a Telegram Bot API.<\/p>\n<p>3. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0431\u043e\u0442\u0430 (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442): \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e BotFather \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0431\u043e\u0442\u0430, \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0435\u043c \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u042d\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0448 \u0431\u043e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u0431\u043e\u0442\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u0434.<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <em>main.py<\/em> &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0438\u0433\u0440\u044b, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0431\u043e\u0442\u0430:<\/p>\n<pre><code class=\"python\">from bot_config import BotConfig from telegram.ext import Application  def main():\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0# Load our bot configuration \u00a0\u00a0\u00a0config = BotConfig.load_config() \u00a0\u00a0\u00a0application = Application.builder().token(token=config.telegram_token).build()  \u00a0\u00a0\u00a0# Instantiate the bot \u00a0\u00a0\u00a0game = Game(config) \u00a0\u00a0\u00a0game.start(application) \u00a0\u00a0\u00a0print(\"Bot has started\")<\/code><\/pre>\n<p><em>Application<\/em> &#8212; \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 Telegram API, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c Telegram.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0438\u0433\u0440\u044b \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Game:<\/p>\n<pre><code class=\"python\">def start(self, application: Application): \u00a0\u00a0\u00a0self.app = application  \u00a0\u00a0\u00a0# Add command handlers \u00a0\u00a0\u00a0application.add_handler(CommandHandler(\"start\", self.handle_start)) \u00a0\u00a0\u00a0application.add_handler(CommandHandler(\"rules\", self.handle_print_rules)) \u00a0\u00a0\u00a0application.add_handler(MessageHandler(Filters.TEXT &amp; ~Filters.COMMAND, self.handle_message))  \u00a0\u00a0\u00a0# Start the bot \u00a0\u00a0\u00a0application.run_polling(allowed_updates=Update.ALL_TYPES)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0438\u043f\u044b \u043a\u043e\u043c\u0430\u043d\u0434\/\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u0431\u043e\u0442. \u0423 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 3 \u0442\u0438\u043f\u0430: \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <strong>start<\/strong> &#8212; \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0431\u043e\u0442\u0430, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <strong>rules,<\/strong> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438\u0433\u0440\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0438 \u043b\u044e\u0431\u043e\u0439 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0439 <strong>message,<\/strong> \u043e\u0431\u044b\u0447\u043d\u043e \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u0433\u0440\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438\u0433\u0440\u044b \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c sessions.<\/p>\n<pre><code class=\"python\">class Game: \u00a0\u00a0\u00a0def __init__(self, config): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.sessions = {} \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.config = config \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.app = None<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043c\u044b \u0440\u0435\u0448\u0430\u0435\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u043d \u0432\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u043c\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c &#8212; \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0435\u0433\u043e \u0441\u0435\u0441\u0441\u0438\u044e \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 user_data (\u0438\u0437 \u0444\u0430\u0439\u043b\u0430 info.txt), \u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e:<\/p>\n<pre><code class=\"python\">def get_user_session(self, update: Update): \u00a0\u00a0\u00a0user_id = update.message.from_user.id  \u00a0\u00a0\u00a0if user_id not in self.sessions: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user = User(user_id, update.message.from_user.full_name, update.message.from_user.username) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0session = self.load_user_session(user) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.sessions[user_id] = session \u00a0\u00a0\u00a0return self.sessions[user_id]  \u00a0\u00a0 def load_user_session(self, user): \u00a0\u00a0\u00a0user_folder = f'user_data\/{user.telegram_name}' \u00a0\u00a0\u00a0if not os.path.exists(user_folder): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0os.makedirs(user_folder)  \u00a0\u00a0\u00a0info_path = os.path.join(user_folder, 'info.txt')  \u00a0\u00a0\u00a0if not os.path.exists(info_path): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.image_submitted = '' \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.attempts_left = self.config.max_attempts \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return GameSession(user, self.config)  \u00a0\u00a0\u00a0with open(info_path, 'r') as info_file: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.readline() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.readline() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.readline() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.image_submitted = info_file.readline().split(':')[1].strip() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.attempts_left = int(info_file.readline().split(':')[1].strip()) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.last_prompt = info_file.readline().split(':')[1].strip() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.position = info_file.readline().split(':')[1].strip() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.company = info_file.readline().split(':')[1].strip()  \u00a0\u00a0\u00a0session = GameSession(user, self.config) \u00a0\u00a0\u00a0return session<\/code><\/pre>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434:<\/p>\n<pre><code class=\"python\">async def handle_start(self, update: Update, context: CallbackContext): \u00a0\u00a0\u00a0if update.message.from_user is None: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return  \u00a0\u00a0\u00a0session = self.get_user_session(update) \u00a0\u00a0\u00a0await session.start(update, context)      async def handle_message(self, update: Update, context: CallbackContext): \u00a0\u00a0\u00a0session = self.get_user_session(update) \u00a0\u00a0\u00a0await session.handle_message(update, context)    async def handle_print_rules(self, update: Update, context: CallbackContext): \u00a0\u00a0\u00a0session = self.get_user_session(update) \u00a0\u00a0\u00a0await session.handle_print_rules(update, context)<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u043c\u044b \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u043a\u043b\u0430\u0441\u0441\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0435\u0441\u0441\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e. \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 GameSession, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430:<\/p>\n<pre><code class=\"python\">class GameSession: \u00a0\u00a0\u00a0STATE_NOT_STARTED = 'not_started' \u00a0\u00a0\u00a0STATE_WAITING_FOR_POSITION = 'waiting_for_position' \u00a0\u00a0\u00a0STATE_WAITING_FOR_COMPANY = 'waiting_for_company' \u00a0\u00a0\u00a0STATE_WAITING_FOR_PROMPT = 'waiting_for_prompt' \u00a0\u00a0\u00a0STATE_WAITING_FOR_CONFIRMATION = 'waiting_for_confirmation'      \u00a0\u00a0\u00a0def __init__(self, user, config, is_running = False): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.config = config \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.user = user \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.dalle_service = DalleService(config.openai_api_key) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.last_image = None \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.attempts_left = user.attempts_left \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.state = self.STATE_NOT_STARTED if not is_running else self.STATE_WAITING_FOR_PROMPT<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0443 \u0438\u0433\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u0442\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041e\u043d\u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u0435\u043b. \u0412 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0433\u0440\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438\u0433\u0440\u044b \u0438 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\">async def start(self, update: Update, context: CallbackContext): \u00a0\u00a0\u00a0if self.state != self.STATE_NOT_STARTED: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (self.attempts_left > 0): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"Game is already running. Please enter a prompt for the image:\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"You have no attempts left. Please come back tomorrow.\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return  \u00a0\u00a0\u00a0self.state = self.STATE_WAITING_FOR_PROMPT \u00a0\u00a0\u00a0await update.message.reply_text(_(\"Welcome to the 'Culture Code' game! Here are the rules...\")) \u00a0\u00a0\u00a0await update.message.reply_text(_(\"Game Rules\"))      \u00a0\u00a0\u00a0# Send the predefined image \u00a0\u00a0\u00a0with self.get_predefined_image() as image: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_photo(photo=image)  \u00a0\u00a0\u00a0await update.message.reply_text(_(\"Please enter a prompt for the image:\"))<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d message handler. \u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e OpenAI Dall-e API, \u0447\u0442\u043e\u0431\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0438\u0433\u0440\u0430 \u0441\u043f\u0440\u043e\u0441\u0438\u0442, \u0445\u043e\u0447\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0443\u0434\u044c\u044f\u043c \u0438\u043b\u0438 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0435\u0449\u0435 \u0440\u0430\u0437 (\u0435\u0441\u043b\u0438 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u043f\u044b\u0442\u043a\u0438):<\/p>\n<pre><code class=\"python\">async def handle_message(self, update: Update, context: CallbackContext): \u00a0if self.state == self.STATE_WAITING_FOR_PROMPT: \u00a0\u00a0\u00a0\u00a0\u00a0# Check if the user has already submitted an image today and have attempts \u00a0\u00a0\u00a0\u00a0\u00a0if self.user.image_submitted: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"You have already submitted a result today. Please come back tomorrow.\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0if not self.has_attempts_left(): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"You have no attempts left. Please come back tomorrow.\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return\u00a0  \u00a0\u00a0\u00a0\u00a0\u00a0prompt = update.message.text      \u00a0\u00a0\u00a0\u00a0\u00a0# Generate image from DALLE-3 \u00a0\u00a0\u00a0\u00a0\u00a0try: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"Generating image...\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.last_image = self.dalle_service.generate_image(prompt) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.user.last_prompt = prompt \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_photo(photo=self.last_image.image_data)  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.state = self.STATE_WAITING_FOR_CONFIRMATION \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (self.attempts_left == 1): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"This is your last attempt. Do you want to submit this image for validation? (yes\/no)\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0elif (self.attempts_left == 2): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"You have 2 attempts left. Do you want to submit this image for validation? (yes\/no)\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"Do you want to submit this image for validation? (yes\/no)\")) \u00a0\u00a0\u00a0\u00a0\u00a0except Exception as e: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(str(e)) \u00a0elif self.state == self.STATE_WAITING_FOR_CONFIRMATION: \u00a0\u00a0\u00a0\u00a0\u00a0if update.message.text.lower() == 'yes': \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if self.submit_attempt(self.last_image): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"Congratulations, the image was submitted!\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if not self.user.position: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"Btw, what is your position in your company?\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.state = self.STATE_WAITING_FOR_POSITION \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"Something went wrong! Please enter another prompt:\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.state = self.STATE_WAITING_FOR_PROMPT \u00a0\u00a0\u00a0\u00a0\u00a0elif update.message.text.lower() == 'no': \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.attempts_left -= 1 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.save_user_info() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if self.has_attempts_left(): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"Allright. Attempts left: \") + str(self.attempts_left) + \". \" + _(\"Please enter another prompt:\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"You have no attempts left. Please come back tomorrow.\")) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.state = self.STATE_WAITING_FOR_PROMPT \u00a0\u00a0\u00a0\u00a0\u00a0else: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"Please answer with 'yes' or 'no'\")) \u00a0elif self.state == self.STATE_WAITING_FOR_POSITION: \u00a0\u00a0\u00a0\u00a0\u00a0self.user.position = update.message.text[:100] \u00a0\u00a0\u00a0\u00a0\u00a0self.save_user_info() \u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"How interesting! And what is the name of your company?\")) \u00a0\u00a0\u00a0\u00a0\u00a0self.state = self.STATE_WAITING_FOR_COMPANY \u00a0elif self.state == self.STATE_WAITING_FOR_COMPANY: \u00a0\u00a0\u00a0\u00a0\u00a0self.user.company = update.message.text[:100] \u00a0\u00a0\u00a0\u00a0\u00a0self.save_user_info() \u00a0\u00a0\u00a0\u00a0\u00a0await update.message.reply_text(_(\"Understood. We will validate your image and send you the results soon. Thank you for participating! Please come back tomorrow \\xF0\\x9F\\x98\\x89.\")) \u00a0\u00a0\u00a0\u00a0\u00a0self.state = self.STATE_WAITING_FOR_PROMPT<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0435\u0448\u0430\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 &#8212; \u0438\u0433\u0440\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0446\u0435\u043d\u043a\u0438 \u0436\u044e\u0440\u0438:<\/p>\n<pre><code class=\"python\">def submit_attempt(self, image): \u00a0\u00a0\u00a0if self.attempts_left > 0 and not image is None and not self.user.image_submitted: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.attempts_left = 0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.save_user_image(image) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.user.image_submitted = image.image_name \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.save_user_info() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return True \u00a0\u00a0\u00a0return False  def save_user_image(self, image): \u00a0\u00a0\u00a0user_folder = f'user_data\/{self.user.telegram_name}' \u00a0\u00a0\u00a0if not os.path.exists(user_folder): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0os.makedirs(user_folder)  \u00a0\u00a0\u00a0image_path = os.path.join(user_folder, f'{len(os.listdir(user_folder)) + 1}.jpg') \u00a0\u00a0\u00a0with open(image_path, 'wb') as image_file: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0image_file.write(image.image_data)  \u00a0\u00a0\u00a0return image_path  def save_user_info(self): \u00a0\u00a0\u00a0user_folder = f'user_data\/{self.user.telegram_name}' \u00a0\u00a0\u00a0if not os.path.exists(user_folder): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0os.makedirs(user_folder)  \u00a0\u00a0\u00a0info_path = os.path.join(user_folder, 'info.txt') \u00a0\u00a0\u00a0with open(info_path, 'w') as info_file: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.write(f\"Name: {self.user.user_name}\\n\") \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.write(f\"Id: {self.user.user_id}\\n\") \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.write(f\"Telegram account: {self.user.telegram_name}\\n\") \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.write(f\"Image submitted: {self.user.image_submitted}\\n\") \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.write(f\"Attempts left: {self.attempts_left}\\n\")\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.write(f\"Last prompt: {self.user.last_prompt}\\n\") \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.write(f\"Position: {self.user.position}\\n\")\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.write(f\"Company: {self.user.company}\\n\")\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><\/pre>\n<p>\u0412\u043e\u0442, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0438\u0433\u0440\u044b! \u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 API \u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<h3>\u0422\u0435\u043f\u0435\u0440\u044c \u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u0434\u0430 \u0438 \u043c\u043e\u0438\u0445 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u044f\u0445:<\/h3>\n<p>\u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u0437\u0434\u043e\u0445\u043d\u0443\u0442\u044c \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e &#8212; \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 AI \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d, \u0438 \u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0447\u0438\u043d:<\/p>\n<ol>\n<li>\n<p>API \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0447\u0435\u043c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0434\u043e\u043e\u0431\u0443\u0447\u0430\u0442\u044c \u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u044e\u0442. \u0421\u043e\u043e\u0442\u0432\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u043e\u0434\u0435\u043b\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0439 \u043a\u043e\u0434, \u0438, \u0447\u0442\u043e \u0435\u0449\u0435 \u0445\u0443\u0436\u0435, \u0441\u043c\u0435\u0441\u044c \u0438\u0437 \u043a\u043e\u0434\u0430 \u0440\u0430\u0437\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0438\u0440\u0443\u0435\u0442 &#8212; \u0434\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0443\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 &#8212; \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443: \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043b\u0430\u0441\u0441\u044b-\u043f\u0443\u0441\u0442\u044b\u0448\u043a\u0438, \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0442\u043f.<\/p>\n<\/li>\n<li>\n<p>\u0421 \u0440\u043e\u0441\u0442\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 &#8212; \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u0435\u043b\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043c\u044b \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u044e\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0441\u0442\u0438\u043b\u0438\u0441\u0442\u0438\u043a\u0438 \u0438 styleguides: \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u0438\u043f\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u043a\u0441\u0435\u043f\u0448\u0435\u043d\u044b \u0438 \u0442\u043f.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u043e\u043f\u043e\u0431\u043e\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442: \u043c\u043e\u0434\u0435\u043b\u044c <strong>\u0432\u0440\u0435\u0442<\/strong><\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/53a\/834\/6f3\/53a8346f366872e372b4fa64f10d9af2.png\" alt=\"\u0414\u043e\u043a\u0442\u043e\u0440 \u0425\u0430\u0443\u0441 \u0431\u044b\u043b \u043f\u0440\u0430\u0432\u2026\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e human\u00a0\" title=\"\u0414\u043e\u043a\u0442\u043e\u0440 \u0425\u0430\u0443\u0441 \u0431\u044b\u043b \u043f\u0440\u0430\u0432\u2026\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e human\u00a0\" width=\"1213\" height=\"689\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/53a\/834\/6f3\/53a8346f366872e372b4fa64f10d9af2.png\"\/><\/p>\n<div><figcaption>\u0414\u043e\u043a\u0442\u043e\u0440 \u0425\u0430\u0443\u0441 \u0431\u044b\u043b \u043f\u0440\u0430\u0432\u2026\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e human\u00a0<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u043c\u0430\u043d\u0443\u043b\u0430 \u043c\u0435\u043d\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0441\u043a\u0430\u0437\u0430\u0432 \u0442\u043e, \u0447\u0442\u043e \u044f \u0445\u043e\u0442\u0435\u043b \u0443\u0441\u043b\u044b\u0448\u0430\u0442\u044c, \u0430 \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u0439! \u0422\u0443\u0442 \u044f \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0432 \u043c\u043e\u044e \u0431\u044b\u0442\u043d\u043e\u0441\u0442\u044c \u043b\u0438\u0434\u043e\u043c&#8230; \u0412 \u043e\u0431\u0449\u0435\u043c, \u0441\u043e\u0432\u0441\u0435\u043c \u043a\u0430\u043a \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0421\u043a\u043e\u0440\u043e \u043d\u0430\u0447\u043d\u0451\u0442 \u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0433\u0440\u0435\u0439\u0434 \u043f\u043e\u0432\u044b\u0448\u0435 \u0438 \u0441\u043c\u0443\u0437\u0438&#8230;<\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u0431\u0443\u0434\u044c\u0442\u0435 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u044b. \u042d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e GPT Engineer, \u0430 Chat GPT, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0434\u043b\u044f \u0434\u043e\u0434\u0435\u043b\u043e\u043a.<\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0441 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 AI \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u043e. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u0437\u0430\u043c\u0443\u0434\u0440\u0451\u043d\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043d\u043e \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0448\u0430\u043b \u0431\u044b. \u041f\u0440\u043e\u0441\u0442\u043e\u0435, \u0432 \u043b\u043e\u0431 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u0438 \u0434\u0430\u0436\u0435 \u0441\u0442\u0438\u043b\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 (\u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438). \u0422\u0430\u043a\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u043b\u0435\u043a\u043e \u043b\u0438\u0448\u044c \u043d\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0436\u0443\u043d, \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0438\u0437 \u043d\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d (\u0441). \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0435\u0433\u043e \u0433\u043e\u0434 \u043d\u0430\u0437\u0430\u0434 &#8212; <strong>\u0442\u0443\u0442 \u0435\u0441\u0442\u044c \u043d\u0430\u0434 \u0447\u0435\u043c \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f<\/strong>.<\/p>\n<p>\u041a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0437\u0434\u0435\u0441\u044c: <a href=\"https:\/\/github.com\/vsemogutor\/culture_code_pulbic\"><u>https:\/\/github.com\/vsemogutor\/culture_code_pulbic<\/u><\/a><\/p>\n<p>Have fun!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/780166\/\"> https:\/\/habr.com\/ru\/articles\/780166\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\">\n<div><figcaption>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e AI, \u043d\u0438 \u043e\u0434\u0438\u043d \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043d\u0435 \u043f\u043e\u0441\u0442\u0440\u0430\u0434\u0430\u043b<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0430\u0440\u0443 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0439 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 Highload, \u0438 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0447\u0442\u043e-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0438 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0432\u043b\u0435\u0447\u044c \u043b\u044e\u0434\u0435\u0439 \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0441\u0442\u0435\u043d\u0434\u0443. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0437\u0434\u0443\u043c\u0438\u0439 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 <strong>\u0447\u0430\u0442-\u0431\u043e\u0442\u0430.<\/strong> \u041d\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e: \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0435\u0433\u043e \u0446\u0435\u043b\u044c &#8212; \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0432 \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0411\u043e\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 AI, \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u043c\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u043b \u044d\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430?<\/p>\n<p>\u0421\u0440\u043e\u043a\u0438 \u043f\u043e\u0434\u0436\u0438\u043c\u0430\u043b\u0438, \u0434\u043e \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u0434\u043d\u044f, \u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u043d\u044f\u0442\u044b, \u044f \u0432\u044b\u0437\u0432\u0430\u043b\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c\u00a0 Telegram \u0431\u043e\u0442\u0430. \u0427\u0435\u0441\u0442\u043d\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u044c\u0441\u044f, \u0442\u0430\u043a\u043e\u0439 \u043e\u043f\u044b\u0442 \u0431\u044b\u043b \u0443 \u043c\u0435\u043d\u044f \u0432\u043f\u0435\u0440\u0432\u044b\u0435, \u043d\u043e \u044f \u0432\u0435\u0440\u0438\u043b \u0432 \u0441\u0438\u043b\u0443 \u0432\u0441\u0435\u043c\u043e\u0433\u0443\u0449\u0435\u0433\u043e \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0430, \u0438 \u043f\u0440\u0438\u043d\u044f\u043b\u0441\u044f \u0437\u0430 \u0434\u0435\u043b\u043e! \u00a0<\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c, <a href=\"https:\/\/github.com\/AntonOsika\/gpt-engineer\"><u>GPT Engineer<\/u><\/a> &#8212; \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u0441\u0445\u043e\u0436\u0438\u0439 \u0441 Auto-GPT. \u041e\u043d \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0446\u0435\u043b\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043b\u0438\u0448\u044c \u043d\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438. \u041f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0442\u0430\u043a\u043e\u0432\u0430 \u0442\u0435\u043e\u0440\u0438\u044f. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0432\u0441\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435: \u0434\u0430, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e &#8212; \u0443\u0436\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f. \u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u0430\u043c, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0435. \u041e\u0431 \u044d\u0442\u043e\u043c, \u0438 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0441\u043a\u043e\u0440\u043e AI \u0437\u0430\u043c\u0435\u043d\u0438\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 &#8212; \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c GPT Engineer, \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/AntonOsika\/gpt-engineer\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 <\/u><\/a>\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e, \u0441\u043b\u0435\u0434\u0443\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c \u0432 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u043c \u0444\u0430\u0439\u043b\u0435 README. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043d\u0430 Python, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442. \u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u043e, \u043e\u043f\u0438\u0448\u0438\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 &#8216;main_prompt&#8217;, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 projects. \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0438 \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u043f\u043e\u043a\u0430 \u043e\u043d \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438 \u0441\u0442\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e API OpenAI (\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432\u0435\u0440\u0441\u0438\u044e 4), \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438. \u0412\u043e\u0442 \u043c\u043e\u0439 \u0433\u0435\u043d\u0438\u0430\u043b\u044c\u043d\u044b\u0439 <strong>\u043f\u0440\u043e\u043c\u0442<\/strong>:<\/p>\n<details class=\"spoiler\">\n<summary>Bot design prompt<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>Overview<\/strong><\/p>\n<p>This document outlines the design for a game where players guess the textual prompts used to generate images by DALLE-3. The game will be implemented using the OpenAI API, Python programming language, and Telegram API. It is a guessing game where players are shown an image generated by DALLE-3 and must guess the prompt used to create it.<\/p>\n<p><strong>Game Flow<\/strong><br \/>Start: The player starts the game through a Telegram bot.<br \/>Image Presentation: A DALLE-3 generated image is presented to the player.<br \/>Guessing Phase: The player has 3 attempts to guess the prompt.<br \/>Submission: After 3 attempts, the player submits their final guess.<br \/>Data Storage: The game stores the player\u2019s guess and other relevant data.<\/p>\n<p><strong>Technical Components<\/strong><\/p>\n<p>OpenAI API<\/p>\n<p>Purpose: To generate images based on textual prompts.<br \/>Integration: Python scripts will interact with the OpenAI API to request image generation.<\/p>\n<p>Python Backend<\/p>\n<p>Functionality:<br \/>Communicate with the OpenAI API.<br \/>Handle Telegram bot interactions.<br \/>Manage game logic and state.<br \/>Store and retrieve data.<\/p>\n<p>Libraries:<br \/>python-telegram-bot: For Telegram bot interactions.<br \/>requests: For making API calls to OpenAI.<br \/>os, json: For file handling and configuration management.<\/p>\n<p>Telegram API<br \/>Purpose: To provide a platform for users to play the game.<br \/>Integration:<br \/>The game will be accessible through a Telegram bot.<br \/>The bot will handle user inputs and display images and messages.<\/p>\n<p>Game Logic<br \/>Starting Image:<br \/>Read an image name from the config file, load it from the root folder.<br \/>User Interaction:<br \/>Present the image to the user via Telegram bot. <br \/>Receive guesses from the user.<br \/>After each guess &#8212; use OpenAI API to generate an image from that prompt and <br \/>show this image to the user.<br \/>Allow up to 3 attempts per image.<br \/>Data Handling:<br \/>After 3 attempts or final submission, save the user\u2019s guess.<br \/>Store the image, prompt, user\u2019s guess, Telegram username, and account info.<\/p>\n<p>Data Storage<br \/>Location: user_data folder in the bot\u2019s root directory.<br \/>Structure:<br \/>Subfolders named after the user\u2019s Telegram username.<br \/>Filder contains info.txt file with all user data and an image generated by the user.<\/p>\n<p>Configuration File<br \/>File Name: bot_config.json<br \/>Contents:<br \/>API keys.<br \/>Game settings (e.g., time limits, number of attempts).<br \/>Other configurable parameters.  <\/p>\n<p>Internationalization<br \/>gettext should be used for all text messages<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u043b\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c &#8212; \u0431\u0435\u0437\u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0431\u0443\u0447\u0430\u043b\u0441\u044f OpenAI, \u0431\u044b\u043b\u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c\u0438. Telegram API \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434, \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0437\u043d\u0430\u043b\u0430 \u043e\u0431 \u044d\u0442\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u043e\u043a\u043e\u043f\u0430\u0432\u0448\u0438\u0441\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Telegram (\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u043a\u043b\u0438\u043d\u0430\u044f \u0414\u0443\u0440\u043e\u0432\u0430 \u0438 \u0432\u0441\u044e \u0435\u0433\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0437\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u0442\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043c\u0435\u043d\u044f\u0435\u0442 API), \u044f \u0441\u043c\u043e\u0433 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u043e\u0434.<\/p>\n<p>\u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u0442\u0430 \u0432 Telegram. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043e\u0431\u0440\u0430\u0442\u0438\u0432\u0448\u0438\u0441\u044c \u043a \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0431\u043e\u0442\u0443 Telegram \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <strong>BotFather<\/strong>.<\/p>\n<figure class=\"\"><\/figure>\n<p>BotFather &#8212; \u044d\u0442\u043e <s>\u043a\u0440\u0435\u0441\u0442\u043d\u044b\u0439 \u043e\u0442\u0435\u0446<\/s> \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043e\u0442 Telegram, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u043e\u0442\u0430\u043c\u0438. \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c, \u043d\u0430\u0439\u0434\u0438\u0442\u0435 &#8216;@BotFather&#8217; \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 Telegram \u0438 \u043d\u0430\u0447\u043d\u0438\u0442\u0435 \u0441 \u043d\u0438\u043c \u0447\u0430\u0442. \u0414\u0430\u043b\u0435\u0435:<\/p>\n<p>1. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430: \u043e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 BotFather \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \/newbot. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e BotFather \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442 \u0432\u0430\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0438\u043c\u044f \u0438 \u044e\u0437\u0435\u0440\u043d\u0435\u0439\u043c \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0418\u043c\u044f &#8212; \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0431\u0435\u0441\u0435\u0434\u0430\u0445, \u0430 \u044e\u0437\u0435\u0440\u043d\u0435\u0439\u043c &#8212; \u0442\u043e, \u043a\u0430\u043a \u0432\u0430\u0448 \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0434\u0435\u043d \u0432 Telegram. \u042e\u0437\u0435\u0440\u043d\u0435\u0439\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 &#171;bot&#187;, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &#171;examplebot&#187;.<\/p>\n<p>2. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0442\u043e\u043a\u0435\u043d: \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0432\u044b \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u0431\u043e\u0442\u0443 \u0438\u043c\u044f, BotFather \u0434\u0430\u0441\u0442 \u0435\u0433\u043e \u0442\u043e\u043a\u0435\u043d. \u042d\u0442\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u0430\u0448\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a Telegram Bot API.<\/p>\n<p>3. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0431\u043e\u0442\u0430 (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442): \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e BotFather \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0431\u043e\u0442\u0430, \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0435\u043c \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u042d\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0448 \u0431\u043e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u0431\u043e\u0442\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u0434.<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <em>main.py<\/em> &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0438\u0433\u0440\u044b, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0431\u043e\u0442\u0430:<\/p>\n<pre><code class=\"python\">from bot_config import BotConfig from telegram.ext import Application  def main():\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0# Load our bot configuration \u00a0\u00a0\u00a0config = BotConfig.load_config() \u00a0\u00a0\u00a0application = Application.builder().token(token=config.telegram_token).build()  \u00a0\u00a0\u00a0# Instantiate the bot \u00a0\u00a0\u00a0game = Game(config) \u00a0\u00a0\u00a0game.start(application) \u00a0\u00a0\u00a0print(\"Bot has started\")<\/code><\/pre>\n<p><em>Application<\/em> &#8212; \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 Telegram API, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c Telegram.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0438\u0433\u0440\u044b \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Game:<\/p>\n<pre><code class=\"python\">def start(self, application: Application): \u00a0\u00a0\u00a0self.app = application  \u00a0\u00a0\u00a0# Add command handlers \u00a0\u00a0\u00a0application.add_handler(CommandHandler(\"start\", self.handle_start)) \u00a0\u00a0\u00a0application.add_handler(CommandHandler(\"rules\", self.handle_print_rules)) \u00a0\u00a0\u00a0application.add_handler(MessageHandler(Filters.TEXT &amp; ~Filters.COMMAND, self.handle_message))  \u00a0\u00a0\u00a0# Start the bot \u00a0\u00a0\u00a0application.run_polling(allowed_updates=Update.ALL_TYPES)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0438\u043f\u044b \u043a\u043e\u043c\u0430\u043d\u0434\/\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u0431\u043e\u0442. \u0423 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 3 \u0442\u0438\u043f\u0430: \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <strong>start<\/strong> &#8212; \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0431\u043e\u0442\u0430, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <strong>rules,<\/strong> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438\u0433\u0440\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0438 \u043b\u044e\u0431\u043e\u0439 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0439 <strong>message,<\/strong> \u043e\u0431\u044b\u0447\u043d\u043e \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u0433\u0440\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438\u0433\u0440\u044b \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c sessions.<\/p>\n<pre><code class=\"python\">class Game: \u00a0\u00a0\u00a0def __init__(self, config): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.sessions = {} \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.config = config \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.app = None<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043c\u044b \u0440\u0435\u0448\u0430\u0435\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u043d \u0432\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u043c\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c &#8212; \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0435\u0433\u043e \u0441\u0435\u0441\u0441\u0438\u044e \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 user_data (\u0438\u0437 \u0444\u0430\u0439\u043b\u0430 info.txt), \u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e:<\/p>\n<pre><code class=\"python\">def get_user_session(self, update: Update): \u00a0\u00a0\u00a0user_id = update.message.from_user.id  \u00a0\u00a0\u00a0if user_id not in self.sessions: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user = User(user_id, update.message.from_user.full_name, update.message.from_user.username) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0session = self.load_user_session(user) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.sessions[user_id] = session \u00a0\u00a0\u00a0return self.sessions[user_id]  \u00a0\u00a0 def load_user_session(self, user): \u00a0\u00a0\u00a0user_folder = f'user_data\/{user.telegram_name}' \u00a0\u00a0\u00a0if not os.path.exists(user_folder): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0os.makedirs(user_folder)  \u00a0\u00a0\u00a0info_path = os.path.join(user_folder, 'info.txt')  \u00a0\u00a0\u00a0if not os.path.exists(info_path): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.image_submitted = '' \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.attempts_left = self.config.max_attempts \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return GameSession(user, self.config)  \u00a0\u00a0\u00a0with open(info_path, 'r') as info_file: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.readline() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.readline() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info_file.readline() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.image_submitted = info_file.readline().split(':')[1].strip() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.attempts_left = int(info_file.readline().split(':')[1].strip()) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.last_prompt = info_file.readline().split(':')[1].strip() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.position = info_file.readline().split(':')[1].strip() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user.company = info_file.readline().split(':')[1].strip()  \u00a0\u00a0\u00a0session = GameSession(user, self.config) \u00a0\u00a0\u00a0return session<\/code><\/pre>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434:<\/p>\n<pre><code class=\"python\">async def handle_start(self, update: Update, context: CallbackContext): \u00a0\u00a0\u00a0if update.message.from_user is None: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return  \u00a0\u00a0\u00a0session = self.get_user_session(update) \u00a0\u00a0\u00a0await session.start(update, context)      async def handle_message(self, update: Update, context: CallbackContext): \u00a0\u00a0\u00a0session = self.get_user_session(update) \u00a0\u00a0\u00a0await session.handle_message(update, context)    async def handle_print_rules(self, update: Update, context: CallbackContext): \u00a0\u00a0\u00a0session = self.get_user_session(update) \u00a0\u00a0\u00a0await session.handle_print_rules(update, context)<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u043c\u044b \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u043a\u043b\u0430\u0441\u0441\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0435\u0441\u0441\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e. \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 GameSession, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430:<\/p>\n<pre><code class=\"python\">class GameSession: \u00a0\u00a0\u00a0STATE_NOT_STARTED = 'not_started'<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-362754","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/362754","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=362754"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/362754\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=362754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=362754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=362754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}