mirror of
				https://github.com/LonamiWebs/Telethon.git
				synced 2025-10-31 07:57:38 +03:00 
			
		
		
		
	Update documentation index to reflect __call__ and enhance search
This commit is contained in:
		
							parent
							
								
									0119a00658
								
							
						
					
					
						commit
						5061e22c66
					
				|  | @ -14,6 +14,7 @@ | ||||||
| </head> | </head> | ||||||
| <body> | <body> | ||||||
| <div id="main_div"> | <div id="main_div"> | ||||||
|  |     <!-- You can append '?q=query' to the URL to default to a search --> | ||||||
|     <input id="searchBox" type="text" onkeyup="updateSearch()" |     <input id="searchBox" type="text" onkeyup="updateSearch()" | ||||||
|            placeholder="Search for requests and types…" /> |            placeholder="Search for requests and types…" /> | ||||||
| 
 | 
 | ||||||
|  | @ -146,7 +147,6 @@ | ||||||
|     <pre><span class="sh3">#!/usr/bin/python3</span> |     <pre><span class="sh3">#!/usr/bin/python3</span> | ||||||
| <span class="sh4">from</span> telethon <span class="sh4">import</span> TelegramClient | <span class="sh4">from</span> telethon <span class="sh4">import</span> TelegramClient | ||||||
| <span class="sh4">from</span> telethon.tl.functions.messages <span class="sh4">import</span> GetHistoryRequest | <span class="sh4">from</span> telethon.tl.functions.messages <span class="sh4">import</span> GetHistoryRequest | ||||||
| <span class="sh4">from</span> telethon.utils <span class="sh4">import</span> get_input_peer |  | ||||||
| 
 | 
 | ||||||
| <span class="sh3"># <b>(1)</b> Use your own values here</span> | <span class="sh3"># <b>(1)</b> Use your own values here</span> | ||||||
| api_id   = <span class="sh1">12345</span> | api_id   = <span class="sh1">12345</span> | ||||||
|  | @ -167,25 +167,28 @@ dialogs, entities = client.get_dialogs(<span class="sh1">10</span>) | ||||||
| entity = entities[<span class="sh1">0</span>] | entity = entities[<span class="sh1">0</span>] | ||||||
| 
 | 
 | ||||||
| <span class="sh3"># <b>(4)</b> !! Invoking a request manually !!</span> | <span class="sh3"># <b>(4)</b> !! Invoking a request manually !!</span> | ||||||
| result = <b>client.invoke</b>( | result = <b>client</b>(GetHistoryRequest( | ||||||
|     GetHistoryRequest( |     entity, | ||||||
|         get_input_peer(entity), |  | ||||||
|     limit=<span class="sh1">20</span>, |     limit=<span class="sh1">20</span>, | ||||||
|     offset_date=<span class="sh1">None</span>, |     offset_date=<span class="sh1">None</span>, | ||||||
|     offset_id=<span class="sh1">0</span>, |     offset_id=<span class="sh1">0</span>, | ||||||
|     max_id=<span class="sh1">0</span>, |     max_id=<span class="sh1">0</span>, | ||||||
|     min_id=<span class="sh1">0</span>, |     min_id=<span class="sh1">0</span>, | ||||||
|         add_offset=<span class="sh1">0</span>)) |     add_offset=<span class="sh1">0</span> | ||||||
|  | )) | ||||||
| 
 | 
 | ||||||
| <span class="sh3"># Now you have access to the first 20 messages</span> | <span class="sh3"># Now you have access to the first 20 messages</span> | ||||||
| messages = result.messages</pre> | messages = result.messages</pre> | ||||||
| 
 | 
 | ||||||
|     <p>As it can be seen, manually invoking requests with |     <p>As it can be seen, manually calling requests with | ||||||
|     <code>client.invoke()</code> is way more verbose than using the built-in |     <code>client(request)</code> (or using the old way, by calling | ||||||
|     methods (such as <code>client.get_dialogs()</code>. However, and given |     <code>client.invoke(request)</code>) is way more verbose than using the | ||||||
|     that there are so many methods available, it's impossible to provide a nice |     built-in methods (such as <code>client.get_dialogs()</code>).</p> | ||||||
|     interface to things that may change over time. To get full access, however, | 
 | ||||||
|     you're still able to invoke these methods manually.</p> |     <p>However, and | ||||||
|  |     given that there are so many methods available, it's impossible to provide | ||||||
|  |     a nice interface to things that may change over time. To get full access, | ||||||
|  |     however, you're still able to invoke these methods manually.</p> | ||||||
| </div> | </div> | ||||||
| 
 | 
 | ||||||
| </div> | </div> | ||||||
|  | @ -195,11 +198,18 @@ searchDiv = document.getElementById("searchDiv"); | ||||||
| searchBox = document.getElementById("searchBox"); | searchBox = document.getElementById("searchBox"); | ||||||
| searchTable = document.getElementById("searchTable"); | searchTable = document.getElementById("searchTable"); | ||||||
| 
 | 
 | ||||||
|  | try { | ||||||
|     requests = [{request_names}]; |     requests = [{request_names}]; | ||||||
|     types = [{type_names}]; |     types = [{type_names}]; | ||||||
| 
 | 
 | ||||||
|     requestsu = [{request_urls}]; |     requestsu = [{request_urls}]; | ||||||
|     typesu = [{type_urls}]; |     typesu = [{type_urls}]; | ||||||
|  | } catch (e) { | ||||||
|  |     requests = []; | ||||||
|  |     types = []; | ||||||
|  |     requetsu = []; | ||||||
|  |     typesu = []; | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| function updateSearch() { | function updateSearch() { | ||||||
|     if (searchBox.value) { |     if (searchBox.value) { | ||||||
|  | @ -253,6 +263,21 @@ function updateSearch() { | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | function getQuery(name) { | ||||||
|  |     var query = window.location.search.substring(1); | ||||||
|  |     var vars = query.split("&"); | ||||||
|  |     for (var i = 0; i != vars.length; ++i) { | ||||||
|  |         var pair = vars[i].split("="); | ||||||
|  |         if (pair[0] == name) | ||||||
|  |             return pair[1]; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | var query = getQuery('q'); | ||||||
|  | if (query) { | ||||||
|  |     searchBox.value = query; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| updateSearch(); | updateSearch(); | ||||||
| </script> | </script> | ||||||
| </body> | </body> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user