From d61bb2e87f83b0e8744191307e90e3d1e399bed8 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 15 Jun 2019 21:54:24 +0200 Subject: [PATCH] Document MTProto Proxy usage (#1205) --- readthedocs/basic/signing-in.rst | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/readthedocs/basic/signing-in.rst b/readthedocs/basic/signing-in.rst index 538e124f..9614b623 100644 --- a/readthedocs/basic/signing-in.rst +++ b/readthedocs/basic/signing-in.rst @@ -126,3 +126,54 @@ consisting of parameters described `in PySocks usage`__. .. __: https://github.com/Anorov/PySocks#installation .. __: https://github.com/Anorov/PySocks#usage-1 + + +Using MTProto Proxies +===================== + +MTProto Proxies are Telegram's alternative to normal proxies, +and work a bit differently. The following protocols are available: + +* ``ConnectionTcpMTProxyAbridged`` +* ``ConnectionTcpMTProxyIntermediate`` +* ``ConnectionTcpMTProxyRandomizedIntermediate`` (preferred) + +For now, you need to manually specify these special connection modes +if you want to use a MTProto Proxy. Your code would look like this: + +.. code-block:: python + + from telethon import TelegramClient, connection + # we need to change the connection ^^^^^^^^^^ + + client = TelegramClient( + 'anon', + api_id, + api_hash, + + # Use one of the available connection modes. + # Normally, this one works with most proxies. + connection=connection.ConnectionTcpMTProxyRandomizedIntermediate, + + # Then, pass the proxy details as a tuple: + # (host name, port, proxy secret) + # + # If the proxy has no secret, the secret must be: + # '00000000000000000000000000000000' + proxy=('mtproxy.example.com', 2002, 'secret') + ) + +In future updates, we may make it easier to use MTProto Proxies +(such as avoiding the need to manually pass ``connection=``). + +In short, the same code above but without comments to make it clearer: + +.. code-block:: python + + from telethon import TelegramClient, connection + + client = TelegramClient( + 'anon', api_id, api_hash, + connection=connection.ConnectionTcpMTProxyRandomizedIntermediate, + proxy=('mtproxy.example.com', 2002, 'secret') + )