mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
parent
ef3ea11e38
commit
77301378f8
|
@ -31,7 +31,6 @@ one is very simple:
|
|||
# Use your own values here
|
||||
api_id = 12345
|
||||
api_hash = '0123456789abcdef0123456789abcdef'
|
||||
phone_number = '+34600000000'
|
||||
|
||||
client = TelegramClient('some_name', api_id, api_hash)
|
||||
|
||||
|
@ -54,6 +53,7 @@ If you're not authorized, you need to ``.sign_in()``:
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
phone_number = '+34600000000'
|
||||
client.send_code_request(phone_number)
|
||||
myself = client.sign_in(phone_number, input('Enter code: '))
|
||||
# If .sign_in raises PhoneNumberUnoccupiedError, use .sign_up instead
|
||||
|
@ -86,7 +86,9 @@ All of this, however, can be done through a call to ``.start()``:
|
|||
|
||||
The code shown is just what ``.start()`` will be doing behind the scenes
|
||||
(with a few extra checks), so that you know how to sign in case you want
|
||||
to avoid using ``input()`` (the default) for whatever reason.
|
||||
to avoid using ``input()`` (the default) for whatever reason. If no phone
|
||||
or bot token is provided, you will be asked one through ``input()``. The
|
||||
method also accepts a ``phone=`` and ``bot_token`` parameters.
|
||||
|
||||
You can use either, as both will work. Determining which
|
||||
is just a matter of taste, and how much control you need.
|
||||
|
|
|
@ -27,7 +27,6 @@ Creating a client
|
|||
# api_hash from https://my.telegram.org, under API Development.
|
||||
api_id = 12345
|
||||
api_hash = '0123456789abcdef0123456789abcdef'
|
||||
phone = '+34600000000'
|
||||
|
||||
client = TelegramClient('session_name', api_id, api_hash)
|
||||
client.start()
|
||||
|
|
|
@ -231,7 +231,15 @@ class TelegramClient(TelegramBareClient):
|
|||
'function that returns the code you received by Telegram.'
|
||||
)
|
||||
|
||||
if (phone and bot_token) or (not phone and not bot_token):
|
||||
if not phone and not bot_token:
|
||||
value = input('Please enter your phone/bot token: ')
|
||||
phone = utils.parse_phone(phone)
|
||||
if not phone:
|
||||
bot_token = value
|
||||
print("Note: input doesn't look like a phone, "
|
||||
"using as bot token")
|
||||
|
||||
if phone and bot_token:
|
||||
raise ValueError(
|
||||
'You must provide either a phone number or a bot token, '
|
||||
'not both (or neither).'
|
||||
|
|
Loading…
Reference in New Issue
Block a user