Commit Graph

120 Commits

Author SHA1 Message Date
Lonami Exo
b716c4fe67 Several documentation enhancements and build warnings fixes
- Made the documentation even more friendly towards newbies.
- Eased the usage of methods like get history which now set
  a default empty message for message actions and vice versa.
- Fixed some docstring documentations too.
- Updated the old normal docs/ to link back and forth RTD.
- Fixed the version of the documentation, now auto-loaded.
2018-01-20 11:47:17 +01:00
Lonami Exo
4d4e81e609 Fix cyclic imports on Python 3.4 by moving Session one level up 2018-01-19 22:55:28 +01:00
Lonami Exo
33e50aaee1 Reuse .on_response/.__str__/.stringify, override iff necessary 2018-01-19 12:12:52 +01:00
Lonami Exo
1c9fa76ede Add new method to .resolve() parameters instead on init
TLObject's __init__ used to call utils.get_input_* methods and
similar to auto-cast things like User into InputPeerUser as
required. Now there's a custom .resolve() method for this purpose
with several advantages:
- Old behaviour still works, autocasts work like usual.

- A request can be constructed and later modified, before the
  autocast only occured on the constructor but now while invoking.

- This allows us to not only use the utils module but also the
  client, so it's even possible to use usernames or phone numbers
  for things that require an InputPeer. This actually assumes
  the TelegramClient subclass is being used and not the bare version
  which would fail when calling .get_input_peer().
2018-01-19 11:47:45 +01:00
Lonami Exo
b546c02210 Return a custom class for sized InputFile instead extra attrs 2018-01-18 20:09:59 +01:00
Lonami Exo
0e4611a593 Properly implement InputPhoto/InputDocument caching
Since uploading a file is done on the TelegramClient, and the
InputFiles are only valid for a short period of time, it only
makes sense to cache the sent media instead (which should not
expire). The problem is the MD5 is only needed when uploading
the file.

The solution is to allow this method to check for the wanted
cache, and if available, return an instance of that, so to
preserve the flexibility of both options (always InputFile,
or the cached InputPhoto/InputDocument) instead reuploading.
2018-01-18 19:36:47 +01:00
Lonami Exo
7e707dbbd9 Fix using enum on sqlite instead its value 2018-01-18 19:35:46 +01:00
Lonami Exo
55efb2b104 Use a different schema for file cache which actually persists
Caching the inputFile values would not persist accross several
days so the cache was nearly unnecessary. Saving the id/hash of
the actual inputMedia sent is a much better/persistent idea.
2018-01-18 09:52:39 +01:00
Lonami Exo
494c90af69 Fix uploaded files cache may have expired 2018-01-15 12:36:46 +01:00
Lonami Exo
045f7f5643 Assert hash is not None when migrating from JSON sessions 2018-01-10 10:46:43 +01:00
Lonami Exo
3c686fecdf Avoid more cyclic imports on the session file 2018-01-08 12:14:03 +01:00
Lonami Exo
34fe150096 Save only one auth_key on the database again 2018-01-07 00:38:30 +01:00
Lonami Exo
7745b8e7ee Use without rowid only if supported (closes #523) 2018-01-06 19:35:24 +01:00
Lonami Exo
f357d00911 Assert user/channel ID is non-zero too for #392 2018-01-06 15:54:27 +01:00
Lonami Exo
ec4ca5dbfc More consistent with asyncio branch (style/small fixes)
Like passing an extra (invalid) dt parameter when serializing
a datetime, and handling more errors in the TcpClient class.
2018-01-05 18:31:48 +01:00
Lonami Exo
c4e26c95f5 Always cache files smaller than 10MB, now in the database
This removes the need for a .clear_cache() method as now files
are identified by their MD5 (which needs to be calculated
always) and their file size (to make collisions even more
unlikely) instead using the file path (which can now change).
2018-01-05 15:33:25 +01:00
Lonami Exo
cbf6306599 Fix early cast to input from 932ed9e causing error on Peer 2017-12-29 22:07:16 +01:00
Lonami Exo
d2121c76cb Fetch and persist each auth_key per DC 2017-12-29 19:41:12 +01:00
Lonami Exo
0570c55120 Remove hardcoded database version from session sql statement 2017-12-29 00:43:52 +01:00
Lonami Exo
47b53ce89f Except only UnicodeDecodeError to check migration (fix #511) 2017-12-28 17:06:14 +01:00
Lonami Exo
4a139b0ae4 Fix session table may be empty if no DC switch 2017-12-28 14:58:42 +01:00
Lonami Exo
55b67b65a1 Remove optional add_mark parameter from .get_peer_id
It was always True after all, and it made no sense for it to
be False.
2017-12-28 13:31:43 +01:00
Lonami Exo
3537e9bcc9 Support more types to represent a date 2017-12-28 12:32:16 +01:00
Lonami Exo
52a4ef82f4 Merge branch 'master' of github.com:LonamiWebs/Telethon 2017-12-28 01:17:30 +01:00
Lonami Exo
ab07f0220a Save dc_id instead layer and salt in the session file
Server salts change every 30 minutes after all, so keeping them
in the long-term storage session file doesn't make much sense.

Saving the layer doesn't make sense either, as it was only used
to know whether to init connection or not, but it should be done
always.
2017-12-28 01:06:27 +01:00
Dmitry D. Chernov
6ec6967ff9 Make exception types correspond to Python docs 2017-12-28 09:48:02 +10:00
Lonami Exo
f29ee41f6c Don't use rowid for the entities table 2017-12-27 13:27:54 +01:00
Lonami Exo
932ed9ea9d Cast to input peer early on get input entity and close cursor 2017-12-27 13:06:03 +01:00
Lonami Exo
843e777eba Simplify .process_entities() flow 2017-12-27 12:58:50 +01:00
Lonami Exo
b6b47d175c Fix username.lower() on instances with username field but None 2017-12-27 12:16:49 +01:00
Lonami Exo
86429e7291 Lowercase usernames before adding them to the database 2017-12-27 11:54:08 +01:00
Lonami Exo
aef96f1b68 Remove custom EntityDatabase and use sqlite3 instead
There are still a few things to change, like cleaning up the
code and actually caching the entities as a whole (currently,
although the username/phone/name can be used to fetch their
input version which is an improvement, their full version
needs to be re-fetched. Maybe it's a good thing though?)
2017-12-27 00:50:09 +01:00
Lonami Exo
0a4849b150 Small cleanup of the Session class 2017-12-26 16:59:30 +01:00
Lonami Exo
664417b409 Use sqlite3 instead JSON for the session files 2017-12-26 16:45:47 +01:00
Lonami Exo
238198db5a Create a convenient class to wrap Dialog instances 2017-12-24 16:18:09 +01:00
Lonami Exo
23ab70fc29 Remove unused request_msg_id from the TLObject class 2017-12-20 17:48:41 +01:00
Lonami Exo
7d189119f4 Fix salt migration failing with valid signed salts 2017-12-20 12:47:39 +01:00
Lonami Exo
d4d7aa9063 Use signed salt 2017-12-03 21:10:22 +01:00
Dmitry D. Chernov
5a4d6d4a57 tlobject: Represent timestamp as 'int' instead of 'float' 2017-11-23 22:39:35 +10:00
Dmitry D. Chernov
f99d14558f binary_reader: Parse TL 'date' to UTC datetime instead of local 2017-11-23 02:06:43 +10:00
Vladislav Kolesnichenko
ee5915e86d Add support for connecting through IPv6 (#425 for #112) 2017-11-16 13:30:18 +01:00
Lonami Exo
81baced12b Support t.me/ links when resolving usernames/joinchat links
Closes #419
2017-11-10 13:27:51 +01:00
Lonami Exo
cad1e883a6 Don't save full entities unless they have access_hash 2017-11-10 09:32:40 +01:00
Lonami Exo
f65322af18 Fix entity database not using the phone on {phone: id}
Closes #412
2017-11-07 10:15:55 +01:00
Lonami Exo
05f7f076d5 Fix InputPeer* with None hash, drop them off database (closes #354) 2017-10-30 10:33:45 +01:00
Lonami Exo
05626c8274 Implement missing .to_dict() and .stringify() on message/container 2017-10-29 20:13:36 +01:00
Lonami Exo
3db13ccdd2 Add a more descriptive error when serializing bytes 2017-10-25 12:43:57 +02:00
Andrey Egorov
8057cea294 Fix resending requests on bad salt/msg notification (#369)
These responses from the server could indicate container IDs,
which weren't being saved. This fix also accounts for that case.
2017-10-22 13:13:49 +02:00
Lonami Exo
5de8350d85 Reorder another import for #357 2017-10-22 11:23:15 +02:00
Lonami Exo
6759beac21 Add __str__ methods to TLMessage and MessageContainer 2017-10-21 20:23:53 +02:00