From 50ab50eb529c88932aa2e3a1b1c0cfa62f7d65c6 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 24 Jun 2018 17:13:17 +0200 Subject: [PATCH] Update AutoAuthorization page --- docs/source/resources/AutoAuthorization.rst | 24 ++++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/source/resources/AutoAuthorization.rst b/docs/source/resources/AutoAuthorization.rst index 73504f80..d7a099fe 100644 --- a/docs/source/resources/AutoAuthorization.rst +++ b/docs/source/resources/AutoAuthorization.rst @@ -14,27 +14,31 @@ Log In To automate the **Log In** process, pass your ``phone_number`` and ``password`` (if you have one) in the Client parameters. If you want to retrieve the phone code programmatically, pass a callback function in the ``phone_code`` field — this -function must return the correct phone code as string (e.g., "12345") — otherwise, ignore this parameter, Pyrogram will -ask you to input the phone code manually. +function accepts a single positional argument (phone_number) and must return the correct phone code (e.g., "12345") +— otherwise, ignore this parameter, Pyrogram will ask you to input the phone code manually. + +Example: .. code-block:: python from pyrogram import Client - def phone_code_callback(): + def phone_code_callback(phone_number): code = ... # Get your code programmatically - return code # Must be string, e.g., "12345" + return code # e.g., "12345" app = Client( session_name="example", phone_number="39**********", - phone_code=phone_code_callback, + phone_code=phone_code_callback, # Note the missing parentheses password="password" # (if you have one) ) app.start() + print(app.get_me()) + app.stop() Sign Up @@ -44,23 +48,27 @@ To automate the **Sign Up** process (i.e., automatically create a new Telegram a ``first_name`` and ``last_name`` fields alongside the other parameters; they will be used to automatically create a new Telegram account in case the phone number you passed is not registered yet. +Example: + .. code-block:: python from pyrogram import Client - def phone_code_callback(): + def phone_code_callback(phone_number): code = ... # Get your code programmatically - return code # Must be string, e.g., "12345" + return code # e.g., "12345" app = Client( session_name="example", phone_number="39**********", - phone_code=phone_code_callback, + phone_code=phone_code_callback, # Note the missing parentheses first_name="Pyrogram", last_name="" # Can be an empty string ) app.start() + print(app.get_me()) + app.stop() \ No newline at end of file