Commit Graph

97 Commits

Author SHA1 Message Date
Lonami Exo
b6bc9ac39b Rename ._connect_lock to ._reconnect_lock 2017-09-30 18:25:09 +02:00
Lonami Exo
4cd7e1711e Rename cdn parameter to _cdn 2017-09-30 17:57:39 +02:00
Lonami Exo
d28f370ab6 Add ._get_cdn_client as alternative ._get_exported_client version 2017-09-30 17:51:07 +02:00
Lonami Exo
a35c4b15db Cache exported Sessions instead whole clients 2017-09-30 16:32:10 +02:00
Lonami Exo
c1c6df9fd0 Fix invoke not raising ValueError when retries reach 0 2017-09-30 16:18:16 +02:00
Lonami Exo
8ecd2c2e06 Call .sync_updates on .connect iff exported_auth is None
Calling this method on exported clients would trigger a
UserMigrateError because it was being used on a non-native
data center. For .connects like this, don't attempt syncing
updates.
2017-09-30 16:11:16 +02:00
Lonami Exo
18e485ded2 Set default TelegramBareClient behaviour to not spawn ReadThread 2017-09-30 15:53:47 +02:00
Lonami Exo
0a567fcd7c Make creating a new sender cleaner 2017-09-30 12:08:06 +02:00
Lonami Exo
003e231239 Attempt at cleaning up TelegramBareClient.invoke() 2017-09-30 11:45:35 +02:00
Lonami Exo
61033b2f56 Allow disabling spawning a second thread 2017-09-30 11:28:15 +02:00
Lonami Exo
7cef5885fa Rename process_updates/polling to workers 2017-09-30 11:17:31 +02:00
Lonami Exo
9560bcc324 Remove "if background thread" check as it isn't exposed anymore 2017-09-30 10:27:46 +02:00
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
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
61e5c73658 Update to v0.14.2 2017-09-29 13:13:05 +02:00
Lonami Exo
dc5bbc1719 Update to v0.14.1 2017-09-28 12:02:47 +02:00
Lonami Exo
b0839a028e Update to v0.14 2017-09-27 13:51:59 +02:00
Lonami Exo
f233110732 Allow sending several requests at once through new MessageContainer 2017-09-25 20:52:27 +02:00
Lonami Exo
0f10e1419f Update to v0.13.6 2017-09-23 11:44:04 +02:00
Lonami Exo
f39f9c33a0 Fix timeout on confirm_received.wait not being added (fix #257) 2017-09-22 19:20:37 +02:00
Lonami Exo
9ce4307304 Update to v0.13.5 2017-09-22 16:12:43 +02:00
Lonami Exo
b0f6b23e52 Fix creating new connections accessing invalid attributes 2017-09-22 16:11:07 +02:00
Lonami Exo
d8bf8bb2eb Fix reconnect always returning False -> infinite loop 2017-09-22 12:48:04 +02:00
Lonami Exo
4d5f16f2aa Fix background thread could not reconnect properly 2017-09-22 12:44:09 +02:00
Lonami Exo
4245ec5abc Make reconnect private 2017-09-22 12:31:41 +02:00
Lonami Exo
bc15b451b5 Use a safer reconnect behaviour (respect multithread too) 2017-09-22 12:20:38 +02:00
Lonami Exo
4ba12e717f Fix reconnect to new_dc wasn't changing connection.ip 2017-09-21 13:58:57 +02:00
Lonami Exo
2b2da843a1 Create a Connection only once and avoid no-op if was "connected" 2017-09-21 13:44:22 +02:00
Lonami Exo
e12e82357d Update to v0.13.4 2017-09-18 13:32:16 +02:00
Lonami Exo
e7a936222f Catch -404 BrokenAuthKeyError on .connect()'s .do_authentication 2017-09-17 18:38:03 +02:00
Lonami Exo
58fe39f060 Expose MtProtoSender.is_connected() and use it on .connect() 2017-09-17 16:39:29 +02:00
Lonami Exo
76b7420b63 Ignore TimeoutError when invoking a request 2017-09-17 16:32:51 +02:00
Lonami Exo
2f0f6d4591 Remove initial_query leftovers 2017-09-17 16:20:04 +02:00
Lonami Exo
aea10b103b Rename generated layer variable to uppercase readonly property 2017-09-17 16:17:55 +02:00
Lonami Exo
c84e54b647 Get rid of the initial_query= parameter on .connect() 2017-09-17 16:06:43 +02:00
Lonami Exo
2689b0750d Make DC options static
Some datacenters don't allow calling GetConfigRequest,
this way it can both be reused and such calls omitted.
2017-09-17 15:19:21 +02:00
Lonami Exo
59a4315c28 Avoid calling InitConnectionRequest when it's not needed 2017-09-17 14:26:25 +02:00
Lonami Exo
29471f3bba Force obfuscated2 mode if api_id < 20 2017-09-15 11:49:39 +02:00
Lonami Exo
279eb110be Update to v0.13.3 2017-09-14 11:51:41 +02:00
Lonami Exo
1d36bbfbf4 Remove forgotten invalid code CdnDecrypter.finish_check (fix #243) 2017-09-12 15:38:00 +02:00
Lonami Exo
48dead76ac Retry up to five times before giving up on a request 2017-09-11 10:52:36 +02:00
Lonami Exo
fa4042a80e Update to v0.13.2 2017-09-08 13:22:05 +02:00
Lonami Exo
c81537bed0 Simplify the workflow with UpdateState exposing a single flag param 2017-09-08 12:54:38 +02:00
Lonami Exo
a24b4020fe Allow adding update handlers without the need to poll updates 2017-09-07 20:29:51 +02:00
Lonami Exo
d4f36162cd Create and use UpdateState to .process() unhandled TLObjects 2017-09-07 18:49:08 +02:00
Lonami Exo
49555ad018 Stick to the offset and limit CdnFileHashes dictates (#222)
The old intersection method and allowing an arbitrary part size
wasn't working properly. Assuming that Telegram will send a sha
sum for the whole file, in the correct order, we can simply use
their offsets to download the file.
2017-09-05 16:43:53 +02:00
Lonami Exo
2924912931 Fix CDN downloads not always calling GetCdnConfigRequest (#222)
On previous tests, Telegram didn't return information about CDNs
on the initial GetConfigRequest. However, it may do so, and it's
necessary to call GetCdnConfigRequest even when a second call to
GetConfigRequest isn't required.
2017-09-05 16:11:02 +02:00
Lonami Exo
d5cd59de8a Update to v0.13.1 2017-09-04 20:34:05 +02:00
Lonami Exo
15fd5390ae Optimize imports 2017-09-04 17:18:33 +02:00
Lonami Exo
97cab7347b Make lint happier 2017-09-04 17:10:04 +02:00