Command exited with code 0. Command output: if client is None: client = Client(f"{ws.session_path}_auth", api_id=self.api_id, api_hash=self.api_hash) self.auth_clients[user_id] = client try: await client.connect() sent = await client.send_code(phone) except Exception as exc: await self.send(user_id, fmt_msg("Code Failed", f"Could not send OTP: `{exc}`", error=True), keyboard=reply_kb([["šŸ” Connect Telegram"], ["šŸ”™ Back to Menu"]])) return True ws.phone = phone ws.phone_code_hash = sent.phone_code_hash ws.state = "await_code" self.save_workspace(ws) await self.send( user_id, fmt_msg("OTP Sent", "šŸ“Œ Send the 5-6 digit code with spaces between numbers.\n\nšŸ‘‰ Example: `1 2 3 4 5`\n\n_(Telegram directly bheje gaye codes ko block kar deta hai, isliye space daal kar bhejein)_\n_If it expires, tap Resend Code._", success=True), keyboard=reply_kb(OTP_KB), ) return True if ws.state == "await_code": if text == "šŸ” Resend Code": client = self.auth_clients.get(user_id) if client is None: await self.send(user_id, fmt_msg("Session Expired", "Login session expired. Please start over.", error=True), keyboard=reply_kb([["šŸ” Connect Telegram"]])) ws.state = None self.save_workspace(ws) return True try: sent = await client.resend_code(ws.phone, ws.phone_code_hash) ws.phone_code_hash = sent.phone_code_hash self.save_workspace(ws) await self.send( user_id, fmt_msg("Resent OTP", "New code has been sent to your Telegram.\n\nšŸ“Œ Send with spaces, e.g.: `1 2 3 4 5`", success=True), keyboard=reply_kb(OTP_KB), ) except Exception as exc: await self.send(user_id, fmt_msg("Resend Failed", f"Error: `{exc}`", error=True), keyboard=reply_kb(OTP_KB)) return True code = re.sub(r"\D", "", text.strip()) if len(code) < 5: await self.send(user_id, fmt_msg("Invalid Code", "Invalid code. Please send with spaces like: `1 2 3 4 5`", error=True)) return True client = self.auth_clients.get(user_id) if client is None: await self.send(user_id, fmt_msg("Session Expired", "Login session expired. Please start over.", error=True)) ws.state = None self.save_workspace(ws) return True try: result = await client.sign_in( phone_number=ws.phone, phone_code_hash=ws.phone_code_hash, phone_code=code, ) except SessionPasswordNeeded: ws.state = "await_password" self.save_workspace(ws) await self.send( user_id, fmt_msg("2FA Required", "This account has 2-Step Verification.\nPlease enter your Telegram password.", success=False), keyboard=reply_kb(BACK_KB), ) return True except BadRequest as exc: err = str(exc).lower() if "phone_code_expired" in err or "PHONE_CODE_EXPIRED" in str(exc): await self.send( user_id, fmt_msg("OTP Expired", "Tap **Resend Code** to get a new one.", error=True), keyboard=reply_kb(OTP_KB), ) else: await self.send(user_id, fmt_msg("Code Rejected", f"Error: `{exc}`\nTry again or resend.", error=True), keyboard=reply_kb(OTP_KB))