LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
9.82k stars 1.4k forks source link

Telegram has stopped sending SMS code. #3835

Closed Subachev closed 2 years ago

Subachev commented 2 years ago

Checklist

Code that causes the issue

self.telethon_client = TelegramClient(
            StringSession(),
            self.device_data.api_id,
            self.device_data.api_hash,
            proxy=self.proxy_data.tg_proxy,
            device_model=self.device_data.device_model,
            app_version=self.device_data.app_version,
            system_version=self.device_data.system_version,
        )
        self.telethon_client.start(
            first_name=first_name,
            last_name=last_name,
            phone=lambda: phone_number,
            force_sms=True,
            max_attempts=2,
        )
...

For a long time everything worked fine, but yesterday we ran into a problem. SMS messages stopped being sent from telegram. At all. We used various proxies, api_id/api_hash, phone numbers (mostly +7 and a little +1). There is no error or warning. Everything is as usual. But telegram just doesn't send SMS.

We tried to send the SMS code immediately using the send_code_request method. The result is the same.

Lonami commented 2 years ago

The library is making the requests to Telegram for it to send the SMS. If Telegram isn't sending the SMS even after it was requested to do so, it probably has its own reasons (avoid spam), and Telethon can likely do nothing about it.

w1ld32 commented 2 years ago

I have been trying to solve this problem for 3 days. But to no avail. Codes come from official apps, but not from the telethon(

Lonami commented 2 years ago

This might be Telegram's anti-spam measures. There is not much that can be done by Telethon to mitigate this.

w1ld32 commented 2 years ago

The codes do not even come to the official Telegram client on the PC. Not for any major third-party client (Telegram X, X Chat). The problem is definitely not in the Thelethon, but I want to solve it somehow (

ZE1L commented 2 years ago

works fine for me, uninstall telethon and reinstall it

Lonami commented 2 years ago

Closing since this is not something Telethon can fix. It's just the way Telegram decides to work. Telethon is making the necessary requests for Telegram to send the code, but if it still doesn't, well, then Telegram is simply ignoring the request Telethon made.

dumpload commented 2 years ago

Try to send SMS verification or verification code, it may be sent successfully, the possibility is very small, this problem may be the problem of tg node

Lonami commented 1 year ago

Also duplicate of #3822.

Lonami commented 1 year ago

And #3697, and #3719, and probably a few others.

Lonami commented 1 year ago

On the 10th of February, Telegram sent this message to those with an application registered on https://my.telegram.org:

Telegram API Update. Hello ▒▒▒▒,. Thank you for contributing to the open Telegram ecosystem by developing your app, ▒▒▒▒.

Please note that due to recent updates to Telegram's handling of SMS and the integration of new SMS providers like Firebase, we are changing the way login codes are handled in third-party apps based on the Telegram API.

Starting on 18.02.2023, users logging into third-party apps will only be able to receive login codes via Telegram. It will no longer be possible to request an SMS to log into your app – just like when logging into Telegram's own desktop and web clients.

Exactly like with the Telegram Desktop and Web apps, if a user doesn’t have a Telegram account yet, they will need to create one first using an official mobile Telegram app.

We kindly ask you to update your app’s login and signup interfaces to reflect these changes before they go live on 18.02.2023 at 13:00 UTC.

This change will not significantly affect users since, according to our research, the vast majority of third-party app users also use official Telegram apps. In the coming months, we expect to offer new tools for third-party developers that will help streamline the login process.

What this means for Telethon:

Why has Telegram done this? Probably in an attempt to reduce spam, and also because sending SMS is likely not cheap at their scale. Another possible reason may be security. We cannot know. Telethon cannot do anything to bypass these new limitations, and won't try playing tricks to do so.