From ad74926e33f6b17118c562cd6fe5b4befd1a582a Mon Sep 17 00:00:00 2001 From: JosXa Date: Tue, 20 Feb 2018 14:53:15 +0100 Subject: [PATCH] Changes to documentation and "Number of retries reached 0." --- readthedocs/extra/basic/entities.rst | 29 +++++++++++++++------------- telethon/telegram_bare_client.py | 4 +++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/readthedocs/extra/basic/entities.rst b/readthedocs/extra/basic/entities.rst index 472942a7..d541366b 100644 --- a/readthedocs/extra/basic/entities.rst +++ b/readthedocs/extra/basic/entities.rst @@ -43,14 +43,15 @@ you're able to just do this: my_channel = client.get_entity(PeerChannel(some_id)) -All methods in the :ref:`telegram-client` call ``.get_input_entity()`` to -further save you from the hassle of doing so manually, so doing things like -``client.send_message('lonami', 'hi!')`` is possible. +All methods in the :ref:`telegram-client` call ``.get_input_entity()`` prior +to sending the requst to save you from the hassle of doing so manually. +That way, convenience calls such as ``client.send_message('lonami', 'hi!')`` +become possible. -Every entity the library "sees" (in any response to any call) will by -default be cached in the ``.session`` file, to avoid performing -unnecessary API calls. If the entity cannot be found, some calls -like ``ResolveUsernameRequest`` or ``GetContactsRequest`` may be +Every entity the library encounters (in any response to any call) will by +default be cached in the ``.session`` file (an SQLite database), to avoid +performing unnecessary API calls. If the entity cannot be found, additonal +calls like ``ResolveUsernameRequest`` or ``GetContactsRequest`` may be made to obtain the required information. @@ -61,16 +62,18 @@ Entities vs. Input Entities Don't worry if you don't understand this section, just remember some of the details listed here are important. When you're calling a method, - don't call ``.get_entity()`` before, just use the username or phone, + don't call ``.get_entity()`` beforehand, just use the username or phone, or the entity retrieved by other means like ``.get_dialogs()``. -To save bandwidth, the API also makes use of their "input" versions. +On top of the normal types, the API also make use of what they call their +``Input*`` versions of objects. The input version of an entity (e.g. ``InputPeerUser``, ``InputChat``, -etc.) only contains the minimum required information that's required -for Telegram to be able to identify who you're referring to: their ID -and hash. This ID/hash pair is unique per user, so if you use the pair -given by another user **or bot** it will **not** work. +etc.) only contains the minimum information that's required from Telegram +to be able to identify who you're referring to: +a Peer's **ID** and **hash**. +This ID/hash pair is unique per user, so if you use the pair given by another +user **or bot** it will **not** work. To save *even more* bandwidth, the API also makes use of the ``Peer`` versions, which just have an ID. This serves to identify them, but diff --git a/telethon/telegram_bare_client.py b/telethon/telegram_bare_client.py index 23fd4ee4..39f0c057 100644 --- a/telethon/telegram_bare_client.py +++ b/telethon/telegram_bare_client.py @@ -455,7 +455,9 @@ class TelegramBareClient: with self._reconnect_lock: self._reconnect() - raise RuntimeError('Number of retries reached 0.') + raise RuntimeError('Giving up on {} after {} failed attemps.'.format( + [type(x).__name__ for x in requests], retries + )) # Let people use client.invoke(SomeRequest()) instead client(...) invoke = __call__