[Python] Telethon check number

Discussão em 'Python' iniciado por Stack, Março 25, 2025.

  1. Stack

    Stack Membro Participativo

    I need to receive information about a large number of Telegram numbers, and more specifically: is the number blocked in Telegram or not, is the mail linked. Ideally, I need to track numbers that are either not registered in Telegram at all or numbers that I could log into via SMS. I tried to implement this in python using Telethon, but it didn't work.

    async def check_number(phone, api_id, api_hash, pbar):
    safe_phone = phone.replace("+", "").replace(" ", "").replace("-", "")
    client = TelegramClient(f"{SESSIONS_DIR}/{safe_phone}", api_id, api_hash)
    try:
    await client.connect()

    request = await client(SendCodeRequest(phone))

    if hasattr(request, 'email_pattern') and request.email_pattern:
    results["Numbers with email"].append(phone)
    else:
    results["The number is not registered"].append(phone)

    except PhoneNumberBannedError:
    results["Blocked numbers"].append(phone)
    except PhoneNumberUnoccupiedError:
    results["The number is not registered"].append(phone)
    except FloodWaitError:
    results["The number is not registered"].append(phone)
    except Exception:
    results["The number is not registered"].append(phone)


    As a result, I want to divide the phone numbers into groups, but this method is not working, it classifies all the numbers as unregistered. I managed to implement a number lock check, but this is not my only ultimate goal. How can I implement a proper check for the presence of mail and is it possible to find out if the account linked to the number has 2FA at all (in the form of mail or password)? I want to clarify that I do not need to access (log in) to the accounts themselves, I just want to find out if the number is blocked or not and if there is mail on it.

    Continue reading...

Compartilhe esta Página