mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-04 12:10:21 +03:00
Fixes++++ (that's how I commit sorry <3)
This commit is contained in:
parent
9259811d96
commit
aa67364e26
|
@ -125,7 +125,7 @@ class TelegramClient(TelegramBareClient):
|
|||
|
||||
self._updates_thread = None
|
||||
self._phone_code_hash = None
|
||||
self._phone_number = None
|
||||
self._phone = None
|
||||
|
||||
# Uploaded files cache so subsequent calls are instant
|
||||
self._upload_cache = {}
|
||||
|
@ -254,15 +254,15 @@ class TelegramClient(TelegramBareClient):
|
|||
(code request sent and confirmed)?"""
|
||||
return self.session and self.get_me() is not None
|
||||
|
||||
def send_code_request(self, phone_number):
|
||||
def send_code_request(self, phone):
|
||||
"""Sends a code request to the specified phone number"""
|
||||
result = self(
|
||||
SendCodeRequest(phone_number, self.api_id, self.api_hash))
|
||||
self._phone_number = phone_number
|
||||
SendCodeRequest(phone, self.api_id, self.api_hash))
|
||||
self._phone = phone
|
||||
self._phone_code_hash = result.phone_code_hash
|
||||
return result
|
||||
|
||||
def sign_in(self, phone_number=None, code=None,
|
||||
def sign_in(self, phone=None, code=None,
|
||||
password=None, bot_token=None):
|
||||
"""Completes the sign in process with the phone number + code pair.
|
||||
|
||||
|
@ -278,10 +278,10 @@ class TelegramClient(TelegramBareClient):
|
|||
If the login succeeds, the logged in user is returned.
|
||||
"""
|
||||
|
||||
if phone_number:
|
||||
return self.send_code_request(phone_number)
|
||||
if phone:
|
||||
return self.send_code_request(phone)
|
||||
elif code:
|
||||
if self._phone_number == None:
|
||||
if self._phone == None:
|
||||
raise ValueError(
|
||||
'Please make sure to call send_code_request first.')
|
||||
|
||||
|
@ -289,7 +289,7 @@ class TelegramClient(TelegramBareClient):
|
|||
if isinstance(code, int):
|
||||
code = str(code)
|
||||
result = self(SignInRequest(
|
||||
self._phone_number, self._phone_code_hash, code
|
||||
self._phone, self._phone_code_hash, code
|
||||
))
|
||||
|
||||
except (PhoneCodeEmptyError, PhoneCodeExpiredError,
|
||||
|
@ -308,16 +308,16 @@ class TelegramClient(TelegramBareClient):
|
|||
|
||||
else:
|
||||
raise ValueError(
|
||||
'You must provide a phone_number and a code the first time, '
|
||||
'You must provide a phone and a code the first time, '
|
||||
'and a password only if an RPCError was raised before.')
|
||||
|
||||
return result.user
|
||||
|
||||
def sign_up(self, phone_number, code, first_name, last_name=''):
|
||||
def sign_up(self, code, first_name, last_name=''):
|
||||
"""Signs up to Telegram. Make sure you sent a code request first!"""
|
||||
result = self(
|
||||
SignUpRequest(
|
||||
phone_number=self._phone_number,
|
||||
phone=self._phone,
|
||||
phone_code_hash=self._phone_code_hash,
|
||||
phone_code=code,
|
||||
first_name=first_name,
|
||||
|
|
Loading…
Reference in New Issue
Block a user