Handle missing login email
This commit is contained in:
@@ -149,8 +149,15 @@ class ClientWrapper:
|
||||
code_type = getattr(sent, "type", None)
|
||||
logger.info("Login code type: %s", type(code_type).__name__ if code_type else "unknown")
|
||||
if isinstance(code_type, types.auth.SentCodeTypeSetUpEmailRequired):
|
||||
logger.warning("Telegram requires login email verification; sending email code")
|
||||
sent = await self.client(functions.auth.ResetLoginEmailRequest(phone, sent.phone_code_hash))
|
||||
logger.warning("Telegram requires login email verification")
|
||||
try:
|
||||
sent = await self.client(functions.auth.ResetLoginEmailRequest(phone, sent.phone_code_hash))
|
||||
except Exception as exc:
|
||||
logger.error("Email reset failed: %s", exc)
|
||||
raise RuntimeError(
|
||||
"Set a recovery email in Telegram (Settings -> Privacy and Security -> Two-Step Verification) "
|
||||
"then retry login."
|
||||
) from exc
|
||||
code_type = getattr(sent, "type", None)
|
||||
logger.info("Login code type: %s", type(code_type).__name__ if code_type else "unknown")
|
||||
if isinstance(code_type, types.auth.SentCodeTypeEmailCode):
|
||||
|
||||
@@ -51,8 +51,15 @@ async def generate(args: argparse.Namespace) -> None:
|
||||
code_type = getattr(sent, "type", None)
|
||||
print(f"Code delivery type: {type(code_type).__name__ if code_type else 'unknown'}")
|
||||
if isinstance(code_type, types.auth.SentCodeTypeSetUpEmailRequired):
|
||||
print("Telegram requires login email verification, sending email code...")
|
||||
sent = await client(functions.auth.ResetLoginEmailRequest(phone, sent.phone_code_hash))
|
||||
print("Telegram requires login email verification.")
|
||||
try:
|
||||
sent = await client(functions.auth.ResetLoginEmailRequest(phone, sent.phone_code_hash))
|
||||
except Exception as exc:
|
||||
print(f"Email reset failed: {exc}")
|
||||
print("Open Telegram -> Settings -> Privacy and Security -> Two-Step Verification")
|
||||
print("Add and verify a recovery email, then retry.")
|
||||
await client.disconnect()
|
||||
return
|
||||
code_type = getattr(sent, "type", None)
|
||||
print(f"Code delivery type: {type(code_type).__name__ if code_type else 'unknown'}")
|
||||
if isinstance(code_type, types.auth.SentCodeTypeEmailCode):
|
||||
|
||||
Reference in New Issue
Block a user