Update AutoAuthorization page

This commit is contained in:
Dan 2018-06-24 17:13:17 +02:00
parent 44f71f096f
commit 50ab50eb52

View File

@ -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()