{"id":479566,"date":"2026-05-13T09:56:38","date_gmt":"2026-05-13T09:56:38","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=479566"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=479566","title":{"rendered":"Production MTProto user-\u0431\u043e\u0442 \u043d\u0430 FastAPI + Telethon: WARP \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 DPI \u0438 5 \u0433\u0440\u0430\u0431\u043b\u0435\u0439 \u0441 Telegram"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2><\/h2>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1d2\/7a6\/957\/1d27a6957787e8b7cf1fcae40e5cc906.jpg\" width=\"1200\" height=\"630\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/1d2\/7a6\/957\/1d27a6957787e8b7cf1fcae40e5cc906.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1d2\/7a6\/957\/1d27a6957787e8b7cf1fcae40e5cc906.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>Production MTProto user-\u0431\u043e\u0442 \u043d\u0430 FastAPI + Telethon: WARP \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 DPI \u0438 5 \u0433\u0440\u0430\u0431\u043b\u0435\u0439 \u0441 Telegram<\/h2>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432 \u043f\u043e Telegram-\u0431\u043e\u0442\u0430\u043c \u0432\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u0443\u0441\u043a\u0430 \u043a\u043e\u0434\u0430: \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u043e\u043a\u0435\u043d \u0443 @BotFather, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438\u00a0<code>python-telegram-bot<\/code>\u00a0\u0438\u043b\u0438\u00a0<code>aiogram<\/code>, \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0445\u0435\u043d\u0434\u043b\u0435\u0440, deploy. \u042d\u0442\u043e Bot API. \u0418 \u0432 90% \u0437\u0430\u0434\u0430\u0447 \u044d\u0442\u043e\u0433\u043e \u0445\u0432\u0430\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0410 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e Bot API \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435:\u00a0<strong>\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f\u0443 \u043f\u043e\u0434 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u043d\u0443\u0436\u043d\u044b\u0445 \u043b\u044e\u0434\u0435\u0439 \u043f\u043e\u00a0<\/strong><code><strong>@username<\/strong><\/code><strong>, \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0440\u0430\u0437 \u0432 \u0434\u0435\u043d\u044c<\/strong>. Bot API \u0442\u0430\u043a\u043e\u0435 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0434\u0430\u0436\u0435 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 &#8212; \u043c\u0435\u0442\u043e\u0434\u0430 \u00ab\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0443\u00bb \u0442\u0430\u043c \u043d\u0435\u0442, \u043c\u0435\u0442\u043e\u0434\u0430 \u00ab\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044e\u0437\u0435\u0440\u0430 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443\u00bb \u0442\u043e\u0436\u0435. \u041b\u0435\u0437\u0435\u0442\u0435 \u0432\u00a0<a href=\"https:\/\/core.telegram.org\/api\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u043b\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e Telegram API<\/a>\u00a0\u0438\u0441\u043a\u0430\u0442\u044c \u043e\u0431\u0445\u043e\u0434, \u0443\u043f\u0438\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b \u00a0<code>channels.createChannel<\/code>\u00a0 \/\u00a0 <code>channels.inviteToChannel<\/code> \u043f\u043e\u0434 MTProto, \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f &#8212; \u043d\u0435 Bot API, \u0430 user-\u0431\u043e\u0442 \u0447\u0435\u0440\u0435\u0437\u00a0<code>telethon<\/code>.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e \u043a\u0430\u043a \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 production MTProto user-\u0431\u043e\u0442 \u043d\u0430 FastAPI + Telethon. \u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c: Cloudflare WARP \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 DPI (\u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0441 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e VPS \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f), Singleton-\u043a\u043b\u0438\u0435\u043d\u0442 \u0441 keepalive, in-memory cache resolve-\u044e\u0437\u0435\u0440\u043e\u0432, \u0438\u00a0<strong>5 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 Telegram \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u043d\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043a\u0442\u043e \u043b\u0435\u0437 \u0442\u0443\u0434\u0430 \u043d\u043e\u0433\u0430\u043c\u0438<\/strong>. \u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0439 production-\u0441\u0435\u0440\u0432\u0438\u0441 \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432 \u043d\u0438\u0448\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430\/\u043c\u043e\u043d\u0442\u0430\u0436\u0430, \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u0432\u044f\u0437\u043a\u0443 Planfix \u2192 Telegram-\u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 Python 3.11. \u0421\u0442\u0435\u043a: Telethon 1.43.2, FastAPI 0.136.1, Uvicorn 0.46.0, Pydantic 2.13.4. \u041d\u0430 VPS \u043f\u043e\u0434\u00a0<code>systemd<\/code>, \u043d\u0430\u0440\u0443\u0436\u0443 \u0447\u0435\u0440\u0435\u0437 Cloudflare Tunnel. \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 n8n \u0447\u0435\u0440\u0435\u0437 HTTP-\u043d\u043e\u0434\u0443.<\/p>\n<h3>\u041a\u043e\u0433\u0434\u0430 MTProto user-\u0431\u043e\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u0435\u043d<\/h3>\n<p>\u0418\u0434\u0442\u0438 \u0432 MTProto \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 Bot API \u0443\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0432\u043e\u0438 \u043f\u043e\u0442\u043e\u043b\u043a\u0438. \u0418 \u043d\u0435 \u00ab\u043b\u0435\u043d\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f\u00bb, \u0430\u00a0<strong>\u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0435\u0442 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435<\/strong>\u00a0&#8212; \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 Bot API \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a.<\/p>\n<p>\u0427\u0442\u043e Bot API \u0434\u0435\u043b\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e:<\/p>\n<ul>\n<li>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 inline-\u043a\u043d\u043e\u043f\u043e\u043a \u0438 callback-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438\/\u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438 (\u0435\u0441\u043b\u0438 \u0431\u043e\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0430\u0434\u043c\u0438\u043d\u043e\u043c):\u00a0<code>banChatMember<\/code>,\u00a0<code>unbanChatMember<\/code>,\u00a0<code>pinChatMessage<\/code>,\u00a0<code>setChatTitle<\/code><\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u0451\u043c\u00a0<code>chat_join_request<\/code>\u00a0\u0438\u00a0<code>approveChatJoinRequest<\/code>\u00a0\/\u00a0<code>declineChatJoinRequest<\/code>\u00a0&#8212; \u0442\u043e \u0435\u0441\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0432\u0445\u043e\u0434\u0430 \u043f\u043e invite-link<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e Bot API\u00a0<strong>\u043d\u0435 \u0443\u043c\u0435\u0435\u0442<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f\u044b. \u0421\u043e\u0432\u0441\u0435\u043c. \u041c\u0435\u0442\u043e\u0434\u0430 \u043d\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u044e\u0437\u0435\u0440\u043e\u0432 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443. \u0411\u043e\u0442 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0438\u043a\u043e\u0433\u043e \u00ab\u0437\u0430\u0442\u0430\u0449\u0438\u0442\u044c\u00bb \u0432\u043d\u0443\u0442\u0440\u044c &#8212; \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u0430\u044f\u0432\u043a\u0438 \u043e\u0442 \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u0440\u0438\u0448\u0451\u043b \u043f\u043e invite-link<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0437\u043e\u043b\u0432\u0438\u0442\u044c\u00a0<code>@username<\/code>\u00a0\u2194\u00a0<code>user_id<\/code>. \u041d\u0438\u043a\u0430\u043a<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0430\u043b\u043e\u0433 \u0441 \u044e\u0437\u0435\u0440\u043e\u043c \u043f\u0435\u0440\u0432\u044b\u043c (\u043d\u0443\u0436\u0435\u043d\u00a0<code>\/start<\/code>\u00a0\u043e\u0442 \u044e\u0437\u0435\u0440\u0430)<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u044d\u0442\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0435\u0441\u0442\u044c \u0432 MTProto. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0434\u0432\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 &#8212; \u044d\u0442\u043e \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u0434 \u0437\u0430 user-\u0431\u043e\u0442\u0430.<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u043d\u0438\u0448\u0430 \u043c\u043e\u043d\u0442\u0430\u0436\u0430\/\u0440\u0435\u043c\u043e\u043d\u0442\u0430\/\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430, \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0441 \u043f\u043e\u0434\u0440\u044f\u0434\u0447\u0438\u043a\u0430\u043c\u0438 \u0438 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430\u043c\u0438) \u0431\u044b\u043b \u0437\u0430\u043f\u0440\u043e\u0441:\u00a0<strong>\u043a\u0430\u0436\u0434\u0430\u044f \u043d\u043e\u0432\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0432 Planfix \u0434\u043e\u043b\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c Telegram-\u0447\u0430\u0442 \u0441\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430\u043c\u0438 \u0438\u0437 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438<\/strong>. \u041d\u0430 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0435\u043a\u0442 3-10 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0420\u0430\u043d\u044c\u0448\u0435 \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0440\u0443\u043a\u0430\u043c\u0438 \u0434\u0435\u043b\u0430\u043b project-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\/\u043e\u0444\u0438\u0441-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440: \u0441\u043e\u0437\u0434\u0430\u0451\u0448\u044c \u0433\u0440\u0443\u043f\u043f\u0443, \u0438\u0449\u0435\u0448\u044c \u043b\u044e\u0434\u0435\u0439 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0435, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0448\u044c, \u043f\u043e\u0442\u043e\u043c \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u0430\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 &#8212; \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u0430\u0432\u0438\u0448\u044c \u0440\u0443\u043a\u0430\u043c\u0438. \u041d\u0430 \u0431\u043e\u0442 \u044d\u0442\u0430 \u0440\u043e\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043f\u043e\u0447\u0442\u0438 \u043d\u0430 100%.<\/p>\n<p>\u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0447\u0435\u0440\u0435\u0437 MTProto \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f\u044b (\u0442\u043e\u043b\u044c\u043a\u043e MTProto)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u043f\u043e\u00a0<code>@username<\/code>\u00a0\u0438\u0437 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 Planfix (\u0442\u043e\u043b\u044c\u043a\u043e MTProto)<\/p>\n<\/li>\n<li>\n<p>Resolve\u00a0<code>id \u2194 @username<\/code>\u00a0(\u0442\u043e\u043b\u044c\u043a\u043e MTProto)<\/p>\n<\/li>\n<\/ol>\n<p>Bot API \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0441\u0432\u044f\u0437\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u043e\u0439:\u00a0<code>banChatMember<\/code>\/<code>unbanChatMember<\/code>\u00a0\u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430,\u00a0<code>approveChatJoinRequest<\/code>\u00a0\u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u0445\u0441\u044f \u0447\u0435\u0440\u0435\u0437 invite-link, pin \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u0432. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u0447\u0435\u0440\u0435\u0437 MTProto user-\u0431\u043e\u0442\u0430, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0435\u0440\u0435\u0437 Bot API.<\/p>\n<h3>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043a\u043e\u0434\u043e\u043c &#8212; \u043e\u0431\u0449\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430. \u0427\u0442\u043e \u0435\u0441\u0442\u044c \u0432 production:<\/p>\n<pre><code>   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502      Planfix (event source)          \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                    \u2502 webhook                    \u25bc   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502   n8n (orchestrator, 56 \u043d\u043e\u0434)         \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                    \u2502 HTTP + X-API-Key                    \u25bc   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502  FastAPI service (mtproto-api)       \u2502   \u2502  \u251c\u2500 Singleton TelegramClient         \u2502   \u2502  \u251c\u2500 \/create-group  \/add-users        \u2502   \u2502  \u2502  \/resolve-user  \/health           \u2502   \u2502  \u2514\u2500 keepalive 180s + ensure_connected\u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                    \u2502 MTProto                    \u25bc   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502  Cloudflare WARP (SOCKS5 :40000)     \u2502   \u2502  \u043e\u0431\u0445\u043e\u0434 \u0420\u041a\u041d-DPI                       \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                    \u25bc   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502       Telegram MTProto API           \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u043d\u0430\u0440\u0443\u0436\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 Cloudflare Tunnel (<code>mtproto.example.ru<\/code>\u00a0\u2192\u00a0<code>localhost:8080<\/code>), \u043f\u043e\u0440\u0442 8080 \u043d\u0430 \u0441\u0430\u043c VPS \u043d\u0430\u0440\u0443\u0436\u0443 \u043d\u0435 \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 HTTP &#8212; \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a\u00a0<code>X-API-Key<\/code>\u00a0(\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437\u00a0<code>openssl rand -base64 32<\/code>), \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 FastAPI dependency \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c endpoint.<\/p>\n<p>Endpoints:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041c\u0435\u0442\u043e\u0434<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u0443\u0442\u044c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>GET<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>\/health<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0442\u0430\u0442\u0443\u0441 MTProto-\u0441\u0435\u0441\u0441\u0438\u0438, \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0431\u0435\u0437 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>POST<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>\/create-group<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f\u0443, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0431\u043e\u0442\u0430 \u0438 \u0430\u0434\u043c\u0438\u043d\u043e\u0432, \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>POST<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>\/add-users<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432\/\u0430\u0434\u043c\u0438\u043d\u043e\u0432 \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0443<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>POST<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>\/resolve-user<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">Resolve id \u2194 username, \u0441 in-memory \u043a\u0435\u0448\u0435\u043c + deep_search \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0430\u043c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>GET<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>\/cache-stats<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0435\u0448\u0430 resolve-\u044e\u0437\u0435\u0440\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u00a0<code>\/create-group<\/code>\u00a0\u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"json\">POST \/create-groupX-API-Key: &lt;secret&gt;Content-Type: application\/json{  \"title\": \"\u041f\u0440\u043e\u0435\u043a\u0442 \u041e\u0431\u044a\u0435\u043a\u0442-42 \u041c\u043e\u0441\u043a\u0432\u0430\",  \"description\": \"\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\",  \"admins\": [\"@admin_username\"],  \"users\": [\"@team_member1\", \"@team_member2\"],  \"request_approval\": true}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442\u0435 &#8212;\u00a0<code>chat_id<\/code>\u00a0\u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Bot API (\u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c\u00a0<code>-100<\/code>, \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 Bot API),\u00a0<code>invite_link<\/code>, \u0438\u00a0<strong>\u043a\u0440\u0438\u0442\u0438\u0447\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430 \u0434\u043b\u044f production &#8212; \u0441\u043b\u043e\u0432\u0430\u0440\u0438\u00a0<\/strong><code><strong>*_errors<\/strong><\/code><strong>\u00a0\u0441 pereason&#8217;\u043e\u043c \u0435\u0441\u043b\u0438 \u043a\u043e\u0433\u043e-\u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c<\/strong>:<\/p>\n<pre><code class=\"json\">{  \"status\": \"ok\",  \"chat_id\": -1001234567890,  \"invite_link\": \"https:\/\/t.me\/+abc...\",  \"bot_added\": true,  \"admins_added\": [\"admin_username\"],  \"admins_errors\": {},  \"users_added\": [\"team_member1\"],  \"users_errors\": {\"team_member2\": \"user_privacy_restricted\"}}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c HTTP-\u0441\u0442\u0430\u0442\u0443\u0441 200, \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430, \u043d\u043e\u00a0<code>team_member2<\/code>\u00a0\u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439. n8n \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c fallback &#8212; \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0431\u043e\u0442\u0430 \u043b\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u0430 \u0438\u0437\u00a0<code>*_errors<\/code>, \u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u044e\u0437\u0435\u0440\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 invite-link, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043e\u043d \u0441\u0430\u043c \u043a\u043b\u0438\u043a\u043d\u0435\u0442 \u0438 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a \u0441\u0430\u043c\u043e\u0439 \u0442\u044f\u0436\u0451\u043b\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 &#8212; \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u0441\u0451 \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e VPS.<\/p>\n<h3>\u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u0431\u043b\u043e\u043a\u0435\u0440: \u0420\u041a\u041d-DPI \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 MTProto-\u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c Telethon-\u043a\u043b\u0438\u0435\u043d\u0442 \u0441 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e VPS \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0435:<\/p>\n<pre><code>ConnectionError: Connection to Telegram failed 5 time(s)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0435 resolve hostname&#8217;\u0430, \u043d\u0435 TLS-\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043d\u0435 firewall. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u00a0<strong>\u0420\u041a\u041d-DPI \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0451\u0442 MTProto-\u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435 \u043f\u0430\u043a\u0435\u0442\u0430<\/strong>\u00a0\u0438 \u0440\u0435\u0436\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 TCP. \u041e\u0431\u0444\u0443\u0441\u043a\u0430\u0446\u0438\u044f, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0432 Telethon (<code>ConnectionTcpObfuscated<\/code>), \u043d\u0430 \u044d\u0442\u043e \u043d\u0435 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 &#8212; DPI \u0435\u0451 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0432\u0438\u0434\u0438\u0442.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u043b \u0441\u0435\u0440\u0432\u0438\u0441 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0431\u0435\u0437 \u043e\u0431\u0445\u043e\u0434\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b:<\/p>\n<ul>\n<li>\n<p>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 DC (datacenters Telegram) &#8212; \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b\u00a0<code>connection<\/code>\u00a0\u0432 Telethon (<code>ConnectionTcpFull<\/code>,\u00a0<code>ConnectionTcpIntermediate<\/code>,\u00a0<code>ConnectionTcpAbridged<\/code>,\u00a0<code>ConnectionTcpObfuscated<\/code>) &#8212; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0442 \u0436\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 &#8212;\u00a0<strong>Cloudflare WARP \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 SOCKS5 \u043d\u0430 127.0.0.1:40000<\/strong>. \u0427\u0442\u043e \u044d\u0442\u043e:<\/p>\n<ol>\n<li>\n<p>WARP &#8212; VPN-\u043a\u043b\u0438\u0435\u043d\u0442 Cloudflare, \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f\u00a0<code>warp-cli<\/code>\u00a0\u043f\u043e\u0434 Linux. \u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435\u00a0<code>warp-cli connect<\/code>\u00a0&#8212; \u0432\u0435\u0441\u044c \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0442\u0440\u0430\u0444\u0438\u043a \u0441 VPS \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 CF-\u0441\u0435\u0442\u044c. \u0412\u043d\u0435\u0448\u043d\u0438\u0439 IP \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 CF Moscow (DPI \u0435\u0433\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0440\u0430\u0444\u0438\u043a \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d \u043c\u0435\u0436\u0434\u0443 VPS \u0438 CF \u0438 \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 HTTPS \u043d\u0430 CF)<\/p>\n<\/li>\n<li>\n<p>Telethon \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 SOCKS5 \u0447\u0435\u0440\u0435\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 40000 (\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 WARP SOCKS-\u0440\u0435\u0436\u0438\u043c)<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 Telethon \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">from telethon import TelegramClientfrom telethon.network.connection import ConnectionTcpFullimport socksPROXY = (socks.SOCKS5, \"127.0.0.1\", 40000)client = TelegramClient(    \"session\",    API_ID,    API_HASH,    connection=ConnectionTcpFull,    proxy=PROXY,)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e\u00a0<code>client.start()<\/code>\u00a0\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0436\u0438\u0432\u043e\u0441\u0442\u0438 WARP:<\/p>\n<pre><code class=\"bash\">warp-cli status        # \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f: Connectedcurl --socks5 127.0.0.1:40000 -m 10 https:\/\/ipinfo.io\/# \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0435\u0440\u043d\u0443\u0442\u044c IP \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Cloudflare Moscow<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>WARP \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0441\u043b\u0435\u00a0<code>systemctl enable warp-svc<\/code>. \u0417\u0430 \u0432\u0441\u0451 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u0430 WARP \u043d\u0435 \u043f\u0430\u0434\u0430\u043b \u043d\u0438 \u0440\u0430\u0437\u0443 &#8212; \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0441 VPS, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0440\u0438\u0441\u043a \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0438\u0434\u0435\u043b &#8212; \u043f\u043e\u0441\u043b\u0435\u00a0<code>reboot<\/code>\u00a0VPS WARP \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e, \u0438 \u0435\u0441\u043b\u0438\u00a0<code>mtproto-api.service<\/code>\u00a0\u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0440\u0430\u043d\u044c\u0448\u0435, \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043e\u043d\u043d\u0435\u043a\u0442 \u043a Telegram \u043f\u0430\u0434\u0430\u0435\u0442 \u0441\u00a0<code>ConnectionError<\/code>. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 &#8212; startup-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u00a0<code>mtproto-api.service<\/code>\u00a0\u043e\u0442\u00a0<code>warp-svc<\/code>:<\/p>\n<pre><code>[Unit]Description=MTProto FastAPI serviceAfter=network-online.target warp-svc.serviceRequires=warp-svc.service[Service]ExecStart=\/opt\/mtproto-api\/venv\/bin\/uvicorn app:app --host 127.0.0.1 --port 8080Restart=on-failure<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0435 reconnect&#8217;\u044b \u0432 journald &#8212; \u044d\u0442\u043e keepalive \u043f\u043e\u0441\u043b\u0435 idle-\u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430, \u043d\u0435 WARP-\u0438\u043d\u0446\u0438\u0434\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b WARP&#8217;\u0443 &#8212; \u043f\u043b\u0430\u0442\u043d\u044b\u0439 VPS \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0441 \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u0420\u0424 \u043b\u0438\u0431\u043e \u0441\u0432\u043e\u0439 MTProxy \u043d\u0430 foreign-\u0445\u043e\u0441\u0442\u0435. \u0414\u043e\u0440\u043e\u0436\u0435, \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0430\u0449\u0435 \u043e\u0431\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043b\u044e\u0441 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435. WARP \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439, \u043d\u0430\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 Linux, \u0438 \u0441\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 DPI \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u044f.<\/p>\n<h3>Singleton TelegramClient &#8212; \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e<\/h3>\n<p>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0436\u0438\u0440\u043d\u043e\u0439 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0447\u0435\u0440\u0442\u043e\u0439 \u043f\u043e\u0441\u043b\u0435 \u0434\u0432\u0443\u0445 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0439 \u0441\u0435\u0441\u0441\u0438\u0438:\u00a0<strong>\u043e\u0434\u0438\u043d MTPROTO_SESSION = \u043e\u0434\u0438\u043d TelegramClient \u0432 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/strong>. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 Python-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 session-\u0441\u0442\u0440\u043e\u043a\u043e\u0439.<\/p>\n<p>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 (\u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0446\u0438\u0434\u0435\u043d\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430): \u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u00a0<code>check_user.py<\/code>\u00a0\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c\u00a0<code>mtproto-api<\/code>. \u041e\u0431\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441\u0442\u0443\u0447\u0430\u043b\u0438\u0441\u044c \u0432 Telegram \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c session-string. Telegram security-\u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043b\u043e\u0432\u0438\u0442 \u044d\u0442\u043e \u043a\u0430\u043a \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c (\u00ab\u043e\u0434\u0438\u043d \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u0438\u0442\u0441\u044f \u0441 \u0434\u0432\u0443\u0445 \u043c\u0435\u0441\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u00bb) \u0438 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442\u00a0<code>AUTH_KEY_UNREGISTERED<\/code>\u00a0\u0441\u0442\u0430\u0440\u0448\u0435\u043c\u0443 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0421\u0435\u0441\u0441\u0438\u044f \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0430\u0434\u0430\u0435\u0442, \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 reauth.<\/p>\n<p>\u0414\u0432\u0430\u0436\u0434\u044b \u0437\u0430 \u043e\u0434\u0438\u043d \u0434\u0435\u043d\u044c \u0432\u043b\u0435\u0442\u0435\u043b \u0432 \u044d\u0442\u0443 \u044f\u043c\u0443 (\u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0430 \u0434\u0443\u043c\u0430\u043b \u00ab\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u044c\u00bb, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u0442\u0435\u0441\u0442\u044b\u00a0<code>resolve-user<\/code>\u00a0\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e &#8212; \u0441\u043d\u043e\u0432\u0430 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f). \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0448\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432 \u0432\u0438\u0434\u0435 \u0444\u0430\u0439\u043b\u0430\u00a0<code>feedback_mtproto_rules.md<\/code>\u00a0\u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430:<\/p>\n<blockquote>\n<p>\u0417\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0441 Telethon \u043d\u0430 \u0442\u0443 \u0436\u0435\u00a0<code>MTPROTO_SESSION<\/code>\u00a0\u043f\u043e\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u00a0<code>mtproto-api<\/code>. \u0414\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 &#8212; \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u0441\u0441\u0438\u044f \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u043e\u043c\u0435\u0440\u0435 \u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c.<\/p>\n<\/blockquote>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e Singleton-\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c \u0447\u0435\u0440\u0435\u0437 FastAPI lifespan:<\/p>\n<pre><code class=\"python\">from contextlib import asynccontextmanagerfrom fastapi import FastAPIfrom telethon import TelegramClient@asynccontextmanagerasync def lifespan(app: FastAPI):    # startup    app.state.client = TelegramClient(        SESSION, API_ID, API_HASH,        connection=ConnectionTcpFull,        proxy=(socks.SOCKS5, \"127.0.0.1\", 40000),    )    await app.state.client.start()    # warmup entity cache    async for _ in app.state.client.iter_dialogs(limit=300):        pass    # background keepalive    app.state.keepalive_task = asyncio.create_task(_keepalive(app.state.client))    yield    # shutdown    app.state.keepalive_task.cancel()    await app.state.client.disconnect()app = FastAPI(lifespan=lifespan)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 endpoint \u0431\u0435\u0440\u0451\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u0437\u00a0<code>request.app.state.client<\/code>, \u043d\u0438\u043a\u0430\u043a\u043e\u0439\u00a0<code>client = TelegramClient(...)<\/code>\u00a0\u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0435\u0442. \u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043e\u0434\u0438\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441.<\/p>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 (~5 \u043c\u0438\u043d\u0443\u0442):<\/p>\n<ol>\n<li>\n<p><code>systemctl stop mtproto-api<\/code><\/p>\n<\/li>\n<li>\n<p><code>pgrep -af telethon<\/code>\u00a0&#8212; \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043d\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>\u0410\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0439 reauth-\u0441\u043a\u0440\u0438\u043f\u0442 \u0447\u0435\u0440\u0435\u0437\u00a0<code>systemd-run --user --scope<\/code>\u00a0(\u043d\u0435\u00a0<code>nohup<\/code>\/<code>tmux<\/code>\u00a0\u0447\u0435\u0440\u0435\u0437 SSH, \u0438\u043d\u0430\u0447\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0443\u043c\u0440\u0451\u0442 \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u044b\u0432\u0435 SSH-\u0441\u0435\u0441\u0441\u0438\u0438 \u0438 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0437\u0430\u0432\u0438\u0441\u043d\u0435\u0442 \u0432 \u043f\u043e\u043b\u0443-\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 session-string.\u00a0<strong>\u0412\u0430\u0436\u043d\u043e<\/strong>: \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441 \u0442\u043e\u0433\u043e \u0436\u0435 IP \u0447\u0442\u043e \u0438 production (\u0442\u043e\u0442 \u0436\u0435 WARP), \u0438\u043d\u0430\u0447\u0435 Telegram security \u0441\u0442\u0430\u0432\u0438\u0442 \u0444\u043b\u0430\u0433 \u00ab\u0432\u0445\u043e\u0434 \u0441 \u043d\u043e\u0432\u043e\u0433\u043e IP\u00bb \u0438 \u043d\u0435 \u0434\u0430\u0451\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 SMS<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u0433\u043e \u0438 \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e.<\/p>\n<h3>\u0415\u0449\u0451 \u0447\u0435\u0442\u044b\u0440\u0435 \u0433\u0440\u0430\u0431\u043b\u0438 \u0441 Telegram<\/h3>\n<p>\u0421 DPI \u0438 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0440\u043e\u0447\u0435 &#8212; \u0447\u0435\u0442\u044b\u0440\u0435 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043b\u0438\u0447\u043d\u043e \u0441\u043f\u043e\u0442\u044b\u043a\u0430\u043b\u0441\u044f.<\/p>\n<h4>Mutual contact \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0432\u0435\u0436\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043b\u0435\u0433\u0447\u0435<\/h4>\n<p><code>InviteToChannelRequest<\/code>\u00a0(\u043e\u043d \u0436\u0435\u00a0<code>channels.inviteToChannel<\/code>\u00a0\u0432 MTProto) \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043a\u0438\u043d\u0443\u0442\u044c\u00a0<code>USER_NOT_MUTUAL_CONTACT<\/code>\u00a0\u0435\u0441\u043b\u0438 \u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u0430 privacy\u00a0<code>My Contacts<\/code>\u00a0\u0438\u043b\u0438\u00a0<code>Nobody<\/code>, \u0430 \u0441\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u043d\u0435 \u0432 \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430\u0445. \u0412\u00a0<a href=\"https:\/\/core.telegram.org\/method\/channels.inviteToChannel\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Telegram<\/a>\u00a0\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u043a\u043e\u0434\u044b \u043e\u0448\u0438\u0431\u043e\u043a (<code>USER_NOT_MUTUAL_CONTACT<\/code>,\u00a0<code>USER_PRIVACY_RESTRICTED<\/code>,\u00a0<code>USER_BLOCKED<\/code>,\u00a0<code>USER_KICKED<\/code>\u00a0\u0438 \u0435\u0449\u0451 \u043f\u044f\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u044c), \u043d\u043e\u00a0<strong>\u0442\u043e\u0447\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f<\/strong>\u00a0&#8212; \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0430\u0442\u043a\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f.<\/p>\n<p>\u042d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438: \u0432 \u043f\u0435\u0440\u0432\u044b\u0435 \u0447\u0430\u0441\u044b \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f\u044b Telegram \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437\u00a0<code>inviteToChannel<\/code>\u00a0\u0447\u0430\u0449\u0435, \u0447\u0435\u043c \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u044f\/\u043c\u0435\u0441\u044f\u0446. \u041f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u00a0<strong>\u043d\u0435\u043b\u044c\u0437\u044f<\/strong>\u00a0&#8212; \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438 \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0442\u044c fallback \u043d\u0430 invite-link \u0441\u00a0<code>request_approval=true<\/code>.<\/p>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u044b\u0432\u043e\u0434 \u0434\u043b\u044f \u0432\u043e\u0440\u043a\u0444\u043b\u043e\u0443:<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0433\u0440\u0443\u043f\u043f\u044b \u0441\u0440\u0430\u0437\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0435\u0445 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 (\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0439\u0434\u0451\u0442)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e, \u043a\u0442\u043e \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u0432\u00a0<code>users_errors<\/code>\u00a0&#8212; \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c invite-link \u0447\u0435\u0440\u0435\u0437 \u0431\u043e\u0442\u0430 \u0432 \u043b\u0438\u0447\u043a\u0443<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0432\u0441\u0435\u0445 \u043d\u043e\u0432\u044b\u0445 \u0447\u043b\u0435\u043d\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0434\u043d\u0438\/\u043d\u0435\u0434\u0435\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e invite-link + \u0430\u0432\u0442\u043e\u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 Bot API \u043f\u0440\u0438\u00a0<code>chat_join_request<\/code>\u00a0event<\/p>\n<\/li>\n<\/ol>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0435: \u043d\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043d\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u00ab\u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u043a\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043b\u044e\u0431\u044b\u0445\u00bb. \u041e\u043a\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0445\u043b\u043e\u043f\u043d\u0443\u0442\u044c\u0441\u044f &#8212; \u0438 \u0441\u0445\u043b\u043e\u043f\u043d\u0435\u0442\u0441\u044f \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<h4>\u041f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u044e\u0437\u0435\u0440 \u0431\u044b\u043b \u0437\u0430\u0431\u0430\u043d\u0435\u043d \u0447\u0435\u0440\u0435\u0437 Bot API (<code>banChatMember<\/code>) \u0438\u043b\u0438 \u0432\u044b\u0448\u0435\u043b \u0441\u0430\u043c &#8212; \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437\u00a0<code>InviteToChannelRequest<\/code>\u00a0\u0443\u0436\u0435 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. Telegram \u043e\u0442\u0434\u0430\u0441\u0442\u00a0<code>UserNotMutualContactError<\/code>\u00a0\u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 mutual contact, \u043b\u0438\u0431\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u043e\u0439\u0434\u0451\u0442 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u043e \u044e\u0437\u0435\u0440 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u0433\u0440\u0443\u043f\u043f\u0435 \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f. \u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 privacy-\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u044e\u0437\u0435\u0440\u0430 \u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0438 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u043f\u0435\u043a\u0438 \u043d\u0430 \u044d\u0442\u043e \u043d\u0435\u0442.<\/p>\n<p>\u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0439: \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442 \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043f\u0440\u043e\u0435\u043a\u0442 \u0437\u0430\u043a\u0440\u044b\u043b\u0438, \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b \u0447\u0435\u0440\u0435\u0437 Bot API. \u0427\u0435\u0440\u0435\u0437 \u043c\u0435\u0441\u044f\u0446 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438 &#8212; \u0432 Planfix \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0435\u0433\u043e \u0424\u0418\u041e \u0432 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u041f\u0440\u044f\u043c\u043e\u0439\u00a0<code>add-user<\/code>\u00a0\u0447\u0435\u0440\u0435\u0437 MTProto &#8212; \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p><strong>\u0420\u0430\u0431\u043e\u0447\u0430\u044f \u0441\u0445\u0435\u043c\u0430:<\/strong><\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 &#8212;\u00a0<code>banChatMember<\/code>\u00a0\u0447\u0435\u0440\u0435\u0437 Bot API (\u0438\u043b\u0438\u00a0<code>kickChatMember<\/code>, \u0447\u0442\u043e \u0434\u043b\u044f \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 &#8212; \u044e\u0437\u0435\u0440 \u0443\u0445\u043e\u0434\u0438\u0442 \u0432 banned list)<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 &#8212; \u0441\u043d\u0430\u0447\u0430\u043b\u0430\u00a0<code>unbanChatMember<\/code>\u00a0(\u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0438\u0437 banned list), \u0437\u0430\u0442\u0435\u043c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 invite-link \u0441\u00a0<code>request_approval=true<\/code>\u00a0\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044e\u0437\u0435\u0440\u0443 \u0432 \u043b\u0438\u0447\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 \u0431\u043e\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u0433\u0434\u0430 \u044e\u0437\u0435\u0440 \u043a\u043b\u0438\u043a\u0430\u0435\u0442 \u043d\u0430 invite-link, Telegram \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442\u00a0<code>chat_join_request<\/code>\u00a0\u043d\u0430 webhook<\/p>\n<\/li>\n<li>\n<p>Bot API workflow \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442: \u0435\u0441\u0442\u044c \u043b\u0438 \u0435\u0433\u043e\u00a0<code>user_id<\/code>\u00a0\u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u043d\u0430\u0448\u0435\u0439 DataTable? \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c &#8212;\u00a0<code>approveChatJoinRequest<\/code>, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 &#8212;\u00a0<code>declineChatJoinRequest<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u0427\u0435\u0440\u0435\u0437\u00a0<code>unban + invite-link + \u0430\u0432\u0442\u043e\u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u0435<\/code>\u00a0\u043f\u0435\u0442\u043b\u044f \u00ab\u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u2192 \u0432\u0435\u0440\u043d\u0443\u043b\u0438\u00bb \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e \u0434\u043b\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430: \u043e\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u0432 \u043b\u0438\u0447\u043a\u0443, \u043a\u043b\u0438\u043a\u0430\u0435\u0442 \u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 \u0437\u0430 \u043f\u0430\u0440\u0443 \u0441\u0435\u043a\u0443\u043d\u0434 \u0431\u0435\u0437 \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u0432 \u0446\u0438\u043a\u043b\u0435.<\/p>\n<h4>access_hash \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e numeric id<\/h4>\n<p>Telethon\u00a0<strong>\u043d\u0435 \u043c\u043e\u0436\u0435\u0442<\/strong>\u00a0\u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u0430 \u043f\u043e \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u043c\u0443\u00a0<code>user_id<\/code>\u00a0\u0431\u0435\u0437\u00a0<code>access_hash<\/code>. Access_hash &#8212; \u044d\u0442\u043e security-\u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 Telegram \u0432\u044b\u0434\u0430\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0441\u0441\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0430 \u044d\u0442\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u0430 (\u043e\u0431\u0449\u0438\u0439 \u0447\u0430\u0442, \u043a\u043e\u043d\u0442\u0430\u043a\u0442, \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0434\u0438\u0430\u043b\u043e\u0433).<\/p>\n<p>\u0412 Bot API \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u043a\u0440\u044b\u0442\u0430 (API \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 chat_id \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435). \u0412 MTProto access_hash &#8212; \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0433\u0434\u0435-\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0438 \u0433\u0434\u0435-\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c.<\/p>\n<p>Best practice:\u00a0<strong>\u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u00a0<\/strong><code><strong>@username<\/strong><\/code><strong>\u00a0\u0432\u043c\u0435\u0441\u0442\u043e id<\/strong>\u00a0\u0432\u00a0<code>\/create-group<\/code>\u00a0\u0438\u00a0<code>\/add-users<\/code>. Telethon \u0440\u0435\u0441\u043e\u043b\u0432\u0438\u0442 username \u0447\u0435\u0440\u0435\u0437\u00a0<code>client.get_input_entity('@username')<\/code>\u00a0&#8212; \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 access_hash, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e username \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u0435\u043d.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e\u00a0<code>id<\/code>\u00a0(\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438\u043b\u0435\u0442\u0435\u043b \u0438\u0437 webhook Bot API), \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437\u00a0<code>\/resolve-user<\/code>\u00a0\u0441\u00a0<code>deep_search=true<\/code>\u00a0&#8212; \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0432\u0441\u0435\u0445 \u0433\u0440\u0443\u043f\u043f \u0433\u0434\u0435 \u0441\u0435\u0441\u0441\u0438\u044f \u0435\u0441\u0442\u044c, \u0438\u0449\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 id<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0447\u0435\u0440\u0435\u0437 invite-link (\u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 access_hash, \u044e\u0437\u0435\u0440 \u0441\u0430\u043c \u043a\u043b\u0438\u043a\u043d\u0435\u0442)<\/p>\n<\/li>\n<\/ul>\n<p>Deep_search \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 5-60 \u0441\u0435\u043a\u0443\u043d\u0434 (\u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0433\u0440\u0443\u043f\u043f), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0431\u0435\u0437 id \u043d\u0438\u043a\u0430\u043a.<\/p>\n<h4>\u041b\u0438\u043c\u0438\u0442\u044b Telegram \u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f retry<\/h4>\n<p>Telegram\u00a0<strong>\u043d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0442\u043e\u0447\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u043b\u0438\u043c\u0438\u0442\u044b<\/strong>\u00a0\u043d\u0430 rate \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 &#8212; \u0432\u00a0<a href=\"https:\/\/core.telegram.org\/api\/channel\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>\u00a0\u0443\u043a\u0430\u0437\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f\u044b (200 000), \u0430 \u043d\u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u044b \u043d\u0430\u0442\u044b\u043a\u0430\u0435\u0442\u0435\u0441\u044c \u0447\u0435\u0440\u0435\u0437\u00a0<code>FLOOD_WAIT<\/code>\u00a0exception \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u00a0<code>retry_after<\/code>\u00a0\u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u0432 \u0432\u0430\u0448\u0435\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438. \u0422\u043e \u0435\u0441\u0442\u044c \u043b\u0438\u043c\u0438\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 DC + \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430.<\/p>\n<p>\u0423 \u043d\u0430\u0441 bulk-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0435\u0442 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435: \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430 &#8212; \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 3-10 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u0433\u0440\u0443\u043f\u043f\u0435, \u043c\u0430\u0441\u0441\u043e\u0432\u044b\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u043c. \u0422\u043e\u0447\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043b\u043a\u043e\u0432 \u043f\u043e\u00a0<code>InviteToChannelRequest<\/code>\u00a0\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f \u0432 \u0447\u0430\u0441 \u043d\u0435 \u043d\u0430\u0449\u0443\u043f\u044b\u0432\u0430\u043b\u0438 &#8212; \u0434\u043e\u00a0<code>FLOOD_WAIT<\/code>\u00a0\u043d\u0435 \u0434\u043e\u0445\u043e\u0434\u0438\u043c \u0438\u0437-\u0437\u0430 \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u044b \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u043b\u043e\u0436\u0438\u043b\u0438 \u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 FLOOD_WAIT \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 &#8212; \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f bulk:<\/p>\n<ul>\n<li>\n<p><code>asyncio.Lock<\/code>\u00a0\u0432 FastAPI \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u0441\u0435 Telegram-\u0432\u044b\u0437\u043e\u0432\u044b \u2192 \u043e\u0434\u0438\u043d Telethon-\u0437\u0430\u043f\u0440\u043e\u0441 \u0437\u0430 \u0440\u0430\u0437 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 API-\u0432\u044b\u0437\u043e\u0432\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0412 n8n \u043c\u0435\u0436\u0434\u0443 batch-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0441\u0442\u0430\u0432\u043b\u044e\u00a0<code>Wait<\/code>\u00a03-10 \u0441\u0435\u043a\u0443\u043d\u0434 \u0441 jitter (\u0445\u043e\u0442\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 Planfix \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u043c\u0438\u043d\u0443\u0442\u044b)<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 endpoint &#8212;\u00a0<code>retry x2<\/code>\u00a0\u043f\u0440\u0438\u00a0<code>ConnectionError<\/code><\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u00a0<code>FloodWaitError<\/code>\u00a0\u043e\u0442 Telethon &#8212; \u0447\u0438\u0442\u0430\u0435\u043c\u00a0<code>e.seconds<\/code>, \u0436\u0434\u0451\u043c\u00a0<code>seconds + 5<\/code>, \u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u043f\u043e\u0432\u0442\u043e\u0440; \u0435\u0441\u043b\u0438 \u0443\u043f\u0430\u043b\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c 429 \u0432 HTTP-\u043e\u0442\u0432\u0435\u0442 \u0441 \u0442\u0435\u043c \u0436\u0435\u00a0<code>seconds<\/code>\u00a0\u0432 payload, \u0434\u0430\u043b\u044c\u0448\u0435 \u0443\u0436\u0435 n8n \u0440\u0435\u0448\u0430\u0435\u0442 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u043e\u0432\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 &#8212; \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0435 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u00a0<code>InviteToChannelRequest<\/code>\u00a0\u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0432\u0441\u0435\u0445 username \u0441\u0440\u0430\u0437\u0443, \u0447\u0435\u043c \u0442\u043e\u0442 \u0436\u0435 \u043e\u0431\u044a\u0451\u043c \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b. \u041e\u0434\u0438\u043d API-\u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u043f\u043e rate-budget.<\/p>\n<h3>Production-\u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430: \u0447\u0442\u043e \u0435\u0449\u0451 \u0432\u043d\u0443\u0442\u0440\u0438<\/h3>\n<p>\u0411\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0433\u0440\u0430\u0431\u043b\u0435\u0439 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b, \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p><code><strong>ensure_connected<\/strong><\/code><strong>\u00a0\u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c endpoint.<\/strong>\u00a0Telethon \u043c\u043e\u0436\u0435\u0442 \u00ab\u0432\u0438\u0441\u0435\u0442\u044c \u0432 connected, \u043d\u043e send \u043f\u0430\u0434\u0430\u0435\u0442\u00bb \u043f\u0440\u0438 \u0434\u043e\u043b\u0433\u043e\u043c idle. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434 \u043b\u044e\u0431\u044b\u043c API-\u0432\u044b\u0437\u043e\u0432\u043e\u043c &#8212; \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u00a0<code>client.is_connected()<\/code>\u00a0\u0438 \u043f\u0435\u0440\u0435\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0435\u0441\u043b\u0438 \u0443\u043f\u0430\u043b\u043e:<\/p>\n<pre><code class=\"python\">async def ensure_connected(client: TelegramClient):    if not client.is_connected():        await client.connect()    # \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 health-check    try:        await asyncio.wait_for(client.get_me(), timeout=3)    except (asyncio.TimeoutError, ConnectionError):        await client.disconnect()        await client.connect()<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><strong>Keepalive 180 \u0441\u0435\u043a\u0443\u043d\u0434.<\/strong>\u00a0Background-task, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437 \u0432 \u0442\u0440\u0438 \u043c\u0438\u043d\u0443\u0442\u044b \u0434\u0451\u0440\u0433\u0430\u0435\u0442\u00a0<code>get_me()<\/code>. \u0411\u0435\u0437 \u043d\u0435\u0433\u043e Telegram \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 idle-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u043b\u0433\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u044f \u043f\u0430\u0434\u0430\u0435\u0442. \u0421 keepalive &#8212; \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0436\u0438\u0432\u043e\u0435.<\/p>\n<p><strong>Warmup\u00a0<\/strong><code><strong>iter_dialogs(limit=300)<\/strong><\/code><strong>\u00a0\u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435.<\/strong>\u00a0Telethon \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u0442 entity-\u043e\u0431\u044a\u0435\u043a\u0442\u044b \u044e\u0437\u0435\u0440\u043e\u0432 \u0438 \u0433\u0440\u0443\u043f\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442. \u041f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 300 \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432 (~5-10 \u0441\u0435\u043a\u0443\u043d\u0434), \u0447\u0442\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u0435\u0448. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e\u00a0<code>client.get_input_entity('@username')<\/code>\u00a0\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e, \u0431\u0435\u0437 round-trip&#8217;\u0430 \u043a Telegram.<\/p>\n<p><strong>In-memory cache resolved \u044e\u0437\u0435\u0440\u043e\u0432.<\/strong>\u00a0\u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a Telethon-\u043a\u0435\u0448\u0443, \u0434\u0435\u0440\u0436\u0443 \u0441\u0432\u043e\u0439\u00a0<code>dict[int, dict]<\/code>\u00a0\u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u041a\u043e\u0433\u0434\u0430\u00a0<code>\/resolve-user<\/code>\u00a0\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043a\u043b\u0430\u0434\u0451\u043c \u0432 \u043a\u0435\u0448. \u041e\u0447\u0438\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0435 &#8212; \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e warmup \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c.<\/p>\n<p><strong>Post-invite verification.<\/strong>\u00a0\u041f\u043e\u0441\u043b\u0435\u00a0<code>InviteToChannelRequest<\/code>\u00a0\u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u0435\u043b\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439\u00a0<code>GetParticipantRequest<\/code>\u00a0\u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e \u044e\u0437\u0435\u0440 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0432 \u0433\u0440\u0443\u043f\u043f\u0435. \u0415\u0441\u043b\u0438 \u0432\u00a0<code>users_added<\/code>\u00a0&#8212; \u044d\u0442\u043e\u00a0<strong>\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0451\u043d\u043d\u043e\u0435<\/strong>\u00a0\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043d\u0435 \u00ab\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f\u00bb. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e Telegram \u0438\u043d\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u00ab\u043e\u043a, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e\u00bb, \u043d\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043a\u0438 &#8212;\u00a0<code>GetParticipantRequest<\/code>\u00a0\u043b\u043e\u0432\u0438\u0442 \u044d\u0442\u043e \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u044e\u0437\u0435\u0440\u0430 \u0432\u00a0<code>*_errors<\/code>.<\/p>\n<h3>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u041a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 production-\u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u0441 Telegram-\u0441\u0435\u0441\u0441\u0438\u0435\u0439 \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c:<\/p>\n<ol>\n<li>\n<p><strong>\u041e\u0434\u0438\u043d client per session<\/strong>\u00a0&#8212; \u0441\u0442\u0440\u043e\u0433\u043e (\u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b \u0432\u044b\u0448\u0435)<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435 \u043a\u043e\u043c\u043c\u0438\u0442\u0438\u0442\u044c\u00a0<\/strong><code><strong>.env<\/strong><\/code>\u00a0\u0441\u00a0<code>MTPROTO_SESSION<\/code>\u00a0\u0432 git. \u041d\u0438\u043a\u043e\u0433\u0434\u0430. Session-string \u0434\u0430\u0451\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0443, \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u0435\u043d \u043f\u0430\u0440\u043e\u043b\u044e<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/strong>\u00a0&#8212; \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 user_id, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441\u00a0<code>@username<\/code>\u00a0\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/p>\n<\/li>\n<li>\n<p><strong>CORS \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c<\/strong>\u00a0&#8212; \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e server-side \u0438\u0437 n8n, \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u0442\u0443\u0434\u0430 \u043d\u0435 \u0445\u043e\u0434\u0438\u0442<\/p>\n<\/li>\n<li>\n<p><code><strong>systemd-run<\/strong><\/code><strong>\u00a0\u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439<\/strong>, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e reauth &#8212;\u00a0<code>nohup<\/code>\u00a0\u0438\u00a0<code>tmux<\/code>\u00a0\u0447\u0435\u0440\u0435\u0437 SSH \u043d\u0435\u043d\u0430\u0434\u0451\u0436\u043d\u044b \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u044b\u0432\u0435 SSH-\u0441\u0435\u0441\u0441\u0438\u0438, \u0441\u043a\u0440\u0438\u043f\u0442 \u0443\u043c\u0438\u0440\u0430\u0435\u0442 \u043d\u0430 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435, \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u0443-\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<h3>\u0427\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435<\/h3>\n<p>Production MTProto user-\u0431\u043e\u0442 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u043d\u0430\u0431\u043e\u0440\u0443 \u043f\u0440\u0430\u0432\u0438\u043b, \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b \u0434\u043e \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043d\u0430\u0440\u0443\u0448\u0438\u0448\u044c \u0438\u0445:<\/p>\n<ul>\n<li>\n<p>Singleton-\u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441 (\u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c)<\/p>\n<\/li>\n<li>\n<p>WARP SOCKS5 \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 DPI \u0441 \u0420\u0424-VPS<\/p>\n<\/li>\n<li>\n<p>Mutual contact \u0438 \u043b\u044c\u0433\u043e\u0442\u043d\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 &#8212; \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043f\u043e\u0434 \u044d\u0442\u043e<\/p>\n<\/li>\n<li>\n<p>Opt-out \u044e\u0437\u0435\u0440\u0430 &#8212; fallback \u043d\u0430 invite-link \u0441 \u0430\u0432\u0442\u043e\u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/li>\n<li>\n<p><code>@username<\/code>\u00a0\u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u043c numeric id<\/p>\n<\/li>\n<li>\n<p>Keepalive + ensure_connected + warmup &#8212; \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0431\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 &#8212; \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043c\u0430\u0441\u0441\u0430 \u043a\u043e\u0434\u0430 \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 edge cases. \u0421\u0430\u043c\u043e\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 &#8212; \u043f\u043e\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0438 5 \u0433\u0440\u0430\u0431\u043b\u0435\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442, \u0434\u043e \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0441\u0435\u0440\u0432\u0438\u0441 \u0443\u0435\u0445\u0430\u043b \u043a \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0432 production.<\/p>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0432\u00a0<a href=\"https:\/\/bot-craft.ru\/?utm_source=habr\" rel=\"noopener noreferrer nofollow\">BotKraft<\/a>\u00a0&#8212; \u043f\u0438\u0448\u0438\u0442\u0435 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043a\u0435\u0439\u0441 \u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0435\u0439 Telegram \u043f\u043e\u0434 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b.<\/p>\n<h3>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.telethon.dev\/\" rel=\"noopener noreferrer nofollow\">Telethon docs<\/a>\u00a0&#8212; \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043f\u043e MTProto \u0432 Python<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/core.telegram.org\/methods\" rel=\"noopener noreferrer nofollow\">Telegram API docs (MTProto methods)<\/a>\u00a0&#8212; \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developers.cloudflare.com\/warp-client\/get-started\/linux\/\" rel=\"noopener noreferrer nofollow\">Cloudflare WARP CLI<\/a>\u00a0&#8212; \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u0430 Linux<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developers.cloudflare.com\/cloudflare-one\/connections\/connect-networks\/\" rel=\"noopener noreferrer nofollow\">Cloudflare Tunnel<\/a>\u00a0&#8212; \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u0435\u0437 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u043f\u043e\u0440\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/fastapi.tiangolo.com\/advanced\/events\/\" rel=\"noopener noreferrer nofollow\">FastAPI lifespan<\/a>\u00a0&#8212; Singleton-pattern \u0434\u043b\u044f \u0434\u043e\u043b\u0433\u043e\u0436\u0438\u0432\u0443\u0449\u0438\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432<\/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\/1034612\/\">https:\/\/habr.com\/ru\/articles\/1034612\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Production MTProto user-\u0431\u043e\u0442 \u043d\u0430 FastAPI + Telethon: WARP \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 DPI \u0438 5 \u0433\u0440\u0430\u0431\u043b\u0435\u0439 \u0441 Telegram\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432 \u043f\u043e Telegram-\u0431\u043e\u0442\u0430\u043c \u0432\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u0443\u0441\u043a\u0430 \u043a\u043e\u0434\u0430: \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u043e\u043a\u0435\u043d \u0443 @BotFather, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438\u00a0python-telegram-bot\u00a0\u0438\u043b\u0438\u00a0aiogram, \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0445\u0435\u043d\u0434\u043b\u0435\u0440, deploy. \u042d\u0442\u043e Bot API. \u0418 \u0432 90% \u0437\u0430\u0434\u0430\u0447 \u044d\u0442\u043e\u0433\u043e \u0445\u0432\u0430\u0442\u0430\u0435\u0442.\u0410 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e Bot API \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435:\u00a0\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f\u0443 \u043f\u043e\u0434 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u043d\u0443\u0436\u043d\u044b\u0445 \u043b\u044e\u0434\u0435\u0439 \u043f\u043e\u00a0@username, \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0440\u0430\u0437 \u0432 \u0434\u0435\u043d\u044c. Bot API \u0442\u0430\u043a\u043e\u0435 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0434\u0430\u0436\u0435 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 &#8212; \u043c\u0435\u0442\u043e\u0434\u0430 \u00ab\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0443\u00bb \u0442\u0430\u043c \u043d\u0435\u0442, \u043c\u0435\u0442\u043e\u0434\u0430 \u00ab\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044e\u0437\u0435\u0440\u0430 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443\u00bb \u0442\u043e\u0436\u0435. \u041b\u0435\u0437\u0435\u0442\u0435 \u0432\u00a0\u043f\u043e\u043b\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e Telegram API\u00a0\u0438\u0441\u043a\u0430\u0442\u044c \u043e\u0431\u0445\u043e\u0434, \u0443\u043f\u0438\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b \u00a0channels.createChannel\u00a0 \/\u00a0 channels.inviteToChannel \u043f\u043e\u0434 MTProto, \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f &#8212; \u043d\u0435 Bot API, \u0430 user-\u0431\u043e\u0442 \u0447\u0435\u0440\u0435\u0437\u00a0telethon.\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e \u043a\u0430\u043a \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 production MTProto user-\u0431\u043e\u0442 \u043d\u0430 FastAPI + Telethon. \u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c: Cloudflare WARP \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 DPI (\u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0441 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e VPS \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f), Singleton-\u043a\u043b\u0438\u0435\u043d\u0442 \u0441 keepalive, in-memory cache resolve-\u044e\u0437\u0435\u0440\u043e\u0432, \u0438\u00a05 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 Telegram \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u043d\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043a\u0442\u043e \u043b\u0435\u0437 \u0442\u0443\u0434\u0430 \u043d\u043e\u0433\u0430\u043c\u0438. \u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0439 production-\u0441\u0435\u0440\u0432\u0438\u0441 \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432 \u043d\u0438\u0448\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430\/\u043c\u043e\u043d\u0442\u0430\u0436\u0430, \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u0432\u044f\u0437\u043a\u0443 Planfix \u2192 Telegram-\u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442.\u0421\u0435\u0440\u0432\u0438\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 Python 3.11. \u0421\u0442\u0435\u043a: Telethon 1.43.2, FastAPI 0.136.1, Uvicorn 0.46.0, Pydantic 2.13.4. \u041d\u0430 VPS \u043f\u043e\u0434\u00a0systemd, \u043d\u0430\u0440\u0443\u0436\u0443 \u0447\u0435\u0440\u0435\u0437 Cloudflare Tunnel. \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 n8n \u0447\u0435\u0440\u0435\u0437 HTTP-\u043d\u043e\u0434\u0443.\u041a\u043e\u0433\u0434\u0430 MTProto user-\u0431\u043e\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u0435\u043d\u0418\u0434\u0442\u0438 \u0432 MTProto \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 Bot API \u0443\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0432\u043e\u0438 \u043f\u043e\u0442\u043e\u043b\u043a\u0438. \u0418 \u043d\u0435 \u00ab\u043b\u0435\u043d\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f\u00bb, \u0430\u00a0\u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0435\u0442 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435\u00a0&#8212; \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 Bot API \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a.\u0427\u0442\u043e Bot API \u0434\u0435\u043b\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e:\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 inline-\u043a\u043d\u043e\u043f\u043e\u043a \u0438 callback-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438\/\u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438 (\u0435\u0441\u043b\u0438 \u0431\u043e\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0430\u0434\u043c\u0438\u043d\u043e\u043c):\u00a0banChatMember,\u00a0unbanChatMember,\u00a0pinChatMessage,\u00a0setChatTitle\u041f\u0440\u0438\u0451\u043c\u00a0chat_join_request\u00a0\u0438\u00a0approveChatJoinRequest\u00a0\/\u00a0declineChatJoinRequest\u00a0&#8212; \u0442\u043e \u0435\u0441\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0432\u0445\u043e\u0434\u0430 \u043f\u043e invite-link\u0427\u0442\u043e Bot API\u00a0\u043d\u0435 \u0443\u043c\u0435\u0435\u0442:\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f\u044b. \u0421\u043e\u0432\u0441\u0435\u043c. \u041c\u0435\u0442\u043e\u0434\u0430 \u043d\u0435\u0442\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u044e\u0437\u0435\u0440\u043e\u0432 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443. \u0411\u043e\u0442 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0438\u043a\u043e\u0433\u043e \u00ab\u0437\u0430\u0442\u0430\u0449\u0438\u0442\u044c\u00bb \u0432\u043d\u0443\u0442\u0440\u044c &#8212; \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u0430\u044f\u0432\u043a\u0438 \u043e\u0442 \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u0440\u0438\u0448\u0451\u043b \u043f\u043e invite-link\u0420\u0435\u0437\u043e\u043b\u0432\u0438\u0442\u044c\u00a0@username\u00a0\u2194\u00a0user_id. \u041d\u0438\u043a\u0430\u043a\u0421\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0430\u043b\u043e\u0433 \u0441 \u044e\u0437\u0435\u0440\u043e\u043c \u043f\u0435\u0440\u0432\u044b\u043c (\u043d\u0443\u0436\u0435\u043d\u00a0\/start\u00a0\u043e\u0442 \u044e\u0437\u0435\u0440\u0430)\u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u044d\u0442\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0435\u0441\u0442\u044c \u0432 MTProto. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0434\u0432\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 &#8212; \u044d\u0442\u043e \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u0434 \u0437\u0430 user-\u0431\u043e\u0442\u0430.\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u043d\u0438\u0448\u0430 \u043c\u043e\u043d\u0442\u0430\u0436\u0430\/\u0440\u0435\u043c\u043e\u043d\u0442\u0430\/\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430, \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0441 \u043f\u043e\u0434\u0440\u044f\u0434\u0447\u0438\u043a\u0430\u043c\u0438 \u0438 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430\u043c\u0438) \u0431\u044b\u043b \u0437\u0430\u043f\u0440\u043e\u0441:\u00a0\u043a\u0430\u0436\u0434\u0430\u044f \u043d\u043e\u0432\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0432 Planfix \u0434\u043e\u043b\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c Telegram-\u0447\u0430\u0442 \u0441\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430\u043c\u0438 \u0438\u0437 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u0430 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0435\u043a\u0442 3-10 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0420\u0430\u043d\u044c\u0448\u0435 \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0440\u0443\u043a\u0430\u043c\u0438 \u0434\u0435\u043b\u0430\u043b project-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\/\u043e\u0444\u0438\u0441-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440: \u0441\u043e\u0437\u0434\u0430\u0451\u0448\u044c \u0433\u0440\u0443\u043f\u043f\u0443, \u0438\u0449\u0435\u0448\u044c \u043b\u044e\u0434\u0435\u0439 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0435, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0448\u044c, \u043f\u043e\u0442\u043e\u043c \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u0430\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 &#8212; \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u0430\u0432\u0438\u0448\u044c \u0440\u0443\u043a\u0430\u043c\u0438. \u041d\u0430 \u0431\u043e\u0442 \u044d\u0442\u0430 \u0440\u043e\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043f\u043e\u0447\u0442\u0438 \u043d\u0430 100%.\u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0447\u0435\u0440\u0435\u0437 MTProto \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c:\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f\u044b (\u0442\u043e\u043b\u044c\u043a\u043e MTProto)\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u043f\u043e\u00a0@username\u00a0\u0438\u0437 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 Planfix (\u0442\u043e\u043b\u044c\u043a\u043e MTProto)Resolve\u00a0id \u2194 @username\u00a0(\u0442\u043e\u043b\u044c\u043a\u043e MTProto)Bot API \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0441\u0432\u044f\u0437\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u043e\u0439:\u00a0banChatMember\/unbanChatMember\u00a0\u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430,\u00a0approveChatJoinRequest\u00a0\u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u0445\u0441\u044f \u0447\u0435\u0440\u0435\u0437 invite-link, pin \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u0432. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u0447\u0435\u0440\u0435\u0437 MTProto user-\u0431\u043e\u0442\u0430, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0435\u0440\u0435\u0437 Bot API.\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u041f\u0435\u0440\u0435\u0434 \u043a\u043e\u0434\u043e\u043c &#8212; \u043e\u0431\u0449\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430. \u0427\u0442\u043e \u0435\u0441\u0442\u044c \u0432 production:   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502      Planfix (event source)          \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                    \u2502 webhook                    \u25bc   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502   n8n (orchestrator, 56 \u043d\u043e\u0434)         \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                    \u2502 HTTP + X-API-Key                    \u25bc   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502  FastAPI service (mtproto-api)       \u2502   \u2502  \u251c\u2500 Singleton TelegramClient         \u2502   \u2502  \u251c\u2500 \/create-group  \/add-users        \u2502   \u2502  \u2502  \/resolve-user  \/health           \u2502   \u2502  \u2514\u2500 keepalive 180s + ensure_connected\u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                    \u2502 MTProto                    \u25bc   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502  Cloudflare WARP (SOCKS5 :40000)     \u2502   \u2502  \u043e\u0431\u0445\u043e\u0434 \u0420\u041a\u041d-DPI                       \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                    \u25bc   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502       Telegram MTProto API           \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\u0421\u043d\u0430\u0440\u0443\u0436\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 Cloudflare Tunnel (mtproto.example.ru\u00a0\u2192\u00a0localhost:8080), \u043f\u043e\u0440\u0442 8080 \u043d\u0430 \u0441\u0430\u043c VPS \u043d\u0430\u0440\u0443\u0436\u0443 \u043d\u0435 \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 HTTP &#8212; \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a\u00a0X-API-Key\u00a0(\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437\u00a0openssl rand -base64 32), \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 FastAPI dependency \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c endpoint.Endpoints:\u041c\u0435\u0442\u043e\u0434\u041f\u0443\u0442\u044c\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435GET\/health\u0421\u0442\u0430\u0442\u0443\u0441 MTProto-\u0441\u0435\u0441\u0441\u0438\u0438, \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0431\u0435\u0437 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438POST\/create-group\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0443\u043f\u0435\u0440\u0433\u0440\u0443\u043f\u043f\u0443, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0431\u043e\u0442\u0430 \u0438 \u0430\u0434\u043c\u0438\u043d\u043e\u0432, \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432POST\/add-users\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432\/\u0430\u0434\u043c\u0438\u043d\u043e\u0432 \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0443POST\/resolve-userResolve id \u2194 username, \u0441 in-memory \u043a\u0435\u0448\u0435\u043c + deep_search \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0430\u043cGET\/cache-stats\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0435\u0448\u0430 resolve-\u044e\u0437\u0435\u0440\u043e\u0432\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u00a0\/create-group\u00a0\u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:POST \/create-groupX-API-Key: &lt;secret&gt;Content-Type: application\/json{  &#171;title&#187;: &#171;\u041f\u0440\u043e\u0435\u043a\u0442 \u041e\u0431\u044a\u0435\u043a\u0442-42 \u041c\u043e\u0441\u043a\u0432\u0430&#187;,  &#171;description&#187;: &#171;\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430&#187;,  &#171;admins&#187;: [&#171;@admin_username&#187;],  &#171;users&#187;: [&#171;@team_member1&#187;, &#171;@team_member2&#187;],  &#171;request_approval&#187;: true}\u0412 \u043e\u0442\u0432\u0435\u0442\u0435 &#8212;\u00a0chat_id\u00a0\u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Bot API (\u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c\u00a0-100, \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 Bot API),\u00a0invite_link, \u0438\u00a0\u043a\u0440\u0438\u0442\u0438\u0447\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430 \u0434\u043b\u044f production &#8212; \u0441\u043b\u043e\u0432\u0430\u0440\u0438\u00a0*_errors\u00a0\u0441 pereason&#8217;\u043e\u043c \u0435\u0441\u043b\u0438 \u043a\u043e\u0433\u043e-\u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c:{  &#171;status&#187;: &#171;ok&#187;,  &#171;chat_id&#187;: -1001234567890,  &#171;invite_link&#187;: &#171;https:\/\/t.me\/+abc&#8230;&#187;,  &#171;bot_added&#187;: true,  &#171;admins_added&#187;: [&#171;admin_username&#187;],  &#171;admins_errors&#187;: {},  &#171;users_added&#187;: [&#171;team_member1&#187;],  &#171;users_errors&#187;: {&#171;team_member2&#187;: &#171;user_privacy_restricted&#187;}}\u0422\u043e \u0435\u0441\u0442\u044c HTTP-\u0441\u0442\u0430\u0442\u0443\u0441 200, \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430, \u043d\u043e\u00a0team_member2\u00a0\u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439. n8n \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c fallback &#8212; \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0431\u043e\u0442\u0430 \u043b\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u0430 \u0438\u0437\u00a0*_errors, \u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u044e\u0437\u0435\u0440\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 invite-link, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043e\u043d \u0441\u0430\u043c \u043a\u043b\u0438\u043a\u043d\u0435\u0442 \u0438 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443.\u0422\u0435\u043f\u0435\u0440\u044c \u043a \u0441\u0430\u043c\u043e\u0439 \u0442\u044f\u0436\u0451\u043b\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 &#8212; \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u0441\u0451 \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e VPS.\u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u0431\u043b\u043e\u043a\u0435\u0440: \u0420\u041a\u041d-DPI \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 MTProto-\u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c Telethon-\u043a\u043b\u0438\u0435\u043d\u0442 \u0441 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e VPS \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0435:ConnectionError: Connection to Telegram failed 5 time(s)\u041d\u0435 resolve hostname&#8217;\u0430, \u043d\u0435 TLS-\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043d\u0435 firewall. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u00a0\u0420\u041a\u041d-DPI \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0451\u0442 MTProto-\u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435 \u043f\u0430\u043a\u0435\u0442\u0430\u00a0\u0438 \u0440\u0435\u0436\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 TCP. \u041e\u0431\u0444\u0443\u0441\u043a\u0430\u0446\u0438\u044f, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0432 Telethon (ConnectionTcpObfuscated), \u043d\u0430 \u044d\u0442\u043e \u043d\u0435 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 &#8212; DPI \u0435\u0451 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0432\u0438\u0434\u0438\u0442.\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u043b \u0441\u0435\u0440\u0432\u0438\u0441 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0431\u0435\u0437 \u043e\u0431\u0445\u043e\u0434\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b:\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 DC (datacenters Telegram) &#8212; \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0412\u0441\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b\u00a0connection\u00a0\u0432 Telethon (ConnectionTcpFull,\u00a0ConnectionTcpIntermediate,\u00a0ConnectionTcpAbridged,\u00a0ConnectionTcpObfuscated) &#8212; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0442 \u0436\u0435\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 &#8212;\u00a0Cloudflare WARP \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 SOCKS5 \u043d\u0430 127.0.0.1:40000. \u0427\u0442\u043e \u044d\u0442\u043e:WARP &#8212; VPN-\u043a\u043b\u0438\u0435\u043d\u0442 Cloudflare, \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f\u00a0warp-cli\u00a0\u043f\u043e\u0434 Linux. \u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439\u041f\u043e\u0441\u043b\u0435\u00a0warp-cli connect\u00a0&#8212; \u0432\u0435\u0441\u044c \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0442\u0440\u0430\u0444\u0438\u043a \u0441 VPS \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 CF-\u0441\u0435\u0442\u044c. \u0412\u043d\u0435\u0448\u043d\u0438\u0439 IP \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 CF Moscow (DPI \u0435\u0433\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0440\u0430\u0444\u0438\u043a \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d \u043c\u0435\u0436\u0434\u0443 VPS \u0438 CF \u0438 \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 HTTPS \u043d\u0430 CF)Telethon \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 SOCKS5 \u0447\u0435\u0440\u0435\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 40000 (\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 WARP SOCKS-\u0440\u0435\u0436\u0438\u043c)\u0412 Telethon \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:from telethon import TelegramClientfrom telethon.network.connection import ConnectionTcpFullimport socksPROXY = (socks.SOCKS5, &#171;127.0.0.1&#187;, 40000)client = TelegramClient(    &#171;session&#187;,    API_ID,    API_HASH,    connection=ConnectionTcpFull,    proxy=PROXY,)\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e\u00a0client.start()\u00a0\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0436\u0438\u0432\u043e\u0441\u0442\u0438 WARP:warp-cli status        # \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f: Connectedcurl &#8212;socks5 127.0.0.1:40000 -m 10 https:\/\/ipinfo.io\/# \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0435\u0440\u043d\u0443\u0442\u044c IP \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Cloudflare MoscowWARP \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0441\u043b\u0435\u00a0systemctl enable warp-svc. \u0417\u0430 \u0432\u0441\u0451 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u0430 WARP \u043d\u0435 \u043f\u0430\u0434\u0430\u043b \u043d\u0438 \u0440\u0430\u0437\u0443 &#8212; \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0441 VPS, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0440\u0438\u0441\u043a \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0438\u0434\u0435\u043b &#8212; \u043f\u043e\u0441\u043b\u0435\u00a0reboot\u00a0VPS WARP \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e, \u0438 \u0435\u0441\u043b\u0438\u00a0mtproto-api.service\u00a0\u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0440\u0430\u043d\u044c\u0448\u0435, \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043e\u043d\u043d\u0435\u043a\u0442 \u043a Telegram \u043f\u0430\u0434\u0430\u0435\u0442 \u0441\u00a0ConnectionError. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 &#8212; startup-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u00a0mtproto-api.service\u00a0\u043e\u0442\u00a0warp-svc:[Unit]Description=MTProto FastAPI serviceAfter=network-online.target warp-svc.serviceRequires=warp-svc.service[Service]ExecStart=\/opt\/mtproto-api\/venv\/bin\/uvicorn app:app &#8212;host 127.0.0.1 &#8212;port 8080Restart=on-failure\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0435 reconnect&#8217;\u044b \u0432 journald &#8212; \u044d\u0442\u043e keepalive \u043f\u043e\u0441\u043b\u0435 idle-\u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430, \u043d\u0435 WARP-\u0438\u043d\u0446\u0438\u0434\u0435\u043d\u0442\u044b.\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b WARP&#8217;\u0443 &#8212; \u043f\u043b\u0430\u0442\u043d\u044b\u0439 VPS \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0441 \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u0420\u0424 \u043b\u0438\u0431\u043e \u0441\u0432\u043e\u0439 MTProxy \u043d\u0430 foreign-\u0445\u043e\u0441\u0442\u0435. \u0414\u043e\u0440\u043e\u0436\u0435, \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0430\u0449\u0435 \u043e\u0431\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043b\u044e\u0441 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435. WARP \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439, \u043d\u0430\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 Linux, \u0438 \u0441\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 DPI \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u044f.Singleton TelegramClient &#8212; \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0436\u0438\u0440\u043d\u043e\u0439 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0447\u0435\u0440\u0442\u043e\u0439 \u043f\u043e\u0441\u043b\u0435 \u0434\u0432\u0443\u0445 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0439 \u0441\u0435\u0441\u0441\u0438\u0438:\u00a0\u043e\u0434\u0438\u043d MTPROTO_SESSION = \u043e\u0434\u0438\u043d TelegramClient \u0432 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 Python-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 session-\u0441\u0442\u0440\u043e\u043a\u043e\u0439.\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 (\u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0446\u0438\u0434\u0435\u043d\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430): \u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u00a0check_user.py\u00a0\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c\u00a0mtproto-api. \u041e\u0431\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441\u0442\u0443\u0447\u0430\u043b\u0438\u0441\u044c \u0432 Telegram \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c session-string. Telegram security-\u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043b\u043e\u0432\u0438\u0442 \u044d\u0442\u043e \u043a\u0430\u043a \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c (\u00ab\u043e\u0434\u0438\u043d \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u0438\u0442\u0441\u044f \u0441 \u0434\u0432\u0443\u0445 \u043c\u0435\u0441\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u00bb) \u0438 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442\u00a0AUTH_KEY_UNREGISTERED\u00a0\u0441\u0442\u0430\u0440\u0448\u0435\u043c\u0443 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0421\u0435\u0441\u0441\u0438\u044f \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0430\u0434\u0430\u0435\u0442, \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 reauth.\u0414\u0432\u0430\u0436\u0434\u044b \u0437\u0430 \u043e\u0434\u0438\u043d \u0434\u0435\u043d\u044c \u0432\u043b\u0435\u0442\u0435\u043b \u0432 \u044d\u0442\u0443 \u044f\u043c\u0443 (\u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0430 \u0434\u0443\u043c\u0430\u043b \u00ab\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u044c\u00bb,&#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-479566","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/479566","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=479566"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/479566\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=479566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=479566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=479566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}