Commit Graph

40 Commits

Author SHA1 Message Date
Lonami Exo
e3c56b0d98 Reduce autocast overhead as much as possible
Rationale: if the user is doing things right, the penalty for
being friendly (i.e. autocasting to the right version, like
User -> InputPeerUser), should be as little as possible.

Removing the redundant type() call to access .SUBCLASS_OF_ID
and assuming the user provided a TLObject (through excepting
whenever the attribute is not available) is x2 and x4 times
faster respectively.

Of course, this is a micro-optimization, but I still consider
it's good to benefit users doing things right or avoiding
redundant calls.
2018-01-19 13:00:17 +01:00
Lonami Exo
49f204c955 Fix .get_input_media using None caption and missing venue type 2018-01-16 14:04:12 +01:00
Lonami Exo
36e2101910 Allow sending multiple files as album (closes #455) 2018-01-15 18:15:30 +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
7ed3be8e6f Fix .get_dialogs() failing due to IDs being marked
Also removed utils.find_user_or_chat to prevent this from
happening again. Using a dict {marked_id: entity} is better.
2017-12-28 13:21:35 +01:00
Lonami Exo
52a4ef82f4 Merge branch 'master' of github.com:LonamiWebs/Telethon 2017-12-28 01:17:30 +01:00
Dmitry D. Chernov
6ec6967ff9 Make exception types correspond to Python docs 2017-12-28 09:48:02 +10: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
238198db5a Create a convenient class to wrap Dialog instances 2017-12-24 16:18:09 +01:00
Lonami Exo
f3e2887452 Add missing ChannelFull case to .get_peer_id() 2017-11-12 18:15:32 +01:00
Lonami Exo
08abef78d6 Add missing InputUserSelf case to .get_input_peer() 2017-11-12 18:05:01 +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
d58c729af0 Add missing InputPeerSelf case to .get_input_user 2017-10-24 09:43:59 +02:00
Lonami Exo
4fd9d361f0 Replace redundant isinstance calls with a tuple parameter 2017-10-13 11:39:34 +02:00
Lonami Exo
da51e71def Fix .get_input_entity returning marked IDs (closes #314) 2017-10-09 19:40:39 +02:00
Lonami Exo
e2ac18b7bc Use larger chunks when downloading/uploading files 2017-10-09 13:19:03 +02:00
Lonami Exo
83677fc927 Enhance and use .get_input_photo on the generated code 2017-10-08 13:45:14 +02:00
Lonami Exo
6d877549cb Cleanup utils.get_peer_id 2017-10-06 21:47:10 +02:00
Lonami Exo
79e36c98bd Fix EntityDatabase.get_input_peer not actually working 2017-10-06 21:42:04 +02:00
Lonami Exo
1fb3d0d00c Fix EntityDatabase failing to cache self user 2017-10-05 13:34:11 +02:00
Lonami Exo
a8edacd34a Fix get_peer_id going into infinite recursion for InputPeerSelf 2017-10-05 12:59:44 +02:00
Lonami Exo
16f929b8b6 Fix .get_peer_id not working with full entities 2017-10-05 12:33:24 +02:00
Lonami Exo
a737f33324 Save all found entities to the session file 2017-10-01 13:27:08 +02:00
Lonami Exo
68e7d481f4 Add support to get all dialogs at once 2017-10-01 11:25:12 +02:00
Lonami Exo
afc4bd9cab Rename constructor/subclass_of_id to upper case, keep only static 2017-09-29 13:11:33 +02:00
Lonami Exo
3c7dd25982 Revert "if * is None" check (8bff10d) on get_input_* due to 423efc4 2017-09-29 12:02:26 +02:00
Lonami Exo
1d50bba8bc Add get_input_* methods for Media and such 2017-09-25 13:43:03 +02:00
Lonami Exo
8bff10d956 Fix get_input_* not skipping None entities (#215)
This was an issue when parsing optional parameters, since None
could not be specified, resulting in a strange crash.
2017-08-30 11:12:25 +02:00
Lonami Exo
d5323c5506 Enhance a lot choosing a valid path when downloading files 2017-08-24 17:44:38 +02:00
Lonami Exo
83c346ccc5 Let InputPeerChannel be casted automatically into InputChannel 2017-08-05 09:37:34 +02:00
Lonami Exo
88c4cdfb52 Make get_input_* methods slightly smarter 2017-07-10 16:11:06 +02:00
Lonami Exo
bdee94eaf3 Implement automatic cast to InputUser too (closes #159) 2017-07-10 16:04:10 +02:00
Lonami Exo
95a989be2c Automatically cast Channel to InputChannel (similar to InputPeer) 2017-07-07 09:48:06 +02:00
Lonami Exo
f88efa7f49 Let PeerChat be casted to InputPeerChat automatically 2017-07-04 21:18:35 +02:00
Lonami Exo
e7b0c06ca5 Make .get_input_user faster when the right type is given 2017-06-16 10:01:05 +02:00
feodoran
13199f737e Handle more cases on .get_display_name 2017-06-16 09:11:49 +02:00
Lonami Exo
86d45cc276 Improve .get_input_peer and use it only when creating requests*
This avoids cyclic dependencies, so types requiring an InputPeer
as a parameter will NOT convert faulty types to the right ones.
2017-06-15 17:03:59 +02:00
Lonami Exo
fc915b2284 Fix get_message_history ignoring chats and enhance find_user_or_chat 2017-06-14 14:06:35 +02:00
Lonami Exo
7adb4f09d6 Slightly reorganise the project structure 2017-06-09 16:13:39 +02:00