Sessions as sqlite databases
Pre-releaseIn 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
, 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 (although there are a few things missing I'd like to polish first), and the logging
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 theMessage
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 itInputPeer
types. Usernames will always be resolved, since they may have changed..set_proxy()
method, to avoid having to create a newTelegramClient
.- 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 handlingPhoto
.
Internal changes
date
was being serialized as local date, but that was wrong.date
was being represented as afloat
instead of anint
..tl
parser wasn't stripping inline comments.- Removed some redundant checks on
update_state.py
. - Use a synchronized queue 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!