core.html 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>GramJS API</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <link id="style" href="css/docs.dark.css" rel="stylesheet" />
  8. <script>
  9. (function() {
  10. var style = document.getElementById('style');
  11. // setTheme(<link />, 'light' / 'dark')
  12. function setTheme(theme) {
  13. localStorage.setItem('theme', theme);
  14. return (style.href = 'css/docs.' + theme + '.css');
  15. }
  16. // setThemeOnClick(<link />, 'light' / 'dark', <a />)
  17. function setThemeOnClick(theme, button) {
  18. return button.addEventListener('click', function(e) {
  19. setTheme(theme);
  20. e.preventDefault();
  21. return false;
  22. });
  23. }
  24. setTheme(localStorage.getItem('theme') || 'light');
  25. document.addEventListener('DOMContentLoaded', function() {
  26. setThemeOnClick(
  27. 'light',
  28. document.getElementById('themeLight')
  29. );
  30. setThemeOnClick(
  31. 'dark',
  32. document.getElementById('themeDark')
  33. );
  34. });
  35. })();
  36. </script>
  37. <link
  38. href="https://fonts.googleapis.com/css?family=Nunito|Source+Code+Pro"
  39. rel="stylesheet"
  40. />
  41. </head>
  42. <body>
  43. <div id="main_div">
  44. <noscript
  45. >Please enable JavaScript if you would like to use
  46. search.</noscript
  47. >
  48. <h1>GramJS API</h1>
  49. <p>
  50. This documentation was generated straight from the
  51. <code>scheme.tl</code> provided by Telegram. However, there is
  52. no official documentation per se on what the methods,
  53. constructors and types mean. Nevertheless, this page aims to
  54. provide easy access to all the available methods, their
  55. definition and parameters.
  56. </p>
  57. <p id="themeSelect">
  58. <a href="#" id="themeLight">light</a> /
  59. <a href="#" id="themeDark">dark</a> theme.
  60. </p>
  61. <p>Please note that when you see this:</p>
  62. <pre>
  63. ---functions---
  64. users.getUsers#0d91a548 id:Vector&lt;InputUser&gt; = Vector&lt;User&gt;</pre
  65. >
  66. <p>
  67. This is <b>not</b> Python code. It's the "TL definition". It's
  68. an easy-to-read line that gives a quick overview on the
  69. parameters and its result. You don't need to worry about this.
  70. See
  71. <a
  72. href="https://docs.telethon.dev/en/latest/developing/understanding-the-type-language.html"
  73. >Understanding the Type Language</a
  74. >
  75. for more details on it.
  76. </p>
  77. <h3>Index</h3>
  78. <ul>
  79. <li>
  80. <a href="#methods">Methods</a>
  81. (<a href="methods/index.html">full list</a>)
  82. </li>
  83. <li>
  84. <a href="#types">Types</a>
  85. (<a href="types/index.html">full list</a>)
  86. </li>
  87. <li>
  88. <a href="#constructors">Constructors</a>
  89. (<a href="constructors/index.html">full list</a>)
  90. </li>
  91. <li><a href="#core">Core types</a></li>
  92. <li><a href="#example">Full example</a></li>
  93. </ul>
  94. <h3 id="methods">Methods</h3>
  95. <p>
  96. Currently there are <b>{methodCount} methods</b> available for
  97. the layer {layer}.
  98. <a href="methods/index.html">See the complete method list</a>.
  99. <br /><br />
  100. Methods, also known as <i>requests</i>, are used to interact
  101. with the Telegram API itself and are invoked through
  102. <code>client(Request(...))</code>. <b>Only these</b> can be used
  103. like that! You cannot invoke types or constructors, only
  104. requests. After this, Telegram will return a
  105. <code>result</code>, which may be, for instance, a bunch of
  106. messages, some dialogs, users, etc.
  107. </p>
  108. <h3 id="types">Types</h3>
  109. <p>
  110. Currently there are <b>{typeCount} types</b>.
  111. <a href="types/index.html">See the complete list of types</a>.
  112. </p>
  113. <p>
  114. The Telegram types are the <i>abstract</i> results that you
  115. receive after invoking a request. They are "abstract" because
  116. they can have multiple constructors. For instance, the abstract
  117. type <code>User</code> can be either <code>UserEmpty</code> or
  118. <code>User</code>. You should, most of the time, make sure you
  119. received the desired type by using the
  120. <code>isinstance(result, Constructor)</code> Python function.
  121. When a request needs a Telegram type as argument, you should
  122. create an instance of it by using one of its, possibly multiple,
  123. constructors.
  124. </p>
  125. <h3 id="constructors">Constructors</h3>
  126. <p>
  127. Currently there are <b>{constructorCount} constructors</b>.
  128. <a href="constructors/index.html"
  129. >See the list of all constructors</a
  130. >.
  131. </p>
  132. <p>
  133. Constructors are the way you can create instances of the
  134. abstract types described above, and also the instances which are
  135. actually returned from the functions although they all share a
  136. common abstract type.
  137. </p>
  138. <h3 id="core">Core types</h3>
  139. <p>
  140. Core types are types from which the rest of Telegram types build
  141. upon:
  142. </p>
  143. <ul>
  144. <li id="int">
  145. <b>int</b>: The value should be an integer type, like
  146. <span class="sh1">42</span>. It should have 32 bits or less.
  147. You can check the bit length by calling
  148. <code>a.bit_length()</code>, where <code>a</code> is an
  149. integer variable.
  150. </li>
  151. <li id="long">
  152. <b>long</b>: Different name for an integer type. The numbers
  153. given should have 64 bits or less.
  154. </li>
  155. <li id="int128">
  156. <b>int128</b>: Another integer type, should have 128 bits or
  157. less.
  158. </li>
  159. <li id="int256">
  160. <b>int256</b>: The largest integer type, allowing 256 bits
  161. or less.
  162. </li>
  163. <li id="double">
  164. <b>double</b>: The value should be a floating point value,
  165. such as <span class="sh1">123.456</span>.
  166. </li>
  167. <li id="vector">
  168. <b>Vector&lt;T&gt;</b>: If a type <code>T</code> is wrapped
  169. around <code>Vector&lt;T&gt;</code>, then it means that the
  170. argument should be a <i>list</i> of it. For instance, a
  171. valid value for <code>Vector&lt;int&gt;</code> would be
  172. <code>[1, 2, 3]</code>.
  173. </li>
  174. <li id="string">
  175. <b>string</b>: A valid UTF-8 string should be supplied. This
  176. is right how Python strings work, no further encoding is
  177. required.
  178. </li>
  179. <li id="bool">
  180. <b>Bool</b>: Either <code>True</code> or <code>False</code>.
  181. </li>
  182. <li id="true">
  183. <b>flag</b>: These arguments aren't actually sent but rather
  184. encoded as flags. Any truthy value (<code>True</code>,
  185. <code>7</code>) will enable this flag, although it's
  186. recommended to use <code>True</code> or <code>None</code> to
  187. symbolize that it's not present.
  188. </li>
  189. <li id="bytes">
  190. <b>bytes</b>: A sequence of bytes, like
  191. <code>b'hello'</code>, should be supplied.
  192. </li>
  193. <li id="date">
  194. <b>date</b>: Although this type is internally used as an
  195. <code>int</code>, you can pass a <code>datetime</code> or
  196. <code>date</code> object instead to work with date
  197. parameters.<br />
  198. Note that the library uses the date in <b>UTC+0</b>, since
  199. timezone conversion is not responsibility of the library.
  200. Furthermore, this eases converting into any other timezone
  201. without the need for a middle step.
  202. </li>
  203. </ul>
  204. <h3 id="example">Full example</h3>
  205. <p>
  206. All methods shown here have dummy examples on how to write them,
  207. so you don't get confused with their TL definition. However,
  208. this may not always run. They are just there to show the right
  209. syntax.
  210. </p>
  211. <p>
  212. You should check out
  213. <a
  214. href="https://docs.telethon.dev/en/latest/concepts/full-api.html"
  215. >how to access the full API</a
  216. >
  217. in ReadTheDocs.
  218. </p>
  219. </div>
  220. <script src="js/search.js"></script>
  221. </body>
  222. </html>