From 5061e22c66d9fd2cc17837002929f947a33a833a Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 7 Jul 2017 11:33:24 +0200 Subject: [PATCH] Update documentation index to reflect __call__ and enhance search --- docs/res/core.html | 65 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/docs/res/core.html b/docs/res/core.html index 713c16bf..b7875a82 100644 --- a/docs/res/core.html +++ b/docs/res/core.html @@ -14,6 +14,7 @@
+ @@ -146,7 +147,6 @@
#!/usr/bin/python3
 from telethon import TelegramClient
 from telethon.tl.functions.messages import GetHistoryRequest
-from telethon.utils import get_input_peer
 
 # (1) Use your own values here
 api_id   = 12345
@@ -167,25 +167,28 @@ dialogs, entities = client.get_dialogs(10)
 entity = entities[0]
 
 # (4) !! Invoking a request manually !!
-result = client.invoke(
-    GetHistoryRequest(
-        get_input_peer(entity),
-        limit=20,
-        offset_date=None,
-        offset_id=0,
-        max_id=0,
-        min_id=0,
-        add_offset=0))
+result = client(GetHistoryRequest(
+    entity,
+    limit=20,
+    offset_date=None,
+    offset_id=0,
+    max_id=0,
+    min_id=0,
+    add_offset=0
+))
 
 # Now you have access to the first 20 messages
 messages = result.messages
-

As it can be seen, manually invoking requests with - client.invoke() is way more verbose than using the built-in - methods (such as client.get_dialogs(). 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.

+

As it can be seen, manually calling requests with + client(request) (or using the old way, by calling + client.invoke(request)) is way more verbose than using the + built-in methods (such as client.get_dialogs()).

+ +

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.

@@ -195,11 +198,18 @@ searchDiv = document.getElementById("searchDiv"); searchBox = document.getElementById("searchBox"); searchTable = document.getElementById("searchTable"); -requests = [{request_names}]; -types = [{type_names}]; +try { + requests = [{request_names}]; + types = [{type_names}]; -requestsu = [{request_urls}]; -typesu = [{type_urls}]; + requestsu = [{request_urls}]; + typesu = [{type_urls}]; +} catch (e) { + requests = []; + types = []; + requetsu = []; + typesu = []; +} function updateSearch() { 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();