Commit Graph

72 Commits

Author SHA1 Message Date
Lonami Exo
5b1135734b Properly handle PhoneCodeExpiredError in sign_in
Should actually fix #3185 now.
2023-04-06 18:53:12 +02:00
Lonami Exo
af18538722 Handle PhoneCodeExpiredError during sign_in
Closes #3185.
2023-04-06 14:36:24 +02:00
Lonami Exo
a657ae0134 Save self user ID in session file
Should result in one less request after connecting,
as there is no longer a need to fetch the self user.
2023-04-06 14:18:42 +02:00
Lonami Exo
88bc6a46a6 Store self user in entity cache 2023-04-06 13:58:26 +02:00
Lonami Exo
07a7a8b404 Deprecate force_sms and sign_up
On the 10th of February, Telegram sent the following message to
those with an application registered on https://my.telegram.org.

--

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

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.
2023-02-26 10:40:53 +01:00
Lonami Exo
6dece6e8a1 Update to layer 152 2023-02-05 15:05:05 +01:00
Lonami Exo
83f13da420 Don't error when calling disconnect after logout 2022-11-27 11:22:30 +01:00
Lonami Exo
346a3f0ef5 Add note on 2FA for qr_login 2022-09-21 12:28:51 +02:00
Lonami Exo
a83fe46baf Document the client instance cannot be used after logout
Closes #3780.
2022-09-21 12:00:55 +02:00
Lonami Exo
7d21b40401 Revert "Make sessions async"
This reverts commit d2de0f3aca.
2022-08-30 12:32:21 +02:00
Lonami Exo
898eb5b82f Call GetState on login to init MessageBox 2022-05-16 10:05:07 +02:00
Lonami Exo
b5bfe5d9a1 Remove StateCache 2022-05-13 12:43:50 +02:00
Tulir Asokan
f351d5dcfd Handle expired phone codes. Fixes mautrix/telegram#326 2022-05-12 10:39:27 +02:00
Tulir Asokan
d2de0f3aca Make sessions async
SQLiteSession is not updated, don't try to use it
2022-05-12 10:36:10 +02:00
Qwerty-Space
d56b27e570
Fix several minor typos (#1603) 2020-10-18 21:11:59 +02:00
Lonami Exo
4e1f582b17 Call sign_in during sign_up if needed to send the code 2020-10-15 11:43:35 +02:00
penn5
1a9accbe5d
Fix warning when using formatted phones in start (#1532) 2020-08-24 10:53:29 +02:00
Lonami Exo
ddeefff431 Add a warning when trying to connect to a different account
Closes #1172, and also fixed a typo.
2020-08-08 17:49:00 +02:00
Lonami Exo
3f74f83964 Move qrlogin with the rest of custom types 2020-06-06 13:47:56 +02:00
Lonami Exo
c904b7ccd8 Add a friendly method for QR login
Closes #1471.
2020-06-05 21:58:59 +02:00
Lonami Exo
b985dcd248 Fix 3.8 syntax warning and erroneous documentation
Closes #1340 (syntax warning)
Closes #1341 (outdated docs)
2019-12-05 11:14:02 +01:00
Lonami Exo
7de01a5f94 Fix resending code with empty phone hash (fix #1283) 2019-09-27 10:41:01 +02:00
Lonami Exo
42874de2b2 Fix start() and sign_up() flow for layer 104 2019-08-16 19:19:42 +02:00
Lonami Exo
e1905d0d7a Avoid using telethon.sync in the examples 2019-08-13 23:33:39 +02:00
Lonami Exo
8e36bb4c4d Link Python keywords with Python's documentation 2019-07-06 12:11:00 +02:00
Lonami Exo
b6b4ea669d Remove messy subclassing in the TelegramClient
Since it was easy to cause MRO inconsistencies, and it's
not really needed now that self is type hinted as the client.
2019-06-24 17:48:46 +02:00
Lonami Exo
51de0bd2da Update documentation with intersphinx and better summaries 2019-06-11 11:09:22 +02:00
Lonami Exo
9f72bd8ca3 Fix manual raising of RPC errors 2019-05-27 18:18:38 +02:00
Lonami Exo
e5485f3d54 Document raw methods with friendly variants 2019-05-26 21:15:43 +02:00
Lonami Exo
7c1c040d50 Update docstrings to have consistent style 2019-05-20 11:57:11 +02:00
Lonami Exo
0a3d6106f0 Completely overhaul the documentation 2019-05-09 12:50:09 +02:00
Lonami Exo
d92d989569 Quote type hints
Otherwise, sphinx completely butchers the documentation.
2019-05-08 17:16:09 +02:00
Lonami Exo
61613ab6ac Create a new page with a summary of the method reference 2019-05-06 11:38:26 +02:00
Lonami Exo
cd4b915522 Add type hints to all public methods in the client 2019-05-03 21:38:41 +02:00
Lonami Exo
c0e506e568 Add missing await on send_code_request 2019-05-03 21:38:41 +02:00
Lonami Exo
c1880c9191 Fix pts from channels is different (#1160) 2019-04-21 13:56:14 +02:00
Lonami Exo
9090ede5db Reduce __enter__/__exit__ boilerplate for sync ctx managers 2019-04-13 10:53:33 +02:00
Lonami Exo
9965cda968 Save pts and date in a tuple for immutability
This way it is easy and cheap to copy the two required values
to all incoming updates in case we need to getDifference since
the previous pts/date to fetch entities.

This is still a work in progress.
2019-04-10 21:10:34 +04:00
Lonami Exo
5377169db2 Call catch_up on reconnect (WIP for #1125) 2019-03-28 12:32:02 +01:00
Lonami Exo
9eabca6987 Fix run_until_disconnected's call to disconnect 2019-03-22 18:20:10 +01:00
Lonami Exo
04ba2e1fc7 Revert disconnect() to be async again (#1133)
It's the only way to properly clean all background tasks,
which the library makes heavy use for in MTProto/Connection
send and receive loops.

Some parts of the code even relied on the fact that it was
asynchronous (it used to return a future so you could await
it and not be breaking).

It's automatically syncified to reduce the damage of being
a breaking change.
2019-03-21 12:21:00 +01:00
Lonami Exo
0934f71c02 Update to layer 95 2019-02-21 12:40:47 +01:00
Lonami Exo
d1c755809d Except RpcMcgetFailError as call fail and sleep on server errors
This one in particular may happen when iterating over messages,
perhaps more likely to happen if the group was created in a
different data center.

A small sleep of a few seconds also greatly increases the
chances of the error going away.
2019-02-14 11:00:37 +01:00
nosanity
2e544270cd Fix login failure due to wrong argument name (#1109) 2019-02-14 16:46:57 +10:00
Lonami Exo
4899788d92 Expose phone and phone_code_hash in sign_up 2019-02-12 11:44:36 +01:00
Lonami Exo
10cd61d2f9 Add missing timezone info in important places
Things like SQLAlchemy work correctly only for timezone-aware datetimes.
The returned TLObjects all have them, but those that are manually created
were missing them, so serializing the state into SQLAlchemy sessions failed.
2019-01-24 11:16:40 +01:00
Lonami Exo
51f0bf5d84 Fully support email in edit_2fa 2019-01-14 13:57:07 +01:00
Aaron Gallagher
b0e0bc3701 Extend new_algo.salt1 to fix edit_2fa (#1072)
The salt1 that is sent to the server requires an additional 32 bytes
of random data. It's easy to miss this requirement from reading the 
tdesktop source, because this extension is done in a function called
`ValidateNewCloudPasswordAlgo`.

https://github.com/telegramdesktop/tdesktop/blob/2e5a0e056cdb40d61d487c6062bffe1a835f
6ddd/Telegram/SourceFiles/core/core_cloud_password.cpp#L210-L211
2018-12-24 21:16:09 +01:00
Lonami Exo
f16ed8235c Add new is_bot method to check if the logged-in user is a bot 2018-12-24 17:32:34 +01:00
Lonami Exo
46fea3fc93 Implement clearing password in edit_2fa 2018-12-24 16:30:45 +01:00