Telethon

Latest version: v1.35.0

Safety actively analyzes 629599 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 7

0.15.1

The main feature of this release is that Telethon now has a custom database for all the entities you encounter, instead depending on `lru_cache` on the `.get_entity()` method.

The `EntityDatabase` will, by default, **cache** all the users, chats and channels you find in memory for as long as the program is running. The session will, by default, save all key-value pairs of the entity identifiers and their hashes (since Telegram may send an ID that it thinks you already know about, we need to save this information).

You can **prevent** the `EntityDatabase` from saving users by setting `client.session.entities.enabled = False`, and prevent the `Session` from saving input entities at all by setting `client.session.save_entities = False`. You can also clear the cache for a certain user through `client.session.entities.clear_cache(entity=None)`, which will clear all if no entity is given.

More things:
* `.sign_in` accepts phones as integers.
* `.get_dialogs()` doesn't fail on Windows anymore, and returns the right amount of dialogs.
* New method to `.delete_messages()`.
* New `ChannelPrivateError` class
* Changing the IP to which you connect to is as simple as `client.session.server_address = 'ip'`, since now the server address is always queried from the session.
* `GeneralProxyError` should be passed to the main thread again, so that you can handle it.

0.15

After hundreds of lines changed on a major refactor, *it's finally here*. It's the **Updates Overhaul Update**; let's get right into it!

New stuff and enhancements
* You can **invoke** requests from **update handlers**. And **any other thread**. A new temporary will be made, so that you can be sending even several requests at the same time!
* **Several worker threads** for your updates! By default, `None` will spawn. I recommend you to work with `update_workers=4` to get started, these will be polling constantly for updates.
* You can also change the number of workers at any given time.
* The library can now run **in a single thread** again, if you don't need to spawn any at all. Simply set `spawn_read_thread=False` when creating the `TelegramClient`!
* You can specify `limit=None` on `.get_dialogs()` to get **all** of them<sup>[1]</sup>.
* **Updates are expanded**, so you don't need to check if the update has `.updates` or an inner `.update` anymore.
* All `InputPeer` entities are **saved in the session** file, but you can disable this by setting `save_entities=False`.
* New `.get_input_entity` method, which makes use of the above feature. You **should use this** when a request needs a `InputPeer`, rather than the whole entity (although both work).

Less important enhancements
* Assert that either all or None dependent-flag parameters are set before sending the request.
* Phone numbers can have dashes, spaces, or parenthesis. They'll be removed before making the request.
* You can override the phone and its hash on `.sign_in()`, if you're creating a new `TelegramClient` on two different places.

Compatibility breaks
* `.create_new_connection()` is gone for good. No need to deal with this manually since new connections are now handled on demand by the library itself.

Bugs fixed
* `.log_out()` was consuming all retries. It should work just fine now.
* The session would fail to load if the `auth_key` had been removed manually.
* `Updates.check_error` was popping wrong side, although it's been completely removed.
* `ServerError`'s will be **ignored**, and the request will immediately be retried.
* Cross-thread safety when saving the session file.
* Some things changed on a matter of when to reconnect, so please report any bugs!

Internal changes
* `TelegramClient` is now only an abstraction over the `TelegramBareClient`, which can only do basic things, such as invoking requests, working with files, etc. If you don't need any of the abstractions the `TelegramClient`, you can now use the `TelegramBareClient` in a much more comfortable way.
* `MtProtoSender` is not thread-safe, but it doesn't need to be since a new connection will be spawned when needed.
* New connections used to be cached and then reused. Now only their sessions are saved, as temporary connections are spawned only when needed.
* Added more RPC errors to the list.

**[1]:** Broken due to a condition which should had been the opposite (sigh), fixed 4 commits ahead on https://github.com/LonamiWebs/Telethon/commit/62ea77cbeac7c42bfac85aa8766a1b5b35e3a76c.

---

**That's pretty much it**, although there's more work to be done to make the overall experience of working with updates *even better*. Stay tuned!

0.14.2

Two bug fixes, one of them quite **important**, related to the serialization. Every object or request that had to serialize a `True/False` type was always being serialized as `false`!

Another bug that didn't allow you to leave as `None` flag parameters that needed a list has been fixed.

Other internal changes include a somewhat more readable `.to_bytes()` function and pre-computing the flag instead using bit shifting. The `TLObject.constructor_id` has been renamed to `TLObject.CONSTRUCTOR_ID`, and `.subclass_of_id` is also uppercase now.

0.14.1

Version `v0.14` had started working on the new `.to_bytes()` method to dump the `BinaryWriter` and its usage on the `.on_send()` when serializing TLObjects, and this release finally removes it. The speed up when serializing things to bytes should now be over twice as fast wherever it's needed.

Other internal changes include using proper classes (including the generated code) for generating authorization keys and to write out `TLMessage`'s.

For **bug fixes**, this version is again compatible with Python 3.x versions **below 3.5** (there was a method call that was Python 3.5 and above).

0.14

New major release, since I've decided that these two features are big enough:
* Requests larger than 512 bytes will be **compressed through gzip**, and if the result is smaller, this will be uploaded instead.
* You can now send **multiple requests at once**, they're simply `*var_args` on the `.invoke()`. Note that the server doesn't guarantee the order in which they'll be executed!

Internally, another important change. The `.on_send` function on the `TLObjects` is **gone**, and now there's a new `.to_bytes()`. From my tests, this has always been over twice as fast serializing objects, although more replacements need to be done, so please report any issues.

Besides this:
* Downloading media from CDNs wasn't working (wrong access to a parameter).
* Correct type hinting.
* Added a tiny sleep when trying to perform automatic reconnection.
* Error reporting is done in the background, and has a shorter timeout.
* Implemented `.get_input_media` helper methods. Now you can even use another message as input media!
* `setup.py` used to fail with wrongly generated code.

0.13.6

Before getting any further, here's a quick fix-up with things that should have been on `v0.13.5` but were missed. Specifically, the **timeout when receiving** a request will now work properly.

Some other additions are a tiny fix when **handling updates**, which was ignoring some of them, nicer `__str__` and `.stringify()` methods for the `TLObject`'s, and not stopping the `ReadThread` if you try invoking something there (now it simply returns `None`).

Page 2 of 7

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.