From 387bbbf090b53995aaededa1970ca06880562540 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 1 Apr 2018 17:38:22 +0200 Subject: [PATCH] Add new force_sms parameter to force Telegram sending the code via SMS --- pyrogram/client/client.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index ef3e0f26..07869a62 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -136,6 +136,7 @@ class Client: phone_number: str = None, phone_code: str or callable = None, password: str = None, + force_sms: bool = False, first_name: str = None, last_name: str = None, workers: int = 4): @@ -149,6 +150,7 @@ class Client: self.phone_code = phone_code self.first_name = first_name self.last_name = last_name + self.force_sms = force_sms self.workers = workers @@ -346,6 +348,14 @@ class Client: phone_registered = r.phone_registered 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: self.phone_code = ( input("Enter phone code: ") if self.phone_code is None