{"id":393702,"date":"2024-06-29T11:10:09","date_gmt":"2024-06-29T11:10:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=393702"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=393702","title":{"rendered":"<span>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 API \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 MTProto<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0443\u0436\u0435\u00a0 \u0434\u0430\u043b\u0435\u043a\u043e\u043c 2019 Telegram \u043e\u0431\u044a\u044f\u0432\u0438\u043b \u043a\u043e\u043d\u043a\u0443\u0440\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0431-\u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u043c\u0435\u0441\u0441\u0435\u043d\u0434\u0436\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c. \u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u0443 \u043c\u0435\u043d\u044f \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 API Telegram \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 MTProto. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b \u043c\u0435\u043d\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b MTProto \u0434\u043b\u044f \u0431\u044d\u043a\u0435\u043d\u0434\u0430. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u0435\u043b \u043d\u0430 python, \u0442\u0430\u043a \u043a\u0430\u043a \u044f \u044d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u044e \u0438 \u0431\u044b\u043b \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0441\u043c\u043e\u0433\u0443 \u043d\u0430 \u043d\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0438\u0434\u0435\u044e. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 aiohttp \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u043e web-socket\u2019\u0443, \u0430 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b typings \u0438 dataclass.<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c2d\/200\/99a\/c2d20099a94a649baad2087461fd7cde.png\" width=\"900\" height=\"400\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c2d\/200\/99a\/c2d20099a94a649baad2087461fd7cde.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 MTProto: <\/h2>\n<p>\u00a0\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b MTProto \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0442\u0440\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<ol>\n<li>\n<p>\u0412\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c (API \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u043d\u0435\u043c\u0443) &#8212; \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0432\u044b\u0437\u043e\u0432\u044b \u0438 \u043e\u0442\u0432\u0435\u0442\u044b API \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0430\u044f (\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f) \u0447\u0430\u0441\u0442\u044c\u00a0 &#8212; \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u044b\/\u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c &#8212; \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432: (HTTP, HTTPS, WS, WSS, TCP, UDP)<\/p>\n<\/li>\n<\/ol>\n<h2>\u0412\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c API &#8212; \u0421\u0445\u0435\u043c\u0430(schema)<\/h2>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f API. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0445\u0435\u043c\u0435 \u043a\u043b\u0438\u0435\u043d\u0442 \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u043a \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c\/\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0421\u0445\u0435\u043c\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <a href=\"https:\/\/core.telegram.org\/mtproto\/TL\" rel=\"noopener noreferrer nofollow\"><u>\u044f\u0437\u044b\u043a\u0435 TL<\/u><\/a> \u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e JSON.<\/p>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b:<\/h3>\n<p>\u041f\u0440\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432, \u0442\u0438\u043f\u043e\u0432, \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432 \u0441\u0445\u0435\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b int, long, doubles, bytes, string. \u0414\u043b\u044f \u043d\u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043a\u0430\u043a \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442\u00a0 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b:<\/p>\n<ol>\n<li>\n<p><strong>int<\/strong> &#8212; 32 \u0431\u0438\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0446\u0435\u043b\u043e\u0435, \u0434\u043b\u044f \u0434\u0430\u043c\u043f\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f little-endian \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0430\u0439\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p><strong>long<\/strong> &#8212; 64 \u0431\u0438\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0446\u0435\u043b\u043e\u0435, \u0434\u043b\u044f \u0434\u0430\u043c\u043f\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f little-endian \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0430\u0439\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p><strong>double<\/strong> &#8212; 64 \u0431\u0438\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439<\/p>\n<\/li>\n<li>\n<p><strong>bytes<\/strong> &#8212; \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0430\u0439\u0442\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b:<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u0430 253, \u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0430\u0439\u0442 \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u043b\u0438\u043d\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0431\u0430\u0439\u0442\u044b \u0442\u0430\u043a, \u0447\u0442\u043e \u043e\u0431\u0449\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u043b\u0438\u043b\u0430\u0441\u044c \u043d\u0430 4. <\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438\u00a0 \u0431\u043e\u043b\u044c\u0448\u0435 253, \u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0430\u0439\u0442 \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e 254, \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0434\u0443\u0442 3 \u0431\u0430\u0439\u0442\u0430 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 little-endian,\u00a0 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0434\u043b\u0438\u043d\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0441\u0430\u043c\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u0443 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0431\u0430\u0439\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0449\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0434\u0435\u043b\u0438\u043b\u0430\u0441\u044c \u043d\u0430 4.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>string <\/strong>&#8212; \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0438\u0437 UTF-8 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0447\u0442\u043e \u0438 \u0434\u043b\u044f bytes. <\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 MTProto \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0438\u043f\u044b <strong>int128\/int256,<\/strong> \u043d\u043e \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<h3>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0438 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445:<\/h3>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0421\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 &#8212; \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440. \u0410\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0438\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 python \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c <code>dataclass<\/code>. \u041e\u0431\u044a\u044f\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432\u0441\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430(\u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0431\u044b\u0442\u044c \u0432\u043e\u0432\u0441\u0435). \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441<code>Meta<\/code>,\u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>name<\/code> \u0438 <code>order<\/code>. \u0412 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 <code>name<\/code> \u0445\u0440\u0430\u043d\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u00a0 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0430 \u0432 <code>order<\/code> &#8212; \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\/\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430. <\/p>\n<pre><code class=\"python\">from dataclasses import dataclass  from aiohttp import web  from mtpylon import Schema   @dataclass class Reply:     rand_id: int     content: str      class Meta:         name = 'reply'         order = ('rand_id', 'content')<\/code><\/pre>\n<p>\u0423 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u0430 <code>Optional<\/code> \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>dataclasses.field<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>flag<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0439 \u0431\u0438\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 <code>flag<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c \u0442\u043e\u0433\u043e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d \u0438\u043b\u0438 \u043d\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442.<\/p>\n<pre><code class=\"python\">from dataclasses import dataclass, field  @dataclass class AuthorizedUser:     id: int     username: str     password: str     avatar_url: Optional[str] = field(metadata={'flag': 0})      class Meta:         name = 'authorizedUser'         order = ('id', 'username', 'password', 'avatar_url')<\/code><\/pre>\n<p>\u0410\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a. \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0438\u043f <code>typing.List<\/code> \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430<\/p>\n<pre><code class=\"python\">from typing import List from dataclasses import dataclass  from .task import Task   @dataclass class TaskList:     tasks: List[Task]     class Meta:        name = 'task_list'        order = ('tasks',)<\/code><\/pre>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0438\u043f\u044b \u044f\u0437\u044b\u043a\u0430 <code>Union<\/code> \u0438 <code>Annotated<\/code>:<\/p>\n<pre><code class=\"python\">@dataclass class BoolTrue:    class Meta:        name = 'boolTrue'   @dataclass class BoolFalse:    class Meta:        name = 'boolFalse'   Bool = Annotated[    Union[BoolTrue, BoolFalse],    'Bool' ]    @dataclass class AnonymousUser:    class Meta:        name = 'anonymous_user'   @dataclass class RegisteredUser:    id: int    nickname: str     class Meta:        name = 'registered_user'         order = ('id', 'nickname')   User = Annotated[    Union[        AnonymousUser,        RegisteredUser    ],    'User' ]<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\/\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u044b\u043b \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d.\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 32-\u0431\u0438\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c <strong>crc32<\/strong>.<\/p>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 &#8212; \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code>constructor_name attr_1:AttrType attr_2:AttrType2 \u2026 attr_name_n=AttrTypeN = ResType<\/code><\/pre>\n<p>\u0417\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c\/\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.\u00a0<\/p>\n<p>\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 <code>RegisteredUser<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0442\u0438\u043f\u0443 <code>User<\/code>,\u00a0 \u0431\u0443\u0434\u0435\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430:<\/p>\n<pre><code>registered_user id:int nickname:string = User<\/code><\/pre>\n<p>\u0410 \u0447\u0438\u0441\u043b\u043e \u0431\u0443\u0434\u0435\u0442 <code>-366049798<\/code><\/p>\n<h3>\u0424\u0443\u043d\u043a\u0446\u0438\u0438<\/h3>\n<p>\u0412\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0431\u0443\u0434\u0443\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438. \u041f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f request &#8212; \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 <code>aiohttp.web.Request<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043e\u0431\u0449\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0431\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0435, \u043b\u0438\u0431\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b. \u0412\u0441\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438.\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0442\u0438\u043f.\u00a0<\/p>\n<pre><code class=\"python\">from aiohttp.web import Request from mtpylon.crypto import AuthKey from mtpylon.exceptions import RpcCallError from mtpylon.contextvars import auth_key_var  from users.utils import login_user, remember_user from ..constructors import User, RegisteredUser   async def login(request: Request, nickname: str, password: str) -> User:    try:        user = await login_user(nickname, password)    except ValueError as e:        raise RpcCallError(error_code=401, error_message=str(e))     auth_key: AuthKey = auth_key_var.get()    await remember_user(user, auth_key)     return RegisteredUser(id=user.id, nickname=nickname)<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u043e\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 crc32 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"python\">function_name arg_1:ArgType arg_2:ArgType2 \u2026 arg_name_n=ArgTypeN = ResType<\/code><\/pre>\n<h4>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/h4>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e WebSocket \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<h3>\u0421\u0445\u0435\u043c\u0430<\/h3>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0431\u044d\u043a\u0435\u043d\u0434\u0430, \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u0441\u0445\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <code>mtpylon.Schema<\/code><\/p>\n<pre><code class=\"python\">from mtpylon import Schema   from .constructors import (    Bool,    User,    TodoList,    TodoListsResult,    Task,    TaskList ) from .functions import (    register,    login,    get_me,    create_todo_list,    get_todo_lists,    get_single_todo_list,    remove_todo_list,    create_task,    get_task_list,    edit_task_title,    set_as_completed,    set_as_uncompleted,    remove_task, )  mtpylon_schema = Schema(    constructors=[        Bool,        User,        TodoList,        TodoListsResult,        Task,        TaskList    ],    functions=[        register,        login,        get_me,        create_todo_list,        get_todo_lists,        get_single_todo_list,        remove_todo_list,        create_task,        get_task_list,        edit_task_title,        set_as_completed,        set_as_uncompleted,        remove_task,    ]<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432 \u0441\u0445\u0435\u043c\u0443, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0435\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u043e \u0432 TL-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043b\u0438\u0431\u043e \u0432 JSON, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>mtpylon.serializers.to_tl_program()<\/code> \u0438\u043b\u0438 <code>mtpylon.serializers.to_json()<\/code>. \u0417\u043d\u0430\u044f \u043a\u0430\u043a \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c.<\/p>\n<h2>\u041a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0430\u044f(\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f) \u0447\u0430\u0441\u0442\u044c.<\/h2>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 <a href=\"https:\/\/core.telegram.org\/mtproto\" rel=\"noopener noreferrer nofollow\"><u>\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0430<\/u><\/a>.\u00a0<\/p>\n<p>\u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439: \u043d\u0435\u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.     \u041d\u0435\u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0414\u0435\u0444\u0444\u0438-\u0425\u0435\u043b\u044c\u043c\u0430\u043d\u0430.<\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/core.telegram.org\/mtproto\/auth_key\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c <\/u><\/a>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043d\u0435\u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/832\/c6d\/325\/832c6d3255ce98e9475abe736eee175d.png\" width=\"845\" height=\"115\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/832\/c6d\/325\/832c6d3255ce98e9475abe736eee175d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:<\/p>\n<ol>\n<li>\n<p>C\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439\/\u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 RSA-\u043a\u043b\u044e\u0447.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447(2048 bit). \u0423 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f 64\u0445 \u0431\u0438\u0442\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440(<code>auth_id<\/code>), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c key-value \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0441\u0432\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u0445\u0440\u0430\u043d\u044e \u0438\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043b\u0430\u0441\u0441 \u00a0<code>mtproto.crypto.auth_key_manager.AuthKeyManager<\/code>, \u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>mtproto.crypto.auth_key_manager.AuthKeyManagerProtocol<\/code>,\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043b\u044e\u0431\u043e\u0439 \u0431\u0434. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b postgresql, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u043b id \u043a\u0430\u043a BigInteger, \u0430 \u0441\u0430\u043c \u043a\u043b\u044e\u0447 \u043a\u0430\u043a BLOB.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043a\u043b\u044e\u0447 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438,\u00a0 \u043a\u043b\u0438\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0435 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fd6\/5ee\/a70\/fd65eea70b543926ea779da0ce81701a.png\" width=\"837\" height=\"266\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fd6\/5ee\/a70\/fd65eea70b543926ea779da0ce81701a.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/467\/e06\/1a1\/467e061a1bee06a374e965dce782ac4e.png\" width=\"660\" height=\"569\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/467\/e06\/1a1\/467e061a1bee06a374e965dce782ac4e.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0441\u0445\u0435\u043c\u044b, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u0435\u0441\u0441\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0441\u043e\u043b\u044c.<\/p>\n<h4>\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u0435\u0441\u0441\u0438\u0438 session_id <\/h4>\n<p>\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u0435\u0441\u0441\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0430\u0440\u0430 <code>auth_key_id<\/code> \u0438 <code>session_id<\/code> \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a <code>session_id<\/code> \u0443 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f.\u00a0<\/p>\n<p><code>session_id<\/code> &#8212; 64 \u0431\u0438\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c. <code>mtproto.sessions.sessions_storage_protocol.SessionS\u0441torageProtocol<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0431\u0434, \u0438\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>mtproto.sessions.in_memory_session_storage.InMemorySessionStorage<\/code> \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u0435\u0441\u0441\u0438\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u043b\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0441\u0435\u0441\u0441\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d observer.<\/p>\n<h4>\u0421\u043e\u043b\u044c(salt).<\/h4>\n<p><a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%BE%D0%BB%D1%8C_(%D0%BA%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D1%8F)\" rel=\"noopener noreferrer nofollow\"><u>\u0421\u043e\u043b\u044c<\/u><\/a> &#8212; 64 \u0431\u0438\u0442\u043d\u043e\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0435\u0441\u044f \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0430\u0442\u0430\u043a \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u0421\u0435\u0440\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0438 \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0443\u0449\u0435\u0435. \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0441\u043e\u043b\u044c \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0430\u0440\u0443.\u00a0 \u0414\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u043e\u043b\u044c\u044e \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d <code>mtpylon.salts.server_salt_manager.ServerSaltManager<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>mtpylon.salts.server_satl_manager_protocol.ServerSaltManagerProtocol<\/code>. <\/p>\n<h3>\u00a0\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f (acknowledgements)<\/h3>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0439 id. \u0418 \u043f\u0430\u0440\u0430 \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 + id \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430. \u0421\u0435\u0440\u0432\u0435\u0440 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u0438\u043b\u0438 \u0441\u0435\u0441\u0441\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u0431\u044b\u043b\u0430 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0430. \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043a\u043b\u0430\u0441\u0441 <code>mtpylon.acknowledgment_store.inmemory_acknowledgment_store.InmemoryAcknowledgmentStore<\/code> .<\/p>\n<h2>\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c.<\/h2>\n<p>\u0417\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 websocket. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 MTProto, \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c <a href=\"https:\/\/core.telegram.org\/mtproto\/mtproto-transports#transport-obfuscation\" rel=\"noopener noreferrer nofollow\"><u>\u043e\u0431\u0444\u0443\u0441\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043e.<\/u><\/a> \u041a\u0430\u0436\u0434\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u201c\u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f\u201d \u0432 <a href=\"https:\/\/core.telegram.org\/mtproto\/mtproto-transports#intermediate\" rel=\"noopener noreferrer nofollow\"><u>intermediate \u0431\u043b\u043e\u043a<\/u><\/a>\u00a0 \u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0444\u0443\u0441\u043a\u0430\u0446\u0438\u044e<\/p>\n<h2>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 mtpylon \u0438 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/h2>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u0432\u0441\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 MTProto, \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/github.com\/Zapix\/mtpylon\" rel=\"noopener noreferrer nofollow\"><u>mtpylon<\/u><\/a>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 API. <\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: <\/h3>\n<p>1. \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0443\u044e rsa-\u043a\u043b\u044e\u0447\u0438:<\/p>\n<p>rsa_keys.py<\/p>\n<pre><code class=\"python\">from typing import List import rsa  # type: ignore from mtpylon.crypto import KeyPair  # type: ignore   def get_rsa_keys(count: int = 2) -> List[KeyPair]:     rsa_list = [         rsa.newkeys(nbits=2048)         for _ in range(count)     ]      return [         KeyPair(             public=public,             private=private         ) for (public, private) in rsa_list     ]<\/code><\/pre>\n<p>2. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f, \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0441\u0430\u043c\u0443 \u0441\u0445\u0435\u043c\u0443:<\/p>\n<p>schema.py<\/p>\n<pre><code class=\"python\">import random from dataclasses import dataclass  from aiohttp import web  from mtpylon import Schema   @dataclass class Reply:     rand_id: int     content: str      class Meta:         name = 'reply'         order = ('rand_id', 'content')   async def echo(request: web.Request, content: str) -> Reply:     return Reply(         rand_id=random.randint(1, 100),         content=content     )   schema = Schema(constructors=[Reply], functions=[echo])<\/code><\/pre>\n<p>3. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c aiohttp \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c:<\/p>\n<p>web.py<\/p>\n<pre><code class=\"python\">import sys import logging  from aiohttp import web import aiohttp_cors  from mtpylon.configuration import configure_app  from schema import schema as app_schema from rsa_keys import get_rsa_keys   if __name__ == '__main__':     app = web.Application()     configure_app(         app,         app_schema,         {             'rsa_manager': {                 'params': {                     'rsa_keys': get_rsa_keys()  # \u0432\u0435\u0440\u043d\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438                 }             },             'pub_keys_path': '\/pub-keys',  # url \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 rsa-\u043a\u043b\u044e\u0447\u0435\u0439             'schema_path': '\/schema',  # url \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0441\u0445\u0435\u043c\u0430 \u0432 json \u0444\u043e\u0440\u043c\u0430\u0442\u0435         }     )      cors = aiohttp_cors.setup(         app,         defaults={             '*': aiohttp_cors.ResourceOptions(                 allow_credentials=True,                 expose_headers=\"*\",                 allow_headers=\"*\",             )         }     )      for route in list(app.router.routes()):         cors.add(route)      web.run_app(app, port=8081)<\/code><\/pre>\n<p>4. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>python .\/web.py <\/code><\/pre>\n<p>5. \u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/github.com\/Zapix\/zagram\" rel=\"noopener noreferrer nofollow\"><u>zagram<\/u><\/a><\/p>\n<pre><code class=\"javascript\">const { MTProto, methodFromSchema } = zagram;  const WS_URL = 'ws:\/\/localhost:8081\/ws'; const PUB_KEYS_URL = 'http:\/\/localhost:8081\/pub-keys'; const SCHEMA_URL = 'http:\/\/localhost:8081\/schema';   function initConnection(schema, pems) {   return new Promise((resolve, reject) => {     const connection = new MTProto(WS_URL, schema, pems);      connection.addEventListener('statusChanged', (e) => {        if (e.status === 'AUTH_KEY_CREATED') {          resolve([connection, schema]);        } else {          reject(e.status);        }      });       connection.init();   });     }    Promise   .all([     fetch(SCHEMA_URL).then(r => r.json()),     fetch(PUB_KEYS_URL).then(r => r.json()),   ])   .then(([schema, pems]) => initConnection(schema, pems))   .then(([connection, schema]) => {     const rpc = methodFromSchema(schema, 'echo', {'content': 'hello world'});     return connection.request(rpc);   })   .then(console.log); <\/code><\/pre>\n<h2>\u0418\u0442\u043e\u0433:<\/h2>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e Telegram, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u043b\u0438 \u043c\u043e\u0438 \u0431\u0443\u0434\u043d\u0438, \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043c\u0435\u043d\u044f \u043f\u043e\u0433\u043b\u0443\u0431\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0438 \u0440\u0435\u0448\u0430\u0442\u044c \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u044d\u0442\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0438\u043b\u0438 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u044f\u0442 \u043d\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 MTProto.<\/p>\n<p>Mtpylon:<\/p>\n<p>\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434: <a href=\"https:\/\/github.com\/Zapix\/mtpylon\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/github.com\/Zapix\/mtpylon<\/u><\/a><\/p>\n<p>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f: <a href=\"https:\/\/mtpylon.readthedocs.io\/en\/latest\/\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/mtpylon.readthedocs.io\/en\/latest\/<\/u><\/a><\/p>\n<p>Zagram:<\/p>\n<p>\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434: <a href=\"https:\/\/github.com\/Zapix\/zagram\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/github.com\/Zapix\/zagram<\/u><\/a><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439:<\/p>\n<ol>\n<li>\n<p>echo-server <a href=\"https:\/\/github.com\/Zapix\/echo-server\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/github.com\/Zapix\/echo-server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p>ToDo-list: <a href=\"https:\/\/github.com\/Zapix\/mtpylon-todo-list\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/github.com\/Zapix\/mtpylon-todo-list<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/589959\/\"> https:\/\/habr.com\/ru\/articles\/589959\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0443\u0436\u0435\u00a0 \u0434\u0430\u043b\u0435\u043a\u043e\u043c 2019 Telegram \u043e\u0431\u044a\u044f\u0432\u0438\u043b \u043a\u043e\u043d\u043a\u0443\u0440\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0431-\u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u043c\u0435\u0441\u0441\u0435\u043d\u0434\u0436\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c. \u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u0443 \u043c\u0435\u043d\u044f \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 API Telegram \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 MTProto. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b \u043c\u0435\u043d\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b MTProto \u0434\u043b\u044f \u0431\u044d\u043a\u0435\u043d\u0434\u0430. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u0435\u043b \u043d\u0430 python, \u0442\u0430\u043a \u043a\u0430\u043a \u044f \u044d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u044e \u0438 \u0431\u044b\u043b \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0441\u043c\u043e\u0433\u0443 \u043d\u0430 \u043d\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0438\u0434\u0435\u044e. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 aiohttp \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u043e web-socket\u2019\u0443, \u0430 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b typings \u0438 dataclass.<\/p>\n<figure class=\"bordered full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 MTProto: <\/h2>\n<p>\u00a0\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b MTProto \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0442\u0440\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<ol>\n<li>\n<p>\u0412\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c (API \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u043d\u0435\u043c\u0443) &#8212; \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0432\u044b\u0437\u043e\u0432\u044b \u0438 \u043e\u0442\u0432\u0435\u0442\u044b API \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0430\u044f (\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f) \u0447\u0430\u0441\u0442\u044c\u00a0 &#8212; \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u044b\/\u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c &#8212; \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432: (HTTP, HTTPS, WS, WSS, TCP, UDP)<\/p>\n<\/li>\n<\/ol>\n<h2>\u0412\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c API &#8212; \u0421\u0445\u0435\u043c\u0430(schema)<\/h2>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f API. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0445\u0435\u043c\u0435 \u043a\u043b\u0438\u0435\u043d\u0442 \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u043a \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c\/\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0421\u0445\u0435\u043c\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <a href=\"https:\/\/core.telegram.org\/mtproto\/TL\" rel=\"noopener noreferrer nofollow\"><u>\u044f\u0437\u044b\u043a\u0435 TL<\/u><\/a> \u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e JSON.<\/p>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b:<\/h3>\n<p>\u041f\u0440\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432, \u0442\u0438\u043f\u043e\u0432, \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432 \u0441\u0445\u0435\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b int, long, doubles, bytes, string. \u0414\u043b\u044f \u043d\u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043a\u0430\u043a \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442\u00a0 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b:<\/p>\n<ol>\n<li>\n<p><strong>int<\/strong> &#8212; 32 \u0431\u0438\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0446\u0435\u043b\u043e\u0435, \u0434\u043b\u044f \u0434\u0430\u043c\u043f\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f little-endian \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0430\u0439\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p><strong>long<\/strong> &#8212; 64 \u0431\u0438\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0446\u0435\u043b\u043e\u0435, \u0434\u043b\u044f \u0434\u0430\u043c\u043f\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f little-endian \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0430\u0439\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p><strong>double<\/strong> &#8212; 64 \u0431\u0438\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439<\/p>\n<\/li>\n<li>\n<p><strong>bytes<\/strong> &#8212; \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0430\u0439\u0442\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b:<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u0430 253, \u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0430\u0439\u0442 \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u043b\u0438\u043d\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0431\u0430\u0439\u0442\u044b \u0442\u0430\u043a, \u0447\u0442\u043e \u043e\u0431\u0449\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u043b\u0438\u043b\u0430\u0441\u044c \u043d\u0430 4. <\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438\u00a0 \u0431\u043e\u043b\u044c\u0448\u0435 253, \u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0430\u0439\u0442 \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e 254, \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0434\u0443\u0442 3 \u0431\u0430\u0439\u0442\u0430 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 little-endian,\u00a0 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0434\u043b\u0438\u043d\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0441\u0430\u043c\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u0443 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0431\u0430\u0439\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0449\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0434\u0435\u043b\u0438\u043b\u0430\u0441\u044c \u043d\u0430 4.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>string <\/strong>&#8212; \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0438\u0437 UTF-8 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0447\u0442\u043e \u0438 \u0434\u043b\u044f bytes. <\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 MTProto \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0438\u043f\u044b <strong>int128\/int256,<\/strong> \u043d\u043e \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<h3>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0438 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445:<\/h3>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0421\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 &#8212; \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440. \u0410\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0438\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 python \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c <code>dataclass<\/code>. \u041e\u0431\u044a\u044f\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432\u0441\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430(\u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0431\u044b\u0442\u044c \u0432\u043e\u0432\u0441\u0435). \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441<code>Meta<\/code>,\u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>name<\/code> \u0438 <code>order<\/code>. \u0412 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 <code>name<\/code> \u0445\u0440\u0430\u043d\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u00a0 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0430 \u0432 <code>order<\/code> &#8212; \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\/\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430. <\/p>\n<pre><code class=\"python\">from dataclasses import dataclass  from aiohttp import web  from mtpylon import Schema   @dataclass class Reply:     rand_id: int     content: str      class Meta:         name = 'reply'         order = ('rand_id', 'content')<\/code><\/pre>\n<p>\u0423 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u0430 <code>Optional<\/code> \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>dataclasses.field<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>flag<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0439 \u0431\u0438\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 <code>flag<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c \u0442\u043e\u0433\u043e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d \u0438\u043b\u0438 \u043d\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442.<\/p>\n<pre><code class=\"python\">from dataclasses import dataclass, field  @dataclass class AuthorizedUser:     id: int     username: str     password: str     avatar_url: Optional[str] = field(metadata={'flag': 0})      class Meta:         name = 'authorizedUser'         order = ('id', 'username', 'password', 'avatar_url')<\/code><\/pre>\n<p>\u0410\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a. \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0438\u043f <code>typing.List<\/code> \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430<\/p>\n<pre><code class=\"python\">from typing import List from dataclasses import dataclass  from .task import Task   @dataclass class TaskList:     tasks: List[Task]     class Meta:        name = 'task_list'        order = ('tasks',)<\/code><\/pre>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0438\u043f\u044b \u044f\u0437\u044b\u043a\u0430 <code>Union<\/code> \u0438 <code>Annotated<\/code>:<\/p>\n<pre><code class=\"python\">@dataclass class BoolTrue:    class Meta:        name = 'boolTrue'   @dataclass class BoolFalse:    class Meta:        name = 'boolFalse'   Bool = Annotated[    Union[BoolTrue, BoolFalse],    'Bool' ]    @dataclass class AnonymousUser:    class Meta:        name = 'anonymous_user'   @dataclass class RegisteredUser:    id: int    nickname: str     class Meta:        name = 'registered_user'         order = ('id', 'nickname')   User = Annotated[    Union[        AnonymousUser,        RegisteredUser    ],    'User' ]<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\/\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u044b\u043b \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d.\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 32-\u0431\u0438\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c <strong>crc32<\/strong>.<\/p>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 &#8212; \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code>constructor_name attr_1:AttrType attr_2:AttrType2 \u2026 attr_name_n=AttrTypeN = ResType<\/code><\/pre>\n<p>\u0417\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c\/\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.\u00a0<\/p>\n<p>\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 <code>RegisteredUser<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0442\u0438\u043f\u0443 <code>User<\/code>,\u00a0 \u0431\u0443\u0434\u0435\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430:<\/p>\n<pre><code>registered_user id:int nickname:string = User<\/code><\/pre>\n<p>\u0410 \u0447\u0438\u0441\u043b\u043e \u0431\u0443\u0434\u0435\u0442 <code>-366049798<\/code><\/p>\n<h3>\u0424\u0443\u043d\u043a\u0446\u0438\u0438<\/h3>\n<p>\u0412\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0431\u0443\u0434\u0443\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438. \u041f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f request &#8212; \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 <code>aiohttp.web.Request<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043e\u0431\u0449\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0431\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0435, \u043b\u0438\u0431\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b. \u0412\u0441\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438.\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0442\u0438\u043f.\u00a0<\/p>\n<pre><code class=\"python\">from aiohttp.web import Request from mtpylon.crypto import AuthKey from mtpylon.exceptions import RpcCallError from mtpylon.contextvars import auth_key_var  from users.utils import login_user, remember_user from ..constructors import User, RegisteredUser   async def login(request: Request, nickname: str, password: str) -> User:    try:        user = await login_user(nickname, password)    except ValueError as e:        raise RpcCallError(error_code=401, error_message=str(e))     auth_key: AuthKey = auth_key_var.get()    await remember_user(user, auth_key)     return RegisteredUser(id=user.id, nickname=nickname)<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u043e\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 crc32 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"python\">function_name arg_1:ArgType arg_2:ArgType2 \u2026 arg_name_n=ArgTypeN = ResType<\/code><\/pre>\n<h4>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/h4>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e WebSocket \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<h3>\u0421\u0445\u0435\u043c\u0430<\/h3>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0431\u044d\u043a\u0435\u043d\u0434\u0430, \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u0441\u0445\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <code>mtpylon.Schema<\/code><\/p>\n<pre><code class=\"python\">from mtpylon import Schema   from .constructors import (    Bool,    User,    TodoList,    TodoListsResult,    Task,    TaskList ) from .functions import (    register,    login,    get_me,    create_todo_list,    get_todo_lists,    get_single_todo_list,    remove_todo_list,    create_task,    get_task_list,    edit_task_title,    set_as_completed,    set_as_uncompleted,    remove_task, )  mtpylon_schema = Schema(    constructors=[        Bool,        User,        TodoList,        TodoListsResult,        Task,        TaskList    ],    functions=[        register,        login,        get_me,        create_todo_list,        get_todo_lists,        get_single_todo_list,        remove_todo_list,        create_task,        get_task_list,        edit_task_title,        set_as_completed,        set_as_uncompleted,        remove_task,    ]<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432 \u0441\u0445\u0435\u043c\u0443, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0435\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u043e \u0432 TL-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043b\u0438\u0431\u043e \u0432 JSON, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>mtpylon.serializers.to_tl_program()<\/code> \u0438\u043b\u0438 <code>mtpylon.serializers.to_json()<\/code>. \u0417\u043d\u0430\u044f \u043a\u0430\u043a \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c.<\/p>\n<h2>\u041a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0430\u044f(\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f) \u0447\u0430\u0441\u0442\u044c.<\/h2>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 <a href=\"https:\/\/core.telegram.org\/mtproto\" rel=\"noopener noreferrer nofollow\"><u>\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0430<\/u><\/a>.\u00a0<\/p>\n<p>\u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439: \u043d\u0435\u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.     \u041d\u0435\u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0414\u0435\u0444\u0444\u0438-\u0425\u0435\u043b\u044c\u043c\u0430\u043d\u0430.<\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/core.telegram.org\/mtproto\/auth_key\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c <\/u><\/a>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043d\u0435\u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f: <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:<\/p>\n<ol>\n<li>\n<p>C\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439\/\u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 RSA-\u043a\u043b\u044e\u0447.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447(2048 bit). \u0423 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f 64\u0445 \u0431\u0438\u0442\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440(<code>auth_id<\/code>), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c key-value \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0441\u0432\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u0445\u0440\u0430\u043d\u044e \u0438\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043b\u0430\u0441\u0441 \u00a0<code>mtproto.crypto.auth_key_manager.AuthKeyManager<\/code>, \u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>mtproto.crypto.auth_key_manager.AuthKeyManagerProtocol<\/code>,\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043b\u044e\u0431\u043e\u0439 \u0431\u0434. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b postgresql, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u043b id \u043a\u0430\u043a BigInteger, \u0430 \u0441\u0430\u043c \u043a\u043b\u044e\u0447 \u043a\u0430\u043a BLOB.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043a\u043b\u044e\u0447 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438,\u00a0 \u043a\u043b\u0438\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0435 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0441\u0445\u0435\u043c\u044b, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u0435\u0441\u0441\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0441\u043e\u043b\u044c.<\/p>\n<h4>\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u0435\u0441\u0441\u0438\u0438 session_id <\/h4>\n<p>\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u0435\u0441\u0441\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0430\u0440\u0430 <code>auth_key_id<\/code> \u0438 <code>session_id<\/code> \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a <code>session_id<\/code> \u0443 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f.\u00a0<\/p>\n<p><code>session_id<\/code> &#8212; 64 \u0431\u0438\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c. <code>mtproto.sessions.sessions_storage_protocol.SessionS\u0441torageProtocol<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0431\u0434, \u0438\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>mtproto.sessions.in_memory_session_storage.InMemorySessionStorage<\/code> \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u0435\u0441\u0441\u0438\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u043b\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0441\u0435\u0441\u0441\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d observer.<\/p>\n<h4>\u0421\u043e\u043b\u044c(salt).<\/h4>\n<p><a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%BE%D0%BB%D1%8C_(%D0%BA%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D1%8F)\" rel=\"noopener noreferrer nofollow\"><u>\u0421\u043e\u043b\u044c<\/u><\/a> &#8212; 64 \u0431\u0438\u0442\u043d\u043e\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0435\u0441\u044f \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0430\u0442\u0430\u043a \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u0421\u0435\u0440\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-393702","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/393702","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=393702"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/393702\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=393702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=393702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=393702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}