mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2024-11-28 19:23:11 +01:00
145 lines
8.8 KiB
HTML
145 lines
8.8 KiB
HTML
<!DOCTYPE html>
|
|
<html class="">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Min constructors</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta property="description" content="In some situations user and channel constructors have reduced set of fields present (although id is always there) and min flag set. ">
|
|
<meta property="og:title" content="Min constructors">
|
|
<meta property="og:image" content="8440249ddd84efacd0">
|
|
<meta property="og:description" content="In some situations user and channel constructors have reduced set of fields present (although id is always there) and min flag set. ">
|
|
<link rel="icon" type="image/svg+xml" href="/img/website_icon.svg?4">
|
|
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png">
|
|
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png">
|
|
<link rel="icon" type="image/png" sizes="16x16" href="/img/favicon-16x16.png">
|
|
<link rel="alternate icon" href="/img/favicon.ico" type="image/x-icon" />
|
|
<link href="/css/bootstrap.min.css?3" rel="stylesheet">
|
|
|
|
<link href="/css/telegram.css?240" rel="stylesheet" media="screen">
|
|
<style>
|
|
</style>
|
|
</head>
|
|
<body class="preload">
|
|
<div class="dev_page_wrap">
|
|
<div class="dev_page_head navbar navbar-static-top navbar-tg">
|
|
<div class="navbar-inner">
|
|
<div class="container clearfix">
|
|
<ul class="nav navbar-nav navbar-right hidden-xs"><li class="navbar-twitter"><a href="https://twitter.com/telegram" target="_blank" data-track="Follow/Twitter" onclick="trackDlClick(this, event)"><i class="icon icon-twitter"></i><span> Twitter</span></a></li></ul>
|
|
<ul class="nav navbar-nav">
|
|
<li><a href="//telegram.org/">Home</a></li>
|
|
<li class="hidden-xs"><a href="//telegram.org/faq">FAQ</a></li>
|
|
<li class="hidden-xs"><a href="//telegram.org/apps">Apps</a></li>
|
|
<li class="active"><a href="/api">API</a></li>
|
|
<li class=""><a href="/mtproto">Protocol</a></li>
|
|
<li class=""><a href="/schema">Schema</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="container clearfix">
|
|
<div class="dev_page">
|
|
<div id="dev_page_content_wrap" class=" ">
|
|
<div class="dev_page_bread_crumbs"><ul class="breadcrumb clearfix"><li><a href="/api" >API</a></li><i class="icon icon-breadcrumb-divider"></i><li><a href="/api/min" >Min constructors</a></li></ul></div>
|
|
<h1 id="dev_page_title">Min constructors</h1>
|
|
|
|
<div id="dev_page_content"><p>In some situations <a href="/constructor/user">user</a> and <a href="/constructor/channel">channel</a> constructors have reduced set of fields present (although <code>id</code> is always there) and <code>min</code> flag set. This is done for performance and privacy reasons. </p>
|
|
<p>When receiving said constructors, the client must first check if user or chat object without <code>min</code> flag is already present in local cache. If it is present, then the client should just ignore constructors with <code>min</code> flag and use local one instead.</p>
|
|
<p><strong>The rest of the article assumes the client receives a min-constructor and doesn't have the full object in its local cache.</strong></p>
|
|
<p>The client must store the context (similar to <a href="/api/file_reference">file references</a>) in which the user/channel was seen. Later, when the client needs to pass the user/channel as input argument (e.g. fetch profile, mute, ban etc), the context is used to generate the <code>input*FromMessage</code> constructor, instead of normal <code>inputUser</code>, <code>inputChannel</code> or <code>inputPeer</code>.</p>
|
|
<ul>
|
|
<li><a href="/constructor/inputPeerUserFromMessage">inputPeerUserFromMessage</a></li>
|
|
<li><a href="/constructor/inputPeerChannelFromMessage">inputPeerChannelFromMessage</a></li>
|
|
<li><a href="/constructor/inputUserFromMessage">inputUserFromMessage</a></li>
|
|
<li><a href="/constructor/inputChannelFromMessage">inputChannelFromMessage</a></li>
|
|
</ul>
|
|
<p>The <code>access_hash</code> value, if present, is only suitable to use in <a href="/constructor/inputPeerPhotoFileLocation"><code>inputPeerPhotoFileLocation</code></a>, to directly <a href="/api/files">download the profile pictures</a> of channels and users <strong>without</strong> having to generate an <code>inputPeer*FromMessage</code>, simply using <code>inputPeer*</code> with the specified access hash. </p>
|
|
<p>Usually <code>min</code> constructors are encountered in messages inside of groups or channels.
|
|
When a message mentioning (sender, forwarder or forwardee, et cetera) such a user or channel is found, the constuctor must be associated with the message ID of the message and with the chat where the message was seen.</p>
|
|
<h4><a class="anchor" href="#example" id="example" name="example"><i class="anchor-icon"></i></a>Example</h4>
|
|
<p>Assume a <a href="/constructor/message">message</a> with id <code>34</code> is received from supergroup (<a href="/api/channel">actually channel</a>) <code>123456789</code>.
|
|
Said message was sent by <code>from_id</code> <code>102424212</code>.
|
|
The <a href="/api/updates">updates</a> container that contained the message has a user with ID <code>102424212</code> in the <code>users</code> field, but it has the <code>min</code> flag set, and the provided <code>access_hash</code> may be absent, or otherwise can't be used to generate a typical <a href="/constructor/inputPeerUser">inputPeerUser</a> constructor to send messages or do other actions.</p>
|
|
<p>What the client does is associate <code>102424212</code> with the channel <code>123456789</code> and message ID <code>34</code>.
|
|
When and if the client will need to interact with user <code>102424212</code>, it will generate one of the <code>*FromMessage</code> constructors mentioned above, setting:</p>
|
|
<ul>
|
|
<li><code>msg_id</code> to <code>34</code></li>
|
|
<li><code>peer</code> to the <a href="/type/InputPeer">InputPeer</a> associated with channel <code>123456789</code></li>
|
|
<li><code>user_id</code> to <code>102424212</code></li>
|
|
</ul>
|
|
<p><code>user_id</code> can also be set to the IDs of users met in the <code>fwd_header</code> (messages forwarded from a user can be used to interact with the original sender, if they don't have privacy settings for forwards enabled).
|
|
Users mentioned via <a href="/constructor/messageEntityMentionName">messageEntityMentionName</a> in a message can also be used.</p>
|
|
<p>The same can be done with <code>min</code> <a href="/api/channel">channels</a>.</p>
|
|
<p>Example implementations: <a href="https://github.com/peter-iakovlev/Telegram-iOS">Telegram for iOS</a>, <a href="https://github.com/tdlib/td">tdlib</a>.</p></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="footer_wrap">
|
|
<div class="footer_columns_wrap footer_desktop">
|
|
<div class="footer_column footer_column_telegram">
|
|
<h5>Telegram</h5>
|
|
<div class="footer_telegram_description"></div>
|
|
Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.
|
|
</div>
|
|
|
|
<div class="footer_column">
|
|
<h5><a href="//telegram.org/faq">About</a></h5>
|
|
<ul>
|
|
<li><a href="//telegram.org/faq">FAQ</a></li>
|
|
<li><a href="//telegram.org/privacy">Privacy</a></li>
|
|
<li><a href="//telegram.org/press">Press</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer_column">
|
|
<h5><a href="//telegram.org/apps#mobile-apps">Mobile Apps</a></h5>
|
|
<ul>
|
|
<li><a href="//telegram.org/dl/ios">iPhone/iPad</a></li>
|
|
<li><a href="//telegram.org/android">Android</a></li>
|
|
<li><a href="//telegram.org/dl/web">Mobile Web</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer_column">
|
|
<h5><a href="//telegram.org/apps#desktop-apps">Desktop Apps</a></h5>
|
|
<ul>
|
|
<li><a href="//desktop.telegram.org/">PC/Mac/Linux</a></li>
|
|
<li><a href="//macos.telegram.org/">macOS</a></li>
|
|
<li><a href="//telegram.org/dl/web">Web-browser</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer_column footer_column_platform">
|
|
<h5><a href="/">Platform</a></h5>
|
|
<ul>
|
|
<li><a href="/api">API</a></li>
|
|
<li><a href="//translations.telegram.org/">Translations</a></li>
|
|
<li><a href="//instantview.telegram.org/">Instant View</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="footer_columns_wrap footer_mobile">
|
|
<div class="footer_column">
|
|
<h5><a href="//telegram.org/faq">About</a></h5>
|
|
</div>
|
|
<div class="footer_column">
|
|
<h5><a href="//telegram.org/blog">Blog</a></h5>
|
|
</div>
|
|
<div class="footer_column">
|
|
<h5><a href="//telegram.org/apps">Apps</a></h5>
|
|
</div>
|
|
<div class="footer_column">
|
|
<h5><a href="/">Platform</a></h5>
|
|
</div>
|
|
<div class="footer_column">
|
|
<h5><a href="//telegram.org/press">Press</a></h5>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script src="/js/main.js?47"></script>
|
|
|
|
<script>backToTopInit("Go up");
|
|
removePreloadInit();
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|