From 423f0f366c955b9e20b8b41dd374986ee4647634 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 15 Mar 2018 09:29:54 +0100 Subject: [PATCH] Update test servers documentation (#700) --- readthedocs/extra/developing/test-servers.rst | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/readthedocs/extra/developing/test-servers.rst b/readthedocs/extra/developing/test-servers.rst index 2ba66897..a3288a25 100644 --- a/readthedocs/extra/developing/test-servers.rst +++ b/readthedocs/extra/developing/test-servers.rst @@ -8,8 +8,7 @@ To run Telethon on a test server, use the following code: .. code-block:: python client = TelegramClient(None, api_id, api_hash) - client.session.server_address = '149.154.167.40' - client.connect() + client.session.set_dc(dc_id, '149.154.167.40', 80) You can check your ``'test ip'`` on https://my.telegram.org. @@ -17,16 +16,20 @@ You should set ``None`` session so to ensure you're generating a new authorization key for it (it would fail if you used a session where you had previously connected to another data center). -Once you're connected, you'll likely need to ``.sign_up()``. Remember -`anyone can access the phone you +Note that port 443 might not work, so you can try with 80 instead. + +Once you're connected, you'll likely be asked to either sign in or sign up. +Remember `anyone can access the phone you choose `__, -so don't store sensitive data here: +so don't store sensitive data here. + +Valid phone numbers are ``99966XYYYY``, where ``X`` is the ``dc_id`` and +``YYYY`` is any number you want, for example, ``1234`` in ``dc_id = 2`` would +be ``9996621234``. The code sent by Telegram will be ``dc_id`` repeated five +times, in this case, ``22222`` so we can hardcode that: .. code-block:: python - from random import randint - - dc_id = '2' # Change this to the DC id of the test server you chose - phone = '99966' + dc_id + str(randint(9999)).zfill(4) - client.send_code_request(phone) - client.sign_up(dc_id * 5, 'Some', 'Name') + client = TelegramClient(None, api_id, api_hash) + client.session.set_dc(2, '149.154.167.40', 80) + client.start(phone='9996621234', code_callback=lambda: '22222')