{"id":498156,"date":"2026-10-11T10:20:54","date_gmt":"2026-10-11T07:20:54","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=498156"},"modified":"2026-10-11T10:20:54","modified_gmt":"2026-10-11T07:20:54","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=498156","title":{"rendered":"\u041a\u0430\u043a \u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b Telegram-\u0431\u043e\u0442\u0430 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u0442\u043e\u0432 \u043d\u0430 <code>python-telegram-bot<\/code>: \u043a\u043e\u043c\u0430\u043d\u0434\u044b, inline-\u043a\u043d\u043e\u043f\u043a\u0438, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438. \u0417\u0430\u0442\u0435\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0441\u044f \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>\u041f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 HTTP API \u043e\u0437\u043d\u0430\u0447\u0430\u043b\u043e \u0431\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f. \u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c Telegram Web App \u0442\u043e\u0436\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b\u043e: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0431\u0435\u0437 Telegram.<\/p>\n<p>\u042f \u043f\u043e\u0448\u0451\u043b \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0451\u043c: \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043f\u0440\u0438\u0442\u0432\u043e\u0440\u044f\u0435\u0442\u0441\u044f Telegram \u043d\u0430 \u0432\u0445\u043e\u0434\u0435, \u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 transport-\u0441\u043b\u043e\u0439 \u2014 Telegram Bot API \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b <code>Update<\/code> \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0448\u0442\u0430\u0442\u043d\u044b\u0439 <code>Application.process_update()<\/code>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f, \u043d\u0430 \u043a\u0430\u043a\u0438\u0445 \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u043e\u043d \u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0438 \u0447\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/27\/ac\/ad\/27acad646c629450ad90d5b306dba0e6.png\" alt=\"\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 PTB-\u0431\u043e\u0442 \u0432 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435\" width=\"1280\" height=\"900\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/27\/ac\/ad\/27acad646c629450ad90d5b306dba0e6.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/27\/ac\/ad\/27acad646c629450ad90d5b306dba0e6.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 PTB-\u0431\u043e\u0442 \u0432 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435<\/figcaption><\/div>\n<\/figure>\n<p><em>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440; Telegram \u0432 \u044d\u0442\u043e\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442.<\/em><\/p>\n<h3>\u0427\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c<\/h3>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0431\u043e\u0442 \u0443\u0436\u0435 \u0443\u043c\u0435\u043b:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c inline-\u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 <code>CallbackQuery<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0432\u043e\u0435\u0439 \u0431\u0430\u0437\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0431\u044b\u043b \u0442\u0430\u043a\u0438\u043c: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f. \u0412\u0435\u0431-\u0441\u043b\u043e\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043e\u043c, \u0430 \u043d\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439.<\/p>\n<p>\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0432\u0435\u0431-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 <code>start()<\/code>, <code>choose_language()<\/code> \u0438 <code>confirm()<\/code>, \u0434\u0432\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0439\u0434\u0443\u0442\u0441\u044f. \u041e\u0448\u0438\u0431\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0435 \u0441\u0440\u0430\u0437\u0443, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f.<\/p>\n<h3>\u0413\u0434\u0435 \u0432\u043e\u0439\u0442\u0438 \u0432 python-telegram-bot<\/h3>\n<p>\u0423 <code>python-telegram-bot<\/code> \u0435\u0441\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u2014 <code>Application.process_update()<\/code>. \u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0434\u0438\u043d <code>Update<\/code>, \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 handlers \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f error handlers.<\/p>\n<p>\u0417\u043d\u0430\u0447\u0438\u0442, \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c JSON \u0442\u043e\u0439 \u0436\u0435 \u0444\u043e\u0440\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u0438\u0441\u043b\u0430\u043b \u0431\u044b Telegram, \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0447\u0435\u0440\u0435\u0437 <a href=\"http:\/\/Update.de\" rel=\"noopener nofollow\"><code>Update.de<\/code><\/a><code>_json()<\/code>:<\/p>\n<pre><code class=\"python\">update_data = {    \"update_id\": self._next_update,    \"message\": {        \"message_id\": self._next_message,        \"date\": int(datetime.now(timezone.utc).timestamp()),        \"chat\": {\"id\": user_id, \"type\": \"private\"},        \"from\": {            \"id\": user_id,            \"is_bot\": False,            \"first_name\": \"Web\",        },        \"text\": text,    },}update = Update.de_json(update_data, application.bot)await application.process_update(update)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper\"><\/span><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u044e entity \u0442\u0438\u043f\u0430 <code>bot_command<\/code>. \u0414\u043b\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 <code>callback_query<\/code> \u0441 \u0442\u0435\u043c \u0436\u0435 <code>callback_data<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0431\u043e\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u0432 <code>InlineKeyboardButton<\/code>.<\/p>\n<pre><code class=\"python\">update_data = {    \"update_id\": self._next_update,    \"callback_query\": {        \"id\": str(uuid4()),        \"from\": user,        \"chat_instance\": str(user_id),        \"data\": str(payload[\"value\"]),        \"message\": message,    },}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 Telegram update. <code>CommandHandler<\/code>, <code>MessageHandler<\/code> \u0438 <code>CallbackQueryHandler<\/code> \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u0432\u0435\u0431-\u0432\u0435\u0442\u043e\u043a \u0432\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<h3>\u0412\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0438: \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b<\/h3>\n<p>\u041e\u0434\u043d\u043e\u0433\u043e <code>process_update()<\/code> \u043c\u0430\u043b\u043e. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043e\u0447\u0442\u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 <code>reply_text()<\/code>, <code>edit_message_text()<\/code> \u0438\u043b\u0438 <code>send_photo()<\/code>. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e PTB \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 Bot API.<\/p>\n<p>\u0412 \u043c\u043e\u0451\u043c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"http:\/\/HTTPXRequest.do\" rel=\"noopener nofollow\"><code>HTTPXRequest.do<\/code><\/a><code>_request<\/code> \u2014 \u0442\u043e\u0447\u043a\u0430, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u0431\u043e\u0442\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b <code>Bot<\/code> \u0443\u0445\u043e\u0434\u044f\u0442 \u0432 \u0441\u0435\u0442\u044c:<\/p>\n<pre><code class=\"python\">def install_bot_api() -&gt; None:    HTTPXRequest.do_request = _bot_api_requestasync def _bot_api_request(self, url, method, request_data=None, **kwargs):    action = urlsplit(url).path.rsplit(\"\/\", 1)[-1].lower()    if action == \"getme\":        return ok({            \"id\": 123456,            \"is_bot\": True,            \"first_name\": \"Web Bot\",            \"username\": \"local_web_bot\",        })    session = active_session.get()    if session is None:        raise RuntimeError(            f\"Bot API {action} outside an active web conversation is disabled\"        )    if action in {\"sendmessage\", \"sendphoto\", \"senddocument\"}:        return ok(session.send(action, request_data.parameters, request_data))    if action in {        \"editmessagetext\",        \"editmessagecaption\",        \"editmessagereplymarkup\",    }:        return ok(session.edit(action, request_data.parameters))    raise RuntimeError(f\"Bot API method {action} is not implemented\")<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>Transport \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c Bot API. \u041e\u043d \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u043c \u0431\u043e\u0442\u0430\u043c, \u0430 \u043d\u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u044f\u0432\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439. \u042d\u0442\u043e \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043c\u043e\u043b\u0447\u0430 \u043f\u0440\u043e\u0433\u043b\u043e\u0442\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u0435\u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/98\/8f\/37\/988f379446179bfbf736e8839592fcd8.png\" alt=\"\u041f\u043e\u0442\u043e\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 PTB-\u0431\u043e\u0442\" width=\"1600\" height=\"900\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/98\/8f\/37\/988f379446179bfbf736e8839592fcd8.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/98\/8f\/37\/988f379446179bfbf736e8839592fcd8.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0442\u043e\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 PTB-\u0431\u043e\u0442<\/figcaption><\/div>\n<\/figure>\n<p><em>\u0412\u0445\u043e\u0434 \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 <\/em><code><em>Update<\/em><\/code><em>, \u0432\u044b\u0445\u043e\u0434 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 HTTP-\u0433\u0440\u0430\u043d\u0438\u0446\u0435 PTB.<\/em><\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u0437\u0434\u0435\u0441\u044c ContextVar<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441: \u0432 \u043a\u0430\u043a\u0443\u044e \u0432\u0435\u0431-\u0441\u0435\u0441\u0441\u0438\u044e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442? \u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0434\u043e \u0434\u0432\u0443\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <code>ContextVar<\/code>:<\/p>\n<pre><code class=\"python\">_active: ContextVar[PTBSession | None] = ContextVar(    \"telegram_web_session\",    default=None,)marker = _active.set(self)try:    await application.process_update(update)finally:    _active.reset(marker)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043e \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443. \u041a\u043e\u0433\u0434\u0430 handler \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 Bot API, transport \u0434\u043e\u0441\u0442\u0430\u0451\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0443 <code>PTBSession<\/code>, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u0448\u043b\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435.<\/p>\n<p>\u0423 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c <code>asyncio.Lock<\/code>. \u041e\u043d \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u0438\u0430\u043b\u043e\u0433\u0430: \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u043a\u043b\u0438\u043a \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 state machine \u0447\u0435\u0440\u0435\u0437 \u0434\u0432\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430.<\/p>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u0431\u043e\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c. \u0415\u0441\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0444\u043e\u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>concurrent_updates<\/code>, \u0438\u0445 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<h3>\u041a\u0430\u043a Telegram-\u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043d\u043e\u043f\u043a\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430<\/h3>\n<p><code>reply_markup<\/code> \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u0447\u0438\u0442\u0430\u0435\u0442 <code>inline_keyboard<\/code> \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0430:<\/p>\n<pre><code class=\"python\">def keyboard(markup):    if isinstance(markup, str):        markup = json.loads(markup)    return [        {            \"label\": button.get(\"text\", \"\"),            \"value\": button.get(\"callback_data\") or button.get(\"text\", \"\"),            \"row\": row_index,        }        for row_index, row in enumerate(markup.get(\"inline_keyboard\", []))        for button in row    ]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0438 \u043a\u043b\u0438\u043a\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>value<\/code>, transport \u0441\u043e\u0437\u0434\u0430\u0451\u0442 <code>CallbackQuery<\/code>, \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 <code>CallbackQueryHandler<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 <code>update.callback_<\/code><a href=\"http:\/\/query.data\" rel=\"noopener nofollow\"><code>query.data<\/code><\/a>.<\/p>\n<p>\u0421\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u0435, \u043f\u043b\u0430\u0442\u0451\u0436\u043d\u044b\u0435, Web App \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b \u043a\u043d\u043e\u043f\u043e\u043a \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442. \u0414\u043b\u044f \u043c\u043e\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0431\u043e\u0442\u043e\u0432 \u0431\u044b\u043b\u0438 \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e callback-\u043a\u043d\u043e\u043f\u043a\u0438.<\/p>\n<h3>\u041f\u0435\u0440\u0432\u044b\u0439 \u0444\u0435\u0439\u043b: \u00ab\u043d\u043e\u0432\u044b\u0439 \u0434\u0438\u0430\u043b\u043e\u0433\u00bb \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u043d\u043e\u0432\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430<\/h3>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 Telegram-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u043b\u0441\u044f \u0438\u0437 <code>conversationId<\/code>. \u0412 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043a\u043d\u043e\u043f\u043a\u0430 \u00ab\u041d\u043e\u0432\u044b\u0439 \u0434\u0438\u0430\u043b\u043e\u0433\u00bb \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0430 \u043d\u043e\u0432\u044b\u0439 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u2014 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0431\u043e\u0442 \u0432\u0438\u0434\u0435\u043b \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0415\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u0432 \u0431\u0430\u0437\u0435 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0438\u0441\u0447\u0435\u0437\u0430\u043b.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 ID \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code class=\"python\">def web_user_id(value: str) -&gt; int:    digest = hashlib.sha256(value.encode(\"utf-8\")).digest()    return int.from_bytes(digest[:8], \"big\") &amp; ((1 &lt;&lt; 63) - 1)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p><code>conversationId<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0430 <code>userId<\/code> \u2014 \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0431\u043e\u0442\u0435. \u041d\u043e\u0432\u044b\u0439 \u0434\u0438\u0430\u043b\u043e\u0433 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u043e\u043c\u0443 \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e <code>\/start<\/code>; \u0443\u0436\u0435 \u0441\u0430\u043c \u0431\u043e\u0442 \u0440\u0435\u0448\u0430\u0435\u0442, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0431\u0440\u043e\u0441.<\/p>\n<h3>\u0412\u0442\u043e\u0440\u043e\u0439 \u0444\u0435\u0439\u043b: \u043a\u043d\u043e\u043f\u043a\u0430 \u043f\u0435\u0440\u0435\u0436\u0438\u043b\u0430 \u0441\u0435\u0440\u0432\u0435\u0440, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u2014 \u043d\u0435\u0442<\/h3>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430. \u041f\u043e\u0441\u043b\u0435 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u043d\u0430\u0436\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443, \u043d\u043e \u043d\u043e\u0432\u0430\u044f <code>PTBSession<\/code> \u043d\u0435 \u0437\u043d\u0430\u043b\u0430 <code>message_id<\/code> \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 handler \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0441\u044f \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044d\u0442\u043e \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u043b\u043e\u0441\u044c <code>Unknown Telegram message<\/code>. \u0417\u0430\u0442\u0435\u043c \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0446\u0435\u043b\u0438 \u0434\u043b\u044f callback:<\/p>\n<pre><code class=\"python\">def callback_target(self, label: str) -&gt; int:    if self._last_bot_id is not None:        return self._last_bot_id    message_id = self._next_message    self._next_message += 1    self._last_bot_id = message_id    self.messages.append({        \"id\": str(message_id),        \"type\": \"text\",        \"text\": label,    })    return message_id<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 Telegram-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u043e \u0432\u0441\u0435\u0439 \u043f\u043e\u043b\u043d\u043e\u0442\u0435. \u0426\u0435\u043b\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u043e\u043c\u043d\u0435\u0435: \u0434\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 callback-handler \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u043c\u0435\u0441\u0442\u043e 500-\u0439 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 handler \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u0438\u0441\u043b\u0430\u043b, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435: \u043a\u043d\u043e\u043f\u043a\u0430 \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u0430, \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u043d\u044e. \u041c\u043e\u043b\u0447\u0430\u043b\u0438\u0432\u044b\u0439 \u043a\u043b\u0438\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0445\u0443\u0436\u0435 \u044f\u0432\u043d\u043e\u0439 \u0434\u0435\u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/47\/dc\/eb\/47dcebb61cc0bf5d1ac9f10dba9ca406.png\" alt=\"\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0439 inline-\u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430\" width=\"1600\" height=\"900\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/47\/dc\/eb\/47dcebb61cc0bf5d1ac9f10dba9ca406.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/47\/dc\/eb\/47dcebb61cc0bf5d1ac9f10dba9ca406.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0439 inline-\u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p><em>\u0411\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0438 \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0436\u0438\u0432\u0443\u0442 \u0440\u0430\u0437\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u2014 \u044d\u0442\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0443\u0447\u0435\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/em><\/p>\n<h3>\u0422\u0440\u0435\u0442\u0438\u0439 \u0444\u0435\u0439\u043b: \u0441\u043e\u0432\u043f\u0430\u0432\u0448\u0438\u0435 message_id \u0437\u0430\u0442\u0438\u0440\u0430\u043b\u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u044e<\/h3>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0441\u044f \u0441 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435. \u0411\u0440\u0430\u0443\u0437\u0435\u0440 \u0443\u0436\u0435 \u0445\u0440\u0430\u043d\u0438\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 ID <code>1<\/code>, <code>2<\/code>, <code>3<\/code>, \u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0434\u0430\u0432\u0430\u043b \u0442\u0435 \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0424\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u043e\u0433\u043e.<\/p>\n<p>\u0414\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 Telegram-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 ID:<\/p>\n<pre><code class=\"python\">self._next_message = uuid4().int % 2_000_000_000 + 1<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041a\u043e\u043b\u043b\u0438\u0437\u0438\u044f \u0441\u0442\u0430\u043b\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0439, \u043d\u043e \u044d\u0442\u043e \u0432\u0441\u0451 \u0435\u0449\u0451 \u043d\u0435 \u0441\u0442\u0440\u043e\u0433\u0430\u044f \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u044f. \u0412 production-\u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043d\u0443\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 ID \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430.<\/p>\n<h3>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0444\u043e\u043d\u043e\u0432\u044b\u043c\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u043c\u0438<\/h3>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043e\u0448\u0438\u0431\u043e\u043a: handler \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u0444\u043e\u043d\u043e\u0432\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u0415\u0441\u043b\u0438 transport \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u043b\u044e\u0431\u043e\u0439 <code>sendMessage<\/code> \u0432 \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0432\u043a\u043b\u0430\u0434\u043a\u0443, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0443\u0442\u0435\u0447\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0430:<\/p>\n<pre><code class=\"python\">chat_id = int(params[\"chat_id\"])if chat_id != self._current_user:    raise RuntimeError(        \"Outgoing message targets a different Telegram chat\"    )<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0424\u043e\u043d\u043e\u0432\u044b\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439 \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0434\u043b\u044f \u043d\u0438\u0445 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 endpoint \u0441 cursor-\u043f\u043e\u043b\u043b\u0438\u043d\u0433\u043e\u043c. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043d\u0435 \u00ab\u0443\u0434\u043e\u0431\u043d\u043e\u00bb \u043f\u0435\u0440\u0435\u0430\u0434\u0440\u0435\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e.<\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0431\u0435\u0437 Telegram<\/h3>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 PTB, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432 <code>PTBSession<\/code> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e handler:<\/p>\n<pre><code class=\"python\">messages, buttons = await session.dispatch(    application,    {        \"type\": \"command\",        \"payload\": {\"value\": \"start\"},    },    user_id,)assert messagesassert \"lang_ru\" in [button[\"value\"] for button in buttons]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p>\u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0438 callback;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0431-\u0434\u0438\u0430\u043b\u043e\u0433\u0430\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0443 callback-handler;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0434\u0430\u0447\u0430 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 media endpoint.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u043e\u0448\u043b\u0438 33 \u0442\u0435\u0441\u0442\u0430 \u0432\u0435\u0431-\u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0438 \u0434\u0432\u0430 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430 transport-\u0441\u043b\u043e\u044f. \u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0435\u0433\u043e \u0431\u0430\u0437\u044b \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044e \u0438\u0445 \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u044f \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439<\/h3>\n<p>\u041f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0440\u0435\u0448\u0430\u0435\u0442 \u043c\u043e\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<ul>\n<li>\n<p>\u043e\u043d \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d \u043d\u0430 <code>python-telegram-bot 20.7<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u043c\u0435\u043d\u0430 <a href=\"http:\/\/HTTPXRequest.do\" rel=\"noopener nofollow\"><code>HTTPXRequest.do<\/code><\/a><code>_request<\/code> \u0445\u0440\u0443\u043f\u043a\u0430\u044f \u0438 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c Bot API;<\/p>\n<\/li>\n<li>\n<p>\u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 Telegram media objects;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u0435\u0431-\u0441\u0435\u0441\u0441\u0438\u0439 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p><code>_display()<\/code> \u0443\u0434\u0430\u043b\u044f\u0435\u0442 HTML \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u2014 \u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430, \u043d\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f HTML sanitizer;<\/p>\n<\/li>\n<li>\n<p>\u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0441\u043b\u0443\u0448\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e <code>127.0.0.1<\/code> \u0438 \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433 \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a <code>BaseRequest<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 builder \u0442\u0430\u043c, \u0433\u0434\u0435 \u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 <code>Application<\/code>. \u042d\u0442\u043e \u0443\u0431\u0435\u0440\u0451\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 monkey-patch. \u0414\u043b\u044f \u0447\u0443\u0436\u0438\u0445 \u0431\u043e\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 <code>Bot<\/code> \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u044b \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e Bot API \u0438 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u0435\u0441\u0441\u0438\u0439. \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043f\u0430\u043a\u0435\u0442.<\/p>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>\u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043d\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e Telegram-\u0431\u043e\u0442 \u043e\u0442\u043a\u0440\u044b\u043b\u0441\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u041f\u043e\u043b\u0435\u0437\u043d\u0435\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0441\u0430\u043c \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0441\u043a\u0430\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438:<\/p>\n<ol>\n<li>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 application layer.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442 \u0434\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p>\u042f\u0432\u043d\u043e \u043f\u0430\u0434\u0430\u0442\u044c \u043d\u0430 \u043d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0435 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0435 \u0446\u0438\u043a\u043b\u044b \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0435\u043c\u043e, \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u043e\u0442 Telegram. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 Telegram-\u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u2014 \u0438 \u0447\u0435\u043c \u0440\u0430\u043d\u044c\u0448\u0435 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u044d\u0442\u0443 \u0433\u0440\u0430\u043d\u0438\u0446\u0443, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u0435\u0449\u0430\u043d\u0438\u0439 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u0430\u043d\u0430\u043b, \u0433\u0434\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u0443: \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 <code>Update<\/code>, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u043d\u043e\u0441\u0438\u043b\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0438\u0437 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430?<\/p>\n<h3>\u0421\u0441\u044b\u043b\u043a\u0438<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.python-telegram-bot.org\/en\/v20.7\/telegram.ext.application.html#telegram.ext.Application.process_update\" rel=\"noopener nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f <code>Application.process_update()<\/code> \u0434\u043b\u044f python-telegram-bot 20.7<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.python-telegram-bot.org\/en\/v20.7\/telegram.request.baserequest.html\" rel=\"noopener nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f <code>BaseRequest<\/code> \u0434\u043b\u044f python-telegram-bot 20.7<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/core.telegram.org\/bots\/api#available-types\" rel=\"noopener nofollow\">Telegram Bot API: <code>Update<\/code>, <code>Message<\/code>, <code>CallbackQuery<\/code><\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1092800\/\">https:\/\/habr.com\/ru\/articles\/1092800\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u0442\u043e\u0432 \u043d\u0430 python-telegram-bot: \u043a\u043e\u043c\u0430\u043d\u0434\u044b, inline-\u043a\u043d\u043e\u043f\u043a\u0438, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438. \u0417\u0430\u0442\u0435\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0441\u044f \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c.\u041f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 HTTP API \u043e\u0437\u043d\u0430\u0447\u0430\u043b\u043e \u0431\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f. \u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c Telegram Web App \u0442\u043e\u0436\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b\u043e: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0431\u0435\u0437 Telegram.\u042f \u043f\u043e\u0448\u0451\u043b \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0451\u043c: \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043f\u0440\u0438\u0442\u0432\u043e\u0440\u044f\u0435\u0442\u0441\u044f Telegram \u043d\u0430 \u0432\u0445\u043e\u0434\u0435, \u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 transport-\u0441\u043b\u043e\u0439 \u2014 Telegram Bot API \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b Update \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0448\u0442\u0430\u0442\u043d\u044b\u0439 Application.process_update(). \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f, \u043d\u0430 \u043a\u0430\u043a\u0438\u0445 \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u043e\u043d \u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0438 \u0447\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432.\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 PTB-\u0431\u043e\u0442 \u0432 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440; Telegram \u0432 \u044d\u0442\u043e\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442.\u0427\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0431\u043e\u0442 \u0443\u0436\u0435 \u0443\u043c\u0435\u043b:\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442;\u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c inline-\u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b;\u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 CallbackQuery;\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f;\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b;\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0432\u043e\u0435\u0439 \u0431\u0430\u0437\u0435.\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0431\u044b\u043b \u0442\u0430\u043a\u0438\u043c: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f. \u0412\u0435\u0431-\u0441\u043b\u043e\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043e\u043c, \u0430 \u043d\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439.\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0432\u0435\u0431-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 start(), choose_language() \u0438 confirm(), \u0434\u0432\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0439\u0434\u0443\u0442\u0441\u044f. \u041e\u0448\u0438\u0431\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0435 \u0441\u0440\u0430\u0437\u0443, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f.\u0413\u0434\u0435 \u0432\u043e\u0439\u0442\u0438 \u0432 python-telegram-bot\u0423 python-telegram-bot \u0435\u0441\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u2014 Application.process_update(). \u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0434\u0438\u043d Update, \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 handlers \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f error handlers.\u0417\u043d\u0430\u0447\u0438\u0442, \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c JSON \u0442\u043e\u0439 \u0436\u0435 \u0444\u043e\u0440\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u0438\u0441\u043b\u0430\u043b \u0431\u044b Telegram, \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0447\u0435\u0440\u0435\u0437 Update.de_json():update_data = {    &#171;update_id&#187;: self._next_update,    &#171;message&#187;: {        &#171;message_id&#187;: self._next_message,        &#171;date&#187;: int(datetime.now(timezone.utc).timestamp()),        &#171;chat&#187;: {&#171;id&#187;: user_id, &#171;type&#187;: &#171;private&#187;},        &#171;from&#187;: {            &#171;id&#187;: user_id,            &#171;is_bot&#187;: False,            &#171;first_name&#187;: &#171;Web&#187;,        },        &#171;text&#187;: text,    },}update = Update.de_json(update_data, application.bot)await application.process_update(update)\u0414\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u044e entity \u0442\u0438\u043f\u0430 bot_command. \u0414\u043b\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 callback_query \u0441 \u0442\u0435\u043c \u0436\u0435 callback_data, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0431\u043e\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u0432 InlineKeyboardButton.update_data = {    &#171;update_id&#187;: self._next_update,    &#171;callback_query&#187;: {        &#171;id&#187;: str(uuid4()),        &#171;from&#187;: user,        &#171;chat_instance&#187;: str(user_id),        &#171;data&#187;: str(payload[&#171;value&#187;]),        &#171;message&#187;: message,    },}\u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 Telegram update. CommandHandler, MessageHandler \u0438 CallbackQueryHandler \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u0432\u0435\u0431-\u0432\u0435\u0442\u043e\u043a \u0432\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.\u0412\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0438: \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b\u041e\u0434\u043d\u043e\u0433\u043e process_update() \u043c\u0430\u043b\u043e. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043e\u0447\u0442\u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 reply_text(), edit_message_text() \u0438\u043b\u0438 send_photo(). \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e PTB \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 Bot API.\u0412 \u043c\u043e\u0451\u043c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f HTTPXRequest.do_request \u2014 \u0442\u043e\u0447\u043a\u0430, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u0431\u043e\u0442\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b Bot \u0443\u0445\u043e\u0434\u044f\u0442 \u0432 \u0441\u0435\u0442\u044c:def install_bot_api() -&gt; None:    HTTPXRequest.do_request = _bot_api_requestasync def _bot_api_request(self, url, method, request_data=None, **kwargs):    action = urlsplit(url).path.rsplit(&#171;\/&#187;, 1)[-1].lower()    if action == &#171;getme&#187;:        return ok({            &#171;id&#187;: 123456,            &#171;is_bot&#187;: True,            &#171;first_name&#187;: &#171;Web Bot&#187;,            &#171;username&#187;: &#171;local_web_bot&#187;,        })    session = active_session.get()    if session is None:        raise RuntimeError(            f&#187;Bot API {action} outside an active web conversation is disabled&#187;        )    if action in {&#171;sendmessage&#187;, &#171;sendphoto&#187;, &#171;senddocument&#187;}:        return ok(session.send(action, request_data.parameters, request_data))    if action in {        &#171;editmessagetext&#187;,        &#171;editmessagecaption&#187;,        &#171;editmessagereplymarkup&#187;,    }:        return ok(session.edit(action, request_data.parameters))    raise RuntimeError(f&#187;Bot API method {action} is not implemented&#187;)Transport \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c Bot API. \u041e\u043d \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u043c \u0431\u043e\u0442\u0430\u043c, \u0430 \u043d\u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u044f\u0432\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439. \u042d\u0442\u043e \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043c\u043e\u043b\u0447\u0430 \u043f\u0440\u043e\u0433\u043b\u043e\u0442\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u0435\u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.\u041f\u043e\u0442\u043e\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 PTB-\u0431\u043e\u0442\u0412\u0445\u043e\u0434 \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 Update, \u0432\u044b\u0445\u043e\u0434 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 HTTP-\u0433\u0440\u0430\u043d\u0438\u0446\u0435 PTB.\u0417\u0430\u0447\u0435\u043c \u0437\u0434\u0435\u0441\u044c ContextVar\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441: \u0432 \u043a\u0430\u043a\u0443\u044e \u0432\u0435\u0431-\u0441\u0435\u0441\u0441\u0438\u044e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442? \u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0434\u043e \u0434\u0432\u0443\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b ContextVar:_active: ContextVar[PTBSession | None] = ContextVar(    &#171;telegram_web_session&#187;,    default=None,)marker = _active.set(self)try:    await application.process_update(update)finally:    _active.reset(marker)\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043e \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443. \u041a\u043e\u0433\u0434\u0430 handler \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 Bot API, transport \u0434\u043e\u0441\u0442\u0430\u0451\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0443 PTBSession, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u0448\u043b\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435.\u0423 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c asyncio.Lock. \u041e\u043d \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u0438\u0430\u043b\u043e\u0433\u0430: \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u043a\u043b\u0438\u043a \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 state machine \u0447\u0435\u0440\u0435\u0437 \u0434\u0432\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430.\u042d\u0442\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u0431\u043e\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c. \u0415\u0441\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0444\u043e\u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 concurrent_updates, \u0438\u0445 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.\u041a\u0430\u043a Telegram-\u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043d\u043e\u043f\u043a\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430reply_markup \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u0447\u0438\u0442\u0430\u0435\u0442 inline_keyboard \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0430:def keyboard(markup):    if isinstance(markup, str):        markup = json.loads(markup)    return [        {            &#171;label&#187;: button.get(&#171;text&#187;, &#171;&#187;),            &#171;value&#187;: button.get(&#171;callback_data&#187;) or button.get(&#171;text&#187;, &#171;&#187;),            &#171;row&#187;: row_index,        }        for row_index, row in enumerate(markup.get(&#171;inline_keyboard&#187;, []))        for button in row    ]\u041f\u0440\u0438 \u043a\u043b\u0438\u043a\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 value, transport \u0441\u043e\u0437\u0434\u0430\u0451\u0442 CallbackQuery, \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 CallbackQueryHandler \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 update.callback_query.data.\u0421\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u0435, \u043f\u043b\u0430\u0442\u0451\u0436\u043d\u044b\u0435, Web App \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b \u043a\u043d\u043e\u043f\u043e\u043a \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442. \u0414\u043b\u044f \u043c\u043e\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0431\u043e\u0442\u043e\u0432 \u0431\u044b\u043b\u0438 \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e callback-\u043a\u043d\u043e\u043f\u043a\u0438.\u041f\u0435\u0440\u0432\u044b\u0439 \u0444\u0435\u0439\u043b: \u00ab\u043d\u043e\u0432\u044b\u0439 \u0434\u0438\u0430\u043b\u043e\u0433\u00bb \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u043d\u043e\u0432\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 Telegram-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u043b\u0441\u044f \u0438\u0437 conversationId. \u0412 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043a\u043d\u043e\u043f\u043a\u0430 \u00ab\u041d\u043e\u0432\u044b\u0439 \u0434\u0438\u0430\u043b\u043e\u0433\u00bb \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0430 \u043d\u043e\u0432\u044b\u0439 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u2014 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0431\u043e\u0442 \u0432\u0438\u0434\u0435\u043b \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0415\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u0432 \u0431\u0430\u0437\u0435 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0438\u0441\u0447\u0435\u0437\u0430\u043b.\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 ID \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:def web_user_id(value: str) -&gt; int:    digest = hashlib.sha256(value.encode(&#171;utf-8&#187;)).digest()    return int.from_bytes(digest[:8], &#171;big&#187;) &amp; ((1 &lt;&lt; 63) &#8212; 1)conversationId \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0430 userId \u2014 \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0431\u043e\u0442\u0435. \u041d\u043e\u0432\u044b\u0439 \u0434\u0438\u0430\u043b\u043e\u0433 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u043e\u043c\u0443 \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \/start; \u0443\u0436\u0435 \u0441\u0430\u043c \u0431\u043e\u0442 \u0440\u0435\u0448\u0430\u0435\u0442, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0431\u0440\u043e\u0441.\u0412\u0442\u043e\u0440\u043e\u0439 \u0444\u0435\u0439\u043b: \u043a\u043d\u043e\u043f\u043a\u0430 \u043f\u0435\u0440\u0435\u0436\u0438\u043b\u0430 \u0441\u0435\u0440\u0432\u0435\u0440, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u2014 \u043d\u0435\u0442\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430. \u041f\u043e\u0441\u043b\u0435 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u043d\u0430\u0436\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443, \u043d\u043e \u043d\u043e\u0432\u0430\u044f PTBSession \u043d\u0435 \u0437\u043d\u0430\u043b\u0430 message_id \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 handler \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0441\u044f \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044d\u0442\u043e \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u043b\u043e\u0441\u044c Unknown Telegram message. \u0417\u0430\u0442\u0435\u043c \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0446\u0435\u043b\u0438 \u0434\u043b\u044f callback:def callback_target(self, label: str) -&gt; int:    if self._last_bot_id is not None:        return self._last_bot_id    message_id = self._next_message    self._next_message += 1    self._last_bot_id = message_id    self.messages.append({        &#171;id&#187;: str(message_id),        &#171;type&#187;: &#171;text&#187;,        &#171;text&#187;: label,    })    return message_id\u042d\u0442\u043e \u043d\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 Telegram-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u043e \u0432\u0441\u0435\u0439 \u043f\u043e\u043b\u043d\u043e\u0442\u0435. \u0426\u0435\u043b\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u043e\u043c\u043d\u0435\u0435: \u0434\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 callback-handler \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u043c\u0435\u0441\u0442\u043e 500-\u0439 \u043e\u0448\u0438\u0431\u043a\u0438.\u0415\u0441\u043b\u0438 handler \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u0438\u0441\u043b\u0430\u043b, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435: \u043a\u043d\u043e\u043f\u043a\u0430 \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u0430, \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u043d\u044e. \u041c\u043e\u043b\u0447\u0430\u043b\u0438\u0432\u044b\u0439 \u043a\u043b\u0438\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0445\u0443\u0436\u0435 \u044f\u0432\u043d\u043e\u0439 \u0434\u0435\u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438.\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0439 inline-\u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430\u0411\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0438 \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0436\u0438\u0432\u0443\u0442 \u0440\u0430\u0437\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u2014 \u044d\u0442\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0443\u0447\u0435\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.\u0422\u0440\u0435\u0442\u0438\u0439 \u0444\u0435\u0439\u043b: \u0441\u043e\u0432\u043f\u0430\u0432\u0448\u0438\u0435 message_id \u0437\u0430\u0442\u0438\u0440\u0430\u043b\u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u044e\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0441\u044f \u0441 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435. \u0411\u0440\u0430\u0443\u0437\u0435\u0440 \u0443\u0436\u0435 \u0445\u0440\u0430\u043d\u0438\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 ID 1, 2, 3, \u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0434\u0430\u0432\u0430\u043b \u0442\u0435 \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0424\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u043e\u0433\u043e.\u0414\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 Telegram-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 ID:self._next_message = uuid4().int % 2_000_000_000 + 1\u041a\u043e\u043b\u043b\u0438\u0437\u0438\u044f \u0441\u0442\u0430\u043b\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0439, \u043d\u043e \u044d\u0442\u043e \u0432\u0441\u0451 \u0435\u0449\u0451 \u043d\u0435 \u0441\u0442\u0440\u043e\u0433\u0430\u044f \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u044f. \u0412 production-\u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043d\u0443\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 ID \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430.\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0444\u043e\u043d\u043e\u0432\u044b\u043c\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u043c\u0438\u0415\u0441\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043e\u0448\u0438\u0431\u043e\u043a: handler \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u0444\u043e\u043d\u043e\u0432\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u0415\u0441\u043b\u0438 transport \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u043b\u044e\u0431\u043e\u0439 sendMessage \u0432 \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0432\u043a\u043b\u0430\u0434\u043a\u0443, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0443\u0442\u0435\u0447\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0430:chat_id = int(params[&#171;chat_id&#187;])if chat_id != self._current_user:    raise RuntimeError(        &#171;Outgoing message targets a different Telegram chat&#187;    )\u0424\u043e\u043d\u043e\u0432\u044b\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439 \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0434\u043b\u044f \u043d\u0438\u0445 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 endpoint \u0441 cursor-\u043f\u043e\u043b\u043b\u0438\u043d\u0433\u043e\u043c. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043d\u0435 \u00ab\u0443\u0434\u043e\u0431\u043d\u043e\u00bb \u043f\u0435\u0440\u0435\u0430\u0434\u0440\u0435\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e.\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0431\u0435\u0437 Telegram\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 PTB, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432 PTBSession \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e handler:messages, buttons = await session.dispatch(    application,    {        &#171;type&#187;: &#171;command&#187;,        &#171;payload&#187;: {&#171;value&#187;: &#171;start&#187;},    },    user_id,)assert messagesassert &#171;lang_ru&#187; in [button[&#171;value&#187;] for button in buttons]\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f:\u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0438 callback;\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b;\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0431-\u0434\u0438\u0430\u043b\u043e\u0433\u0430\u043c\u0438;\u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430;\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-498156","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/498156","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=498156"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/498156\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=498156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=498156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=498156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}