Commit Graph

106 Commits

Author SHA1 Message Date
Lonami Exo
c61e168de4 Rename invoke to __call__ 2017-10-01 16:04:14 +02:00
Lonami Exo
36dabc4928 Process entities from the MtProtoSender instead TelegramBareClient
This way, update objects will also be processed when they occur.
2017-10-01 16:02:29 +02:00
Lonami Exo
a737f33324 Save all found entities to the session file 2017-10-01 13:27:08 +02:00
Lonami Exo
1d159908c7 Fix RPC excepts (e.g. UserMigrate) being in the wrong try 2017-10-01 11:25:56 +02:00
Lonami Exo
a5ab49c707 Remove sleep on ServerError as per @danog's recommendation 2017-09-30 19:02:12 +02:00
Lonami Exo
c9dff552b8 Except ServerErrors and sleep a bit before retrying 2017-09-30 18:51:25 +02:00
Lonami Exo
76e5206acc Raise ValueError if an unknown **kwarg is given 2017-09-30 18:45:56 +02:00
Lonami Exo
8c3c990e74 Remove UpdateState .set and .check error 2017-09-30 18:39:31 +02:00
Lonami Exo
933ae01d85 Change condition to perform automatic reconnection 2017-09-30 18:33:34 +02:00
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