Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Banned account #4468

Closed
3 tasks done
KR3ND31 opened this issue Sep 19, 2024 · 1 comment
Closed
3 tasks done

Banned account #4468

KR3ND31 opened this issue Sep 19, 2024 · 1 comment

Comments

@KR3ND31
Copy link

KR3ND31 commented Sep 19, 2024

Code that causes the issue

async def is_account_session_valid(self) -> TelegramClient | None:
    """Checks the validity of a session, including proxy and connection to Telegram servers."""

    proxy = None
    if self.proxy:
        proxy = (
            self.proxy.proxy_type, self.proxy.ip, self.proxy.port, True, self.proxy.username, self.proxy.password)

        if not self.proxy.check_proxy():
            print(f"Error. Proxy is not working")
            return None

    try:
        client = TelegramClient(StringSession(self.session_string), self.api_id, self.api_hash, proxy=proxy,
                                device_model=self.device_model, system_version=self.system_version,
                                app_version=self.app_version, lang_code=self.lang_code,
                                system_lang_code=self.system_lang_code)
        await client.connect()
        if not await client.is_user_authorized():
            print(f"Session is not authorized for account {self.telegram_id}")
            await client.disconnect()
            return None

        print(f"Session is valid for account {self.telegram_id}")
        return client  # Return connected TelegramClient
    except (SessionPasswordNeededError, Exception) as e:
        print(f"Error checking session for account {self.telegram_id}: {e}")
        return None

### Expected behavior

No ban

### Actual behavior

I have a pre-registered account through the mobile app. I successfully log into it using Telethon, with my phone and two-factor authentication. However, after running the code several times with this active session (StringSession), my account gets banned and deleted.

### Traceback

Proxy successfully checked via http://httpbin.org/ip. Ping: 574.9 ms
Session is not authorized for account 7184956349
Authorizing for account 7184956349
Authentication error: The used phone number has been banned from Telegram and cannot be used anymore. Maybe check https://www.telegram.org/faq_spam (caused by SendCodeRequest)

Telethon version

1.36.0

Python version

3.9.13

Operating system (including distribution name and version)

Win 10

Other details

No response

Checklist

  • The error is in the library's code, and not in my own.
  • I have searched for this issue before posting it and there isn't an open duplicate.
  • I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip and triggered the bug in the latest version.
@Lonami
Copy link
Member

Lonami commented Sep 19, 2024

#824

@Lonami Lonami closed this as completed Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants