mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-04 14:24:51 +00:00
Add extra checks in case sign-in or sign-up fails
This commit is contained in:
parent
1bd41d0138
commit
c9bcf93cf7
1 changed files with 25 additions and 15 deletions
|
|
@ -45,7 +45,7 @@ from pyrogram.api.errors import (
|
||||||
PhoneNumberUnoccupied, PhoneCodeInvalid, PhoneCodeHashEmpty,
|
PhoneNumberUnoccupied, PhoneCodeInvalid, PhoneCodeHashEmpty,
|
||||||
PhoneCodeExpired, PhoneCodeEmpty, SessionPasswordNeeded,
|
PhoneCodeExpired, PhoneCodeEmpty, SessionPasswordNeeded,
|
||||||
PasswordHashInvalid, FloodWait, PeerIdInvalid, FirstnameInvalid, PhoneNumberBanned,
|
PasswordHashInvalid, FloodWait, PeerIdInvalid, FirstnameInvalid, PhoneNumberBanned,
|
||||||
VolumeLocNotFound, UserMigrate, FileIdInvalid, ChannelPrivate)
|
VolumeLocNotFound, UserMigrate, FileIdInvalid, ChannelPrivate, PhoneNumberOccupied)
|
||||||
from pyrogram.client.handlers import DisconnectHandler
|
from pyrogram.client.handlers import DisconnectHandler
|
||||||
from pyrogram.client.handlers.handler import Handler
|
from pyrogram.client.handlers.handler import Handler
|
||||||
from pyrogram.crypto import AES
|
from pyrogram.crypto import AES
|
||||||
|
|
@ -529,13 +529,18 @@ class Client(Methods, BaseClient):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if phone_registered:
|
if phone_registered:
|
||||||
r = self.send(
|
try:
|
||||||
functions.auth.SignIn(
|
r = self.send(
|
||||||
self.phone_number,
|
functions.auth.SignIn(
|
||||||
phone_code_hash,
|
self.phone_number,
|
||||||
self.phone_code
|
phone_code_hash,
|
||||||
|
self.phone_code
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except PhoneNumberUnoccupied:
|
||||||
|
print("PHONE NON-OCCUPIED")
|
||||||
|
phone_registered = False
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.send(
|
self.send(
|
||||||
|
|
@ -551,15 +556,20 @@ class Client(Methods, BaseClient):
|
||||||
self.first_name = self.first_name if self.first_name is not None else input("First name: ")
|
self.first_name = self.first_name if self.first_name is not None else input("First name: ")
|
||||||
self.last_name = self.last_name if self.last_name is not None else input("Last name: ")
|
self.last_name = self.last_name if self.last_name is not None else input("Last name: ")
|
||||||
|
|
||||||
r = self.send(
|
try:
|
||||||
functions.auth.SignUp(
|
r = self.send(
|
||||||
self.phone_number,
|
functions.auth.SignUp(
|
||||||
phone_code_hash,
|
self.phone_number,
|
||||||
self.phone_code,
|
phone_code_hash,
|
||||||
self.first_name,
|
self.phone_code,
|
||||||
self.last_name
|
self.first_name,
|
||||||
|
self.last_name
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except PhoneNumberOccupied:
|
||||||
|
print("PHONE OCCUPIED")
|
||||||
|
phone_registered = True
|
||||||
|
continue
|
||||||
except (PhoneCodeInvalid, PhoneCodeEmpty, PhoneCodeExpired, PhoneCodeHashEmpty) as e:
|
except (PhoneCodeInvalid, PhoneCodeEmpty, PhoneCodeExpired, PhoneCodeHashEmpty) as e:
|
||||||
if phone_code_invalid_raises:
|
if phone_code_invalid_raises:
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue