Commit Graph

798 Commits

Author SHA1 Message Date
Lonami Exo
479afddf50 Move core functionality to the TelegramBareClient
Rationale: the intended behaviour of the TelegramClient will now
be to focus on abstracting the users from manually importing
requests and types to work with Telegram's API. Thus, all the
core functionality has been moved to the TelegramBareClient,
which will now be responsible of spawning new threads or
connections and even handling updates.

This way there is a clear distinction between the two clients,
TelegramClient is the one meant to be exposed to the end user,
since it provides all the mentioned abstractions, while the
TelegramBareClient is the "basic" client needed to work with
the API in a comfortable way.

There is still a need for an MtProtoSender, which still even
lower level, and knows as little as possible of what requests
are. This handles parsing the messages received from the
server so that their result can be understood.
2017-09-30 10:27:46 +02:00
Lonami Exo
b61deb5cfb Delete methods to create_new_connection and invoke_on_dc 2017-09-30 10:27:46 +02:00
Lonami Exo
0a693c705a Create a new connection when called from a different thread
This allows to invoke several requests in parallel while not
waiting for other requests to be written to the network.
2017-09-30 10:27:46 +02:00
Lonami Exo
ee08232473 Fix UpdateState.check_error popping the wrong side 2017-09-30 10:27:16 +02:00
Lonami Exo
6df38da793 Fix session failing to load if no auth_key present 2017-09-29 19:54:40 +02:00
Lonami Exo
56103845de Fix LogOutRequest consuming all retries (#270) 2017-09-29 13:58:15 +02:00
Lonami Exo
61e5c73658 Update to v0.14.2 2017-09-29 13:13:05 +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
b3f04fd359 Raise AssertionError instead TypeNotFoundError on authenticator 2017-09-29 13:07:21 +02:00
Lonami Exo
a4fa652d35 Precompute the flag index on the generated code 2017-09-29 13:03:35 +02:00
Lonami Exo
76d14b2dd9 Make generated .to_bytes() more readable 2017-09-29 13:00:22 +02:00
Lonami Exo
195bba6f21 Fix bug where booleans were always serialized as false 2017-09-29 12:57:53 +02:00
Lonami Exo
c134d9ba27 Run setup.py gen_tl when installing (may fix #271) 2017-09-29 12:40:03 +02:00
Lonami Exo
7838f8561b Allow running setup.py from other directories 2017-09-29 12:38:53 +02:00
Lonami Exo
f39d8f132f Make generated description on the docs more friendly 2017-09-29 12:14:09 +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
423efc4360 Fix optional vector arguments failing 2017-09-29 11:56:43 +02:00
Lonami Exo
3fda7efeb9 More friendly issue template 2017-09-28 12:20:56 +02:00
Lonami Exo
dc5bbc1719 Update to v0.14.1 2017-09-28 12:02:47 +02:00
Lonami Exo
cc337328c6 Rename handmade Message class to TLMessage to avoid confusion 2017-09-28 11:59:24 +02:00
Lonami Exo
71c2a82b3d Completely remove BinaryWriter from the project 2017-09-28 11:49:45 +02:00
Lonami Exo
2fd03e5422 Stop using BinaryWriter on MtProtoPlainSender 2017-09-28 11:43:06 +02:00
Lonami Exo
fe30f63d5d Use autogen code on the authenticator instead hardcoding requests 2017-09-28 11:36:51 +02:00
Lonami Exo
4bedbfe945 Use bytes instead string type on the auth-key methods 2017-09-28 10:32:57 +02:00
Lonami Exo
14791e1df1 Fix wrong type hint for int128 and int256 2017-09-28 10:12:39 +02:00
Lonami Exo
748c2560de Fix auto-generated code didn't actually write int128/int256 2017-09-28 10:12:15 +02:00
Lonami Exo
fb0898b9cb Don't distinguish between str and bytes when serializing
This makes it easier to use some requests like ReqPqRequest which
needs a string of bytes, not a valid utf-8 string per se.
2017-09-28 09:55:29 +02:00
Lonami Exo
1518be0b95 Use .appendleft(x) for deque instead .insert(0, x) (fix #268) 2017-09-28 09:30:47 +02:00
Lonami Exo
c667a00281 Avoid using BinaryWriter where possible 2017-09-27 21:23:59 +02:00
Lonami Exo
8a605f21e6 Remove BinaryWriter dependency on MessageContainer 2017-09-27 21:06:01 +02:00
Lonami Exo
833aeb86eb Fix auth_key is unsigned 2017-09-27 21:04:52 +02:00
Lonami Exo
bd3dd371a2 Create a proper Message class (msg_id, seqno, body; only .to_bytes()) 2017-09-27 21:01:20 +02:00
Lonami Exo
b0839a028e Update to v0.14 2017-09-27 13:51:59 +02:00
Lonami Exo
795cb98909 Move MessageContainer.on_send inside its .to_bytes 2017-09-27 13:49:58 +02:00
Lonami Exo
6df9fc558e Create and use a new GzipPacked class, also when sending 2017-09-27 13:46:53 +02:00
Lonami Exo
7b736aa6ef Fix MessageContainer having the wrong constructor id 2017-09-27 13:46:02 +02:00
Lonami Exo
efca981312 Fix adding a request twice (or container) to ._pending_receive 2017-09-27 13:26:35 +02:00
Lonami Exo
0c11967232 Remove unused .shaes attribute from CdnDecrypter 2017-09-27 12:11:16 +02:00
Lonami Exo
657e8a70c9 Fix CdnDecrypter incorrectly accessing clients' timeout (closes #265) 2017-09-27 12:08:37 +02:00
Lonami Exo
9b7733d6b9 Avoid the use of starred expressions on autogen code (fix #266) 2017-09-27 12:05:35 +02:00
Lonami Exo
98c2e1dd4f Replace 4 .append calls with a single one when serializing bytes 2017-09-26 14:41:11 +02:00
Lonami Exo
b83cd98ba0 Replace TLObject.on_send with the new .to_bytes()
This also replaces some int.to_bytes() calls with a faster
struct.pack (up to x4 faster). This approach is also around
x3 faster than creating a BinaryWriter just to serialize a
TLObject as bytes.
2017-09-26 14:36:02 +02:00
Lonami Exo
2bb26d6389 Modify setup.py to work even if generated code was wrong 2017-09-26 14:29:35 +02:00
Lonami Exo
f233110732 Allow sending several requests at once through new MessageContainer 2017-09-25 20:52:27 +02:00
Lonami Exo
b40708a8c7 Import get_input_* only once on the generated code 2017-09-25 14:05:13 +02:00
Lonami Exo
dc73744fc4 Add get_input_media calls on the generated code 2017-09-25 13:47:25 +02:00
Lonami Exo
1d50bba8bc Add get_input_* methods for Media and such 2017-09-25 13:43:03 +02:00
Lonami Exo
edcd23f94c Making timeout when reporting an error shorter 2017-09-25 12:00:09 +02:00
Lonami Exo
493f5cec1f Fix-up target method typo 2017-09-25 11:57:42 +02:00
Lonami Exo
01c91bb895 Report errors in the background not to interfer with users (#262) 2017-09-25 11:56:44 +02:00