Skip to content

Releases: LonamiWebs/Telethon

Newbie friendly update

22 Aug 23:59
Compare
Choose a tag to compare
Pre-release
Scheme layer used: 70

This update is overall an attempt to make Telethon a bit more user friendly, along with some other stability enhancements, although it brings quite a few changes.

Things that will probably break your code

  • The TelegramClient methods .send_photo_file(), .send_document_file() and .send_media_file() are now a single method called .send_file(). It's also important to note that the order of the parameters has been swapped: first to who you want to send it, then the file itself.

  • The same applies to .download_msg_media(), which has been renamed to .download_media(). The method now supports a Message itself too, rather than only Message.media. The specialized .download_photo(), .download_document() and .download_contact() still exist, but are private.

More new stuff

  • Updated to layer 70!
  • Both downloading and uploading now support stream-like objects.
  • A lot faster initial connection if sympy is installed (can be installed through pip).
  • libssl will also be used if available on your system (likely on Linux based systems). This speed boost should also apply to uploading and downloading files.
  • You can use a phone number or an username for methods like .send_message(), .send_file(), and all the other quick-access methods provided by the TelegramClient.

Bug fixes

  • Crashing when migrating to a new layer and receiving old updates should not happen now.
  • InputPeerChannel is now casted to InputChannel automtically too.
  • .get_new_msg_id() should now be thread-safe. No promises.
  • Logging out on macOS caused a crash, which should be gone now.
  • More checks to ensure that the connection is flagged correctly as either connected or not.

Bug additions

  • Downloading files from CDN's will not work yet (something new that comes with layer 70).

That's it, any new idea or suggestion about how to make the project even more friendly is highly appreciated.

P.S.: Did you know that you can pretty print any result Telegram returns (called TLObject's) by using their .stringify() function? Great for debugging!

get_input_* now works with vectors

11 Jul 09:39
Compare
Choose a tag to compare
Pre-release

Quick fix-up of a bug which hadn't been encountered until now. Auto-cast by using get_input_* now works.

get_input_* everywhere

10 Jul 14:19
Compare
Choose a tag to compare
Pre-release
Scheme layer used: 68

For some reason, Telegram doesn't have enough with the InputPeer. There also exist InputChannel and InputUser! You don't have to worry about those anymore, it's handled internally now.

Besides this, every Telegram object now features a new default .__str__ look, and also a .stringify() method to pretty format them, if you ever need to inspect them.

The library now uses the DEBUG level everywhere, so no more warnings or information messages if you had logging enabled.

The no_webpage parameter from .send_message has been renamed to link_preview for clarity, so now it does the opposite (but has a clearer intention).

Quick .send_message() fix

05 Jul 08:24
Compare
Choose a tag to compare
Pre-release

A very quick follow-up release to fix a tiny bug with .send_message(), no new features.

Callable TelegramClient

04 Jul 09:09
Compare
Choose a tag to compare
Pre-release
Scheme layer used: 68 (changes)

There is a new preferred way to invoke requests, which you're encouraged to use:

# New!
result = client(SomeRequest())

# Old.
result = client.invoke(SomeRequest())

Existing code will continue working, since the old .invoke() has not been deprecated.

When you .create_new_connection(), it will also handle FileMigrateError's for you, so you don't need to worry about those anymore.

Bugs fixed:

  • Fixed some errors when installing Telethon via pip (for those using either source distributions or a Python version ≤ 3.5).
  • ConnectionResetError didn't flag sockets as closed, but now it does.

On a more technical side, msg_id's are now more accurate.

Improvements to the updates

24 Jun 16:25
Compare
Choose a tag to compare
Pre-release
Scheme layer used: 66

Receiving new updates shouldn't miss any anymore, also, periodic pings are back again so it should work on the long run.

On a different order of things, .connect() also features a timeout. Notice that the timeout= is not passed as a parameter anymore, and is instead specified when creating the TelegramClient.

Some other bug fixes:

  • Fixed some name class when a request had a .msg_id parameter.
  • The correct amount of random bytes is now used in DH request
  • Fixed CONNECTION_APP_VERSION_EMPTY when using temporary sessions.
  • Avoid connecting if already connected.

Support for parallel connections

16 Jun 08:34
Compare
Choose a tag to compare
Pre-release
Scheme layer used: 66

This update brings a lot of changes, so it would be nice if you could read the whole change log!

Things that may break your code

  • Every Telegram error has now its own class, so it's easier to fine-tune your except's.
  • Markdown parsing is not part of Telethon itself anymore, although there are plans to support it again through a some external module.
  • The .list_sessions() has been moved to the Session class instead.
  • The InteractiveTelegramClient is not shipped with pip anymore.

New features

  • A new, more lightweight class has been added. The TelegramBareClient is now the base of the normal TelegramClient, and has the most basic features.
  • New method to .create_new_connection(), which can be ran in parallel with the original connection. This will return the previously mentioned TelegramBareClient already connected.
  • Any file object can now be used to download a file (for instance, a BytesIO() instead a file name).
  • Vales like random_id are now automatically inferred, so you can save yourself from the hassle of writing generate_random_long() everywhere. Same applies to .get_input_peer(), unless you really need the extra performance provided by skipping one if if called manually.
  • Every type now features a new .to_dict() method.

Bug fixes

  • Received errors are acknowledged to the server, so they don't happen over and over.
  • Downloading media on different data centers is now up to x2 faster, since there used to be an InvalidDCError for each file part tried to be downloaded.
  • Lost messages are now properly skipped.
  • New way to handle the result of requests. The old ValueError "The previously sent request must be resent. However, no request was previously sent (possibly called from a different thread)." should not happen anymore.

Minor highlights

  • Some fixes to the JsonSession.
  • Fixed possibly crashes if trying to .invoke() a Request while .reconnect() was being called on the UpdatesThread.
  • Some improvements on the TcpClient, such as not switching between blocking and non-blocking sockets.
  • The code now uses ASCII characters only.
  • Some enhancements to .find_user_or_chat() and .get_input_peer().

JSON session file

07 Jun 18:23
Compare
Choose a tag to compare
JSON session file Pre-release
Pre-release
Scheme layer used: 66

This version is primarily for people to migrate their .session files, which are pickled, to the new JSON format. Although slightly slower, and a bit more vulnerable since it's plain text, it's a lot more resistant to upgrades.

Please upgrade to this version before any higher one if you've used Telethon ≤ v0.10. If you happen to upgrade to an higher version, that's okay, but you will have to manually delete the *.session file, and logout from that session from an official client.

Other highlights:

  • New .get_me() function to get the current user.
  • .is_user_authorized() is now more reliable.
  • New nice button to copy the from telethon.tl.xxx.yyy import Yyy on the online documentation.
  • Everything on the documentation is now, theoretically, sorted alphabetically.
  • More error codes added to the errors file.
  • No second thread is spawned unless one or more update handlers are added.

Full support for different DCs and ++stable

03 Jun 13:50
Compare
Choose a tag to compare
Scheme layer used: 66

Working with different data centers finally works! On a different order of things, reconnection is now performed automatically every time Telegram decides to kick us off their servers, so now Telethon can really run forever and ever! In theory.

Another important highlights:

  • Documentation improvements, such as showing the return type.
  • The msg_id too low/high error should happen less often, if any.
  • Sleeping on the main thread is not done anymore. You will have to except FloodWaitError's.
  • You can now specify your own application version, device model, system version and language code.
  • Code is now more pythonic (such as making some members private), and other internal improvements (which affect the updates thread), such as using logger instead a bare print() too.

This brings Telethon a whole step closer to v1.0, though more things should preferably be changed.

Stability improvements

23 May 08:39
Compare
Choose a tag to compare
Pre-release
Scheme layer used: 66 (changes)

Telethon used to crash a lot when logging in for the very first time. The reason for this was that the reconnection (or dead connections) were not handled properly. Now they are, so you should be able to login directly, without needing to delete the *.session file anymore. Notice that downloading from a different DC is still a WIP.

Some highlights:

  • Updates thread is only started after a successful login.
  • Files meant to be ran by the user now use shebangs and proper permissions.
  • In-code documentation now shows the returning type.
  • Relative import is now used everywhere, so you can rename telethon to anything else.
  • Dead connections are now detected instead entering an infinite loop.
  • Sockets can now be closed (and re-opened) properly.
  • Telegram decided to update the layer 66 without increasing the number. This has been fixed and now we're up-to-date again.