Telethon

Latest version: v1.38.1

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

Scan your dependencies

Page 1 of 7

0.16.1

Please refer to [Read The Docs - Changelog (Version History)](https://docs.telethon.dev/en/stable/misc/changelog.html) for the changelog from now on! You should read it every time you update the library, a considerable amount of effort is put into it and should save you from some "my code worked but not anymore".

0.16

In the beginning, session files used to be pickle. This proved to be bad as soon as one wanted to add more fields. For this reason, they were migrated to use JSON instead. But this proved to be bad as soon as one wanted to save things like entities (usernames, their ID and hash), so now it properly uses [**`sqlite3`**](https://docs.python.org/3/library/sqlite3.html), which has been well tested, to save the session files! Calling `.get_input_entity` using a `username` no longer will need to fetch it first, so it's really 0 calls again. Calling `.get_entity` will always fetch the most up to date version.

Furthermore, nearly everything has been documented, thus preparing the library for [Read the Docs](https://readthedocs.org/) (although there are a few things missing I'd like to polish first), and the [`logging`](https://docs.python.org/3/library/logging.html) are now better placed.



Breaking changes
* `.get_dialogs()` now returns a **single list** instead a tuple consisting of a **custom class** that should make everything easier to work with.
* `.get_message_history()` also returns a **single list** instead a tuple, with the `Message` instances modified to make them more convenient.

Both lists have a `.total` attribute so you can still know how many dialogs/messages are in total.

New stuff
* The mentioned use of `sqlite3` for the session file.
* `.get_entity()` now supports lists too, and it will make as little API calls as possible if you feed it `InputPeer` types. Usernames will always be resolved, since they may have changed.
* `.set_proxy()` method, to avoid having to create a new `TelegramClient`.
* More `date` types supported to represent a date parameter.

Bug fixes
* Empty strings weren't working when they were a flag parameter (e.g., setting no last name).
* Fix invalid assertion regarding flag parameters as well.
* Avoid joining the background thread on disconnect, as it would be `None` due to a race condition.
* Correctly handle `None` dates when downloading media.
* `.download_profile_photo` was failing for some channels.
* `.download_media` wasn't handling `Photo`.

Internal changes
* `date` was being serialized as local date, but that was wrong.
* `date` was being represented as a `float` instead of an `int`.
* `.tl` parser wasn't stripping inline comments.
* Removed some redundant checks on `update_state.py`.
* Use a [synchronized queue](https://docs.python.org/3/library/queue.html) instead a hand crafted version.
* Use signed integers consistently (e.g. `salt`).
* Always read the corresponding `TLObject` from API responses, except for some special cases still.
* A few more `except` low level to correctly wrap errors.
* More accurate exception types.
* `invokeWithLayer(initConnection(X))` now wraps every first request after `.connect()`.

As always, report if you have issues with some of the changes!

0.15.5

<table><tr><td>Scheme layer used: <code>73</code></td></tr></table>

It's here, it has come! The library now **supports IPv6**! Just pass `use_ipv6=True` when creating a `TelegramClient`. Note that I could *not* test this feature because my machine doesn't have IPv6 setup. If you know IPv6 works in your machine but the library doesn't, please refer to 425.

Additions
* IPv6 support.
* New method to extract the text surrounded by `MessageEntity`'s, in the `extensions.markdown` module.

Enhancements
* Markdown parsing is Done Right.
* Reconnection on failed invoke. Should avoid "number of retries reached 0" (270).
* Some missing autocast to `Input*` types.
* The library uses the `NullHandler` for `logging` as it should have always done.
* `TcpClient.is_connected()` is now more reliable.

Bug fixes
* Getting an entity using their phone wasn't actually working.
* Full entities aren't saved unless they have an `access_hash`, to avoid some `None` errors.
* `.get_message_history` was failing when retrieving items that had messages forwarded from a channel.

0.15.4

<table><tr><td>Scheme layer used: <code>72</code></td></tr></table>

This update brings a few general enhancements that are enough to deserve a new release, with a new feature: beta **markdown-like parsing** for `.send_message()`!

Additions
* `.send_message()` supports `parse_mode='md'` for **Markdown**! It works in a similar fashion to the official clients (defaults to double underscore/asterisk, like `**this**`). Please report any issues with emojies or enhancements for the parser!
* New `.idle()` method so your main thread can do useful job (listen for updates).
* Add missing `.to_dict()`, `__str__` and `.stringify()` for `TLMessage` and `MessageContainer`.

Bug fixes
* The list of known peers could end "corrupted" and have users with `access_hash=None`, resulting in `struct` error for it not being an integer. You shouldn't encounter this issue anymore.
* The warning for "added update handler but no workers set" wasn't actually working.
* `.get_input_peer` was ignoring a case for `InputPeerSelf`.
* There used to be an exception when logging exceptions (whoops) on update handlers.
* "Downloading contacts" would produce strange output if they had semicolons (`;`) in their name.
* Fix some cyclic imports and installing dependencies from the `git` repository.
* Code generation was using f-strings, which are only supported on Python ≥3.6.

Other changes
* The `auth_key` generation has been moved from `.connect()` to `.invoke()`. There were some issues were `.connect()` failed and the `auth_key` was `None` so this will ensure to have a valid `auth_key` when needed, even if `BrokenAuthKeyError` is raised.
* Support for higher limits on `.get_history()` and `.get_dialogs()`.
* Much faster integer factorization when generating the required `auth_key`. Thanks delivrance for making me notice this, and for the pull request.

0.15.3

Hopefully a very ungrateful bug has been removed. When you used to invoke some request through update handlers, it could potentially enter an infinite loop. This has been mitigated and it's now safe to invoke things again! A lot of updates were being dropped (all those gzipped), and this has been fixed too.

More bug fixes include a [correct parsing](https://github.com/LonamiWebs/Telethon/commit/ee01724cdb7027c1e38625d31446ba1ea7bade92) of certain TLObjects thanks to stek29, and [some](https://github.com/LonamiWebs/Telethon/commit/ed77ba6f8ff115ac624f02f691c9991e5b37be60) [wrong calls](https://github.com/LonamiWebs/Telethon/commit/16cf94c9add5e94d70c4eee2ac142d8e76af48b9) that would cause the library to crash thanks to andr-04, and the `ReadThread` not re-starting if you were already authorized.

Internally, the `.to_bytes()` function has been replaced with `__bytes__` so now you can do `bytes(tlobject)`.

0.15.2

This release primarly focuses on a few bug fixes and enhancements. Although more stuff may have broken along the way.

Bug fixes:
* `.get_input_entity` was failing for IDs and other cases, also making more requests than it should.
* Use `basename` instead `abspath` when sending a file. You can now also override the attributes.
* ` EntityDatabase.__delitem__` wasn't working.
* `.send_message()` was failing with channels.
* `.get_dialogs(limit=None)` should now return all the dialogs correctly.
* Temporary fix for abusive duplicated updates.

Enhancements:
* You will be warned if you call `.add_update_handler` with no `update_workers`.
* New customizable threshold value on the session to determine when to automatically sleep on flood waits. See `client.session.flood_sleep_threshold`.
* New `.get_drafts()` method with a custom `Draft` class by JosXa.
* Join all threads when calling `.disconnect()`, to assert no dangling thread is left alive.
* Larger chunk when downloading files should result in faster downloads.
* You can use a callable key for the `EntityDatabase`, so it can be any filter you need.

Internal changes:
* MsgsAck is now sent in a container rather than its own request.
* `.get_input_photo` is now used in the generated code.
* `.process_entities` was being called from more places than only `__call__`.
* `MtProtoSender` now relies more on the generated code to read responses.

Page 1 of 7

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.