#!/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.