mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Add new force_sms parameter to force Telegram sending the code via SMS
This commit is contained in:
parent
880eb28e9f
commit
387bbbf090
@ -136,6 +136,7 @@ class Client:
|
|||||||
phone_number: str = None,
|
phone_number: str = None,
|
||||||
phone_code: str or callable = None,
|
phone_code: str or callable = None,
|
||||||
password: str = None,
|
password: str = None,
|
||||||
|
force_sms: bool = False,
|
||||||
first_name: str = None,
|
first_name: str = None,
|
||||||
last_name: str = None,
|
last_name: str = None,
|
||||||
workers: int = 4):
|
workers: int = 4):
|
||||||
@ -149,6 +150,7 @@ class Client:
|
|||||||
self.phone_code = phone_code
|
self.phone_code = phone_code
|
||||||
self.first_name = first_name
|
self.first_name = first_name
|
||||||
self.last_name = last_name
|
self.last_name = last_name
|
||||||
|
self.force_sms = force_sms
|
||||||
|
|
||||||
self.workers = workers
|
self.workers = workers
|
||||||
|
|
||||||
@ -346,6 +348,14 @@ class Client:
|
|||||||
phone_registered = r.phone_registered
|
phone_registered = r.phone_registered
|
||||||
phone_code_hash = r.phone_code_hash
|
phone_code_hash = r.phone_code_hash
|
||||||
|
|
||||||
|
if self.force_sms:
|
||||||
|
self.send(
|
||||||
|
functions.auth.ResendCode(
|
||||||
|
phone_number=self.phone_number,
|
||||||
|
phone_code_hash=phone_code_hash
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
self.phone_code = (
|
self.phone_code = (
|
||||||
input("Enter phone code: ") if self.phone_code is None
|
input("Enter phone code: ") if self.phone_code is None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user