{"id":341880,"date":"2022-11-29T03:00:13","date_gmt":"2022-11-29T03:00:13","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=341880"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=341880","title":{"rendered":"<span>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u043a\u0443 Telegram-\u043a\u0430\u043d\u0430\u043b\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 api \u0438 python<\/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 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0433\u0440\u0443\u043f\u043f\u0430\u0445 \u0432 Telegram \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0438 \u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u0430, \u043d\u043e \u0438 \u043d\u0435\u0445\u0438\u0442\u0440\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441 api. \u0410 \u0435\u0441\u043b\u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u043c\u043d\u043e\u0433\u043e, \u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0432\u0435\u0449\u044c.<\/p>\n<h2>\u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f<\/h2>\n<p>\u041f\u0440\u043e\u0439\u0442\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0441 TDLib.<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/core.telegram.org\/api\/obtaining_api_id\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f<\/a> \u043d\u0430 https:\/\/my.telegram.org. \u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 &#171;API development tools&#187; \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0444\u043e\u0440\u043c\u0443 (\u0442\u0440\u0438 \u043f\u043e\u043b\u044f: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <strong>api_id<\/strong> and <strong>api_hash<\/strong>, \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0448\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 api \u0434\u043b\u044f \u0444\u043b\u0443\u0434\u0430 \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u043d\u0430\u043a\u0440\u0443\u0442\u043e\u043a \u0432\u0430\u0448 \u043d\u043e\u043c\u0435\u0440 \u0437\u0430\u0431\u0430\u043d\u044f\u0442 \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, TDLib, \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u0430\u044f, <a href=\"https:\/\/core.telegram.org\/tdlib\/docs\/\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u044f\u0437\u044b\u043a\u0430\u043c\u0438<\/a> (\u043f\u0438\u0442\u043e\u043d \u0442\u043e\u0436\u0435), \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430 \u0421\u0438. \u0421 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043b\u044e\u0431\u0435\u0437\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u0430\u043c \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c <a href=\"https:\/\/tdlib.github.io\/td\/build.html\" rel=\"noopener noreferrer nofollow\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/a>, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u044f\u0437\u044b\u043a, \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0438 \u0432\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u0430\u043c \u043d\u0430\u043f\u0438\u0448\u0443\u0442. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/33e\/c2a\/d6d\/33ec2ad6deeb119b0c3d794f5dd07fbe.png\" width=\"3218\" height=\"2260\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/33e\/c2a\/d6d\/33ec2ad6deeb119b0c3d794f5dd07fbe.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0443\u0442 \u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0442 \u0442\u0440\u0435\u0442\u044c\u0438\u0445 \u043b\u0438\u0446 \u0438 \u0441\u0442\u043e\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e <a href=\"https:\/\/github.com\/alexander-akhmetov\/python-telegram\" rel=\"noopener noreferrer nofollow\">alexander-akhmetov\/python-telegram<\/a>. \u041e\u043d, \u0442\u0430\u043a \u043e\u043d.<\/p>\n<h2>\u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 (\u043d\u0443, \u043f\u043e\u0447\u0442\u0438)<\/h2>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0451 \u043d\u0443\u0436\u043d\u043e\u0435 \u0438 \u043b\u043e\u0433\u0438\u043d\u0435\u043c\u0441\u044f \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/p>\n<pre><code class=\"python\">import json from telegram.client import Telegram import plotly.graph_objects as go  tg = Telegram(     api_id='api_id',     api_hash='api_hash',     phone='+31611111111',  # you can pass 'bot_token' instead     database_encryption_key='changekey123', ) tg.login() # if this is the first run, library needs to preload all chats # otherwise the message will not be sent result = tg.get_chats() result.wait()<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f 11 \u0441\u0442\u0440\u043e\u0447\u043a\u0438, T\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u0451\u0442 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0434\u043e \u0432\u0432\u0435\u0441\u0442\u0438. \u041f\u043e\u0442\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0447\u0430\u0442\u044b (14-15), \u0430 \u0442\u043e \u0447\u0443\u0434\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442. <\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u0451 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 call_method, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0437 TDLib, \u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043c \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0433\u0440\u0443\u043f\u043f\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430.<\/p>\n<pre><code class=\"python\">params = {     'supergroup_id': 12324890 #id \u0433\u0440\u0443\u043f\u043f\u044b (\u0431\u0435\u0437 -100) }  result = tg.call_method('getSupergroupFullInfo', params, block=True) if result.update['can_get_statistics']:     print('\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c') else:     print(\"\u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a\")<\/code><\/pre>\n<p>\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0435\u0441\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0433\u0440\u0443\u043f\u043f\u0435, tg.get_supergroup_full_info(-100231243245), \u043d\u043e \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0438\u0434\u0451\u0442 \u043d\u0435 \u0442\u0430\u043a, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f None \u0438 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0432 \u0447\u0451\u043c \u0434\u0435\u043b\u043e, \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 tg.call_method(&#8216;getSupergroupFullInfo&#8217;, params, block=True), \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c block=True, \u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"python\">params = {     'supergroup_id': -10012324890 }  result = tg.call_method('getSupergroupFullInfo', params, block=True) >>Telegram error: {'@type': 'error', 'code': 400, 'message': 'Supergroup not found', '@extra': {'request_id': 'fd88892cac814b4c834973d80004d09a'}} <\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0438\u0448\u0435\u0442, \u0447\u0442\u043e \u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b.<\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0437\u0430\u0432\u0435\u0442\u043d\u044b\u0439 \u0444\u043b\u0430\u0436\u043e\u043a can_get_statistics==True, \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443, <a href=\"https:\/\/core.telegram.org\/tdlib\/docs\/classtd_1_1td__api_1_1get_chat_statistics.html\" rel=\"noopener noreferrer nofollow\">\u0432\u044b\u0437\u043e\u0432\u0443 \u043c\u0435\u0442\u043e\u0434\u0430 getChatStatistics<\/a>. \u0412\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0430\u0439\u0434\u0438 \u0447\u0430\u0442\u0430, \u0438 \u0442\u0435\u043c\u043d\u0430\u044f \u0438\u043b\u0438 \u0441\u0432\u0435\u0442\u043b\u0430\u044f \u0442\u0435\u043c\u0430.<\/p>\n<pre><code class=\"python\">params = {     'chat_id': -10012324890, #\u0442\u0443\u0442 \u043d\u0430\u0434\u043e -100     'is_dark': True } stat_resp = tg.call_method('getChatStatistics', params, block=True) stat = stat_resp.update<\/code><\/pre>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c json \u0441\u043e \u0432\u0441\u0435\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u043e\u0439 \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c.<\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/h2>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 plotly<\/p>\n<pre><code class=\"python\"># \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0432 json member_count_graph=json.loads(stat['member_count_graph']['json_data'])  # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c unix timestamp \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f data_x = [     datetime.fromtimestamp(x \/ 1000).strftime(\"%m.%d\")     for x in graph[\"columns\"][0][1:] ]  #\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 fig = go.Figure() fig.add_trace(go.Scatter(x=data_x, y=member_count_graph['columns'][1]))  fig.show()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/186\/d69\/4c1\/186d694c14b431774b4658db7b7c9507.png\" width=\"971\" height=\"525\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/186\/d69\/4c1\/186d694c14b431774b4658db7b7c9507.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \u0412 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e\u043a\u0430 \u044d\u0442\u043e \u0432\u0441\u0451 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u043e\u0441\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435 \u043c\u043e\u0433\u0443. <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/core.telegram.org\/tdlib\/docs\/classes.html\" rel=\"noopener noreferrer nofollow\">\u0421\u043f\u0438\u0441\u043e\u043a \u043a\u043b\u0430\u0441\u0441\u043e\u0432 TDLib Class Index<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/core.telegram.org\/tdlib\" rel=\"noopener noreferrer nofollow\">Telegram Database Library<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/tdlib.github.io\/td\/build.html\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 TDLib<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/python-telegram.readthedocs.io\/en\/0.16.0\/index.html\" rel=\"noopener noreferrer nofollow\">python-telegram<\/a><\/p>\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\/post\/702148\/\"> https:\/\/habr.com\/ru\/post\/702148\/<\/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 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0433\u0440\u0443\u043f\u043f\u0430\u0445 \u0432 Telegram \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0438 \u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u0430, \u043d\u043e \u0438 \u043d\u0435\u0445\u0438\u0442\u0440\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441 api. \u0410 \u0435\u0441\u043b\u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u043c\u043d\u043e\u0433\u043e, \u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0432\u0435\u0449\u044c.<\/p>\n<h2>\u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f<\/h2>\n<p>\u041f\u0440\u043e\u0439\u0442\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0441 TDLib.<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/core.telegram.org\/api\/obtaining_api_id\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f<\/a> \u043d\u0430 https:\/\/my.telegram.org. \u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 &#171;API development tools&#187; \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0444\u043e\u0440\u043c\u0443 (\u0442\u0440\u0438 \u043f\u043e\u043b\u044f: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <strong>api_id<\/strong> and <strong>api_hash<\/strong>, \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0448\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 api \u0434\u043b\u044f \u0444\u043b\u0443\u0434\u0430 \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u043d\u0430\u043a\u0440\u0443\u0442\u043e\u043a \u0432\u0430\u0448 \u043d\u043e\u043c\u0435\u0440 \u0437\u0430\u0431\u0430\u043d\u044f\u0442 \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, TDLib, \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u0430\u044f, <a href=\"https:\/\/core.telegram.org\/tdlib\/docs\/\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u044f\u0437\u044b\u043a\u0430\u043c\u0438<\/a> (\u043f\u0438\u0442\u043e\u043d \u0442\u043e\u0436\u0435), \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430 \u0421\u0438. \u0421 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043b\u044e\u0431\u0435\u0437\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u0430\u043c \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c <a href=\"https:\/\/tdlib.github.io\/td\/build.html\" rel=\"noopener noreferrer nofollow\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/a>, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u044f\u0437\u044b\u043a, \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0438 \u0432\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u0430\u043c \u043d\u0430\u043f\u0438\u0448\u0443\u0442. <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0443\u0442 \u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0442 \u0442\u0440\u0435\u0442\u044c\u0438\u0445 \u043b\u0438\u0446 \u0438 \u0441\u0442\u043e\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e <a href=\"https:\/\/github.com\/alexander-akhmetov\/python-telegram\" rel=\"noopener noreferrer nofollow\">alexander-akhmetov\/python-telegram<\/a>. \u041e\u043d, \u0442\u0430\u043a \u043e\u043d.<\/p>\n<h2>\u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 (\u043d\u0443, \u043f\u043e\u0447\u0442\u0438)<\/h2>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0451 \u043d\u0443\u0436\u043d\u043e\u0435 \u0438 \u043b\u043e\u0433\u0438\u043d\u0435\u043c\u0441\u044f \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/p>\n<pre><code class=\"python\">import json from telegram.client import Telegram import plotly.graph_objects as go  tg = Telegram(     api_id='api_id',     api_hash='api_hash',     phone='+31611111111',  # you can pass 'bot_token' instead     database_encryption_key='changekey123', ) tg.login() # if this is the first run, library needs to preload all chats # otherwise the message will not be sent result = tg.get_chats() result.wait()<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f 11 \u0441\u0442\u0440\u043e\u0447\u043a\u0438, T\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u0451\u0442 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0434\u043e \u0432\u0432\u0435\u0441\u0442\u0438. \u041f\u043e\u0442\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0447\u0430\u0442\u044b (14-15), \u0430 \u0442\u043e \u0447\u0443\u0434\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442. <\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u0451 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 call_method, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0437 TDLib, \u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043c \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0433\u0440\u0443\u043f\u043f\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430.<\/p>\n<pre><code class=\"python\">params = {     'supergroup_id': 12324890 #id \u0433\u0440\u0443\u043f\u043f\u044b (\u0431\u0435\u0437 -100) }  result = tg.call_method('getSupergroupFullInfo', params, block=True) if result.update['can_get_statistics']:     print('\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c') else:     print(\"\u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a\")<\/code><\/pre>\n<p>\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0435\u0441\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0433\u0440\u0443\u043f\u043f\u0435, tg.get_supergroup_full_info(-100231243245), \u043d\u043e \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0438\u0434\u0451\u0442 \u043d\u0435 \u0442\u0430\u043a, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f None \u0438 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0432 \u0447\u0451\u043c \u0434\u0435\u043b\u043e, \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 tg.call_method(&#8216;getSupergroupFullInfo&#8217;, params, block=True), \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c block=True, \u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"python\">params = {     'supergroup_id': -10012324890 }  result = tg.call_method('getSupergroupFullInfo', params, block=True) >>Telegram error: {'@type': 'error', 'code': 400, 'message': 'Supergroup not found', '@extra': {'request_id': 'fd88892cac814b4c834973d80004d09a'}} <\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0438\u0448\u0435\u0442, \u0447\u0442\u043e \u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b.<\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0437\u0430\u0432\u0435\u0442\u043d\u044b\u0439 \u0444\u043b\u0430\u0436\u043e\u043a can_get_statistics==True, \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443, <a href=\"https:\/\/core.telegram.org\/tdlib\/docs\/classtd_1_1td__api_1_1get_chat_statistics.html\" rel=\"noopener noreferrer nofollow\">\u0432\u044b\u0437\u043e\u0432\u0443 \u043c\u0435\u0442\u043e\u0434\u0430 getChatStatistics<\/a>. \u0412\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0430\u0439\u0434\u0438 \u0447\u0430\u0442\u0430, \u0438 \u0442\u0435\u043c\u043d\u0430\u044f \u0438\u043b\u0438 \u0441\u0432\u0435\u0442\u043b\u0430\u044f \u0442\u0435\u043c\u0430.<\/p>\n<pre><code class=\"python\">params = {     'chat_id': -10012324890, #\u0442\u0443\u0442 \u043d\u0430\u0434\u043e -100     'is_dark': True } stat_resp = tg.call_method('getChatStatistics', params, block=True) stat = stat_resp.update<\/code><\/pre>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c json \u0441\u043e \u0432\u0441\u0435\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u043e\u0439 \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c.<\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/h2>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 plotly<\/p>\n<pre><code class=\"python\"># \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0432 json member_count_graph=json.loads(stat['member_count_graph']['json_data'])  # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c unix timestamp \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f data_x = [     datetime.fromtimestamp(x \/ 1000).strftime(\"%m.%d\")     for x in graph[\"columns\"][0][1:] ]  #\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 fig = go.Figure() fig.add_trace(go.Scatter(x=data_x, y=member_count_graph['columns'][1]))  fig.show()<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \u0412 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e\u043a\u0430 \u044d\u0442\u043e \u0432\u0441\u0451 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u043e\u0441\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435 \u043c\u043e\u0433\u0443. <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/core.telegram.org\/tdlib\/docs\/classes.html\" rel=\"noopener noreferrer nofollow\">\u0421\u043f\u0438\u0441\u043e\u043a \u043a\u043b\u0430\u0441\u0441\u043e\u0432 TDLib Class Index<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/core.telegram.org\/tdlib\" rel=\"noopener noreferrer nofollow\">Telegram Database Library<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/tdlib.github.io\/td\/build.html\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 TDLib<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/python-telegram.readthedocs.io\/en\/0.16.0\/index.html\" rel=\"noopener noreferrer nofollow\">python-telegram<\/a><\/p>\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\/post\/702148\/\"> https:\/\/habr.com\/ru\/post\/702148\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-341880","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341880","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=341880"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341880\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}