[Python] How to prevent Telegram accounts (e.g. from Myanmar) from being deleted immediately...

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using Telethon to log into Telegram accounts and save their sessions. However, when I try to log in with accounts from Myanmar or other sensitive countries, the accounts get instantly deleted right after login.

    Here is my login code:

    from telethon.sync import TelegramClient
    from telethon.sessions import StringSession

    client = TelegramClient(
    StringSession(),
    api_id,
    api_hash,
    timeout=33,
    device_model=device["device_model"],
    system_version=device["system_version"],
    app_version=device["app_version"],
    lang_code=device["lang_code"],
    system_lang_code=device["system_lang_code"]
    )

    await client.connect()
    await client.send_code_request(phone_number)


    I tried to simulate a mobile client by passing device_model, system_version, app_version, etc. But when I checked the session under Telegram > Settings > Devices, it shows it as Web Session, not a Mobile one (like Android or iPhone).

    What I tried:

    • Using StringSession()
    • Setting device_model, system_version, app_version, etc.
    • Using fresh proxies
    • Logging in manually and with proper delays

    Continue reading...

Compartilhe esta Página