Commit Graph

283 Commits

Author SHA1 Message Date
Lonami Exo
83f9cafabf Make .get_entity() public 2017-09-11 11:54:32 +02:00
Lonami Exo
188b1c8816 Fix client reconnection not actually working 2017-09-11 11:38:36 +02:00
Lonami Exo
a2fdd4b196 Ignore InvalidChecksumError's 2017-09-11 11:04:19 +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
bce88446ef Fix incorrect condition causing updates to be ignored 2017-09-08 18:43:37 +02:00
Lonami Exo
54ba0661c6 Fix wrong variable name causing .connect() to fail 2017-09-08 18:28:31 +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
25bbb20b0c Use RLocks properly on MtProtoSender (only needed on net IO) 2017-09-07 21:32:46 +02:00
Lonami Exo
16a5ab3070 Add back the periodic PingRequest 2017-09-07 21:23:37 +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
b8e881b6b6 Add basic updates processing to ignore updates with lower .pts 2017-09-07 20:17:40 +02:00
Lonami Exo
d237375208 Allow adding callback methods to UpdateState 2017-09-07 18:58:54 +02:00
Lonami Exo
d4f36162cd Create and use UpdateState to .process() unhandled TLObjects 2017-09-07 18:49:08 +02:00
Lonami Exo
49e884b005 Raise AssertionError if trying to invoke requests from ReadThread 2017-09-07 18:48:41 +02:00
Lonami Exo
06b2834c02 Fix GetContactsRequest using str instead int (layer 70->71) (#234) 2017-09-07 10:45:55 +02:00
Birger Jarl
edf325d580 Fix username regex (#235)
Username max length is 1+31 = 32
2017-09-07 09:41:49 +02:00
xkdnyan
cd40f4a949 Add RPCError for MESSAGE_NOT_MODIFIED (#231) 2017-09-05 17:06:35 +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
a38381665c Support invoking requests from within the ReadThread (fixes #226) 2017-09-04 20:28:41 +02:00
Lonami Exo
fe86b88bef Make .sign_up() return the logged user just like .sign_in() 2017-09-04 18:07:20 +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
Lonami Exo
7f700c3bc1 Remove unused attributes and methods from the base TLObject class 2017-09-04 16:39:16 +02:00
Lonami Exo
dc238df2e0 Update to v0.13 2017-09-04 12:18:45 +02:00
Lonami Exo
6f0bd14c2f Use an Enum for the ConnectionMode and support specifying it 2017-09-04 11:24:10 +02:00
Lonami Exo
62a52679f4 Ensure the state of the requests is clean before invoking them 2017-09-03 13:45:13 +02:00
Lonami Exo
27408b46da Only reconnect from background thread if .disconnect wasn't called 2017-09-03 13:44:52 +02:00
Lonami Exo
626778bd32 Ignore EBADF when closing the socket 2017-09-03 13:44:29 +02:00
Lonami Exo
68cdc9eaf1 Treat OSError.errno == EBADF as a ConnectionResetError 2017-09-03 11:54:26 +02:00
Lonami Exo
f8f389c850 Fix ack requests removing pending requests when they shouldn't 2017-09-03 11:21:42 +02:00
Lonami Exo
db6fd4bdc2 Fix RPC errors being ignored due to modifying the wrong attribute 2017-09-03 11:19:28 +02:00
Lonami Exo
83f3f66113 Fix MtProtoSender never clearing self._pending_receive requests 2017-09-03 10:50:55 +02:00
Lonami Exo
fa34c4bb77 Handle ConnectionResetError on background thread (removed on 9bc1f64) 2017-09-03 10:05:18 +02:00
Lonami Exo
2a5d08b23d Turn socket.timeout error into the more general TimeoutError 2017-09-03 10:01:00 +02:00
Lonami Exo
494b82ea9d Fix check to avoid (dis)connecting if already (dis)connected 2017-09-03 09:59:37 +02:00
Lonami Exo
4de4026bb3 Move the "constant read" thread to the main TelegramClient 2017-09-03 09:56:10 +02:00
Lonami Exo
9bc1f64efe Move update handling to the MtProtoSender, being functional again 2017-09-02 21:46:44 +02:00
Lonami Exo
21eaf8bd72 Allow setting whether the MtProtoSender should use constant_read 2017-09-02 21:27:11 +02:00
Lonami Exo
863d2e8368 Make confirm_received a flag, avoid race conditions, fix bg RPCError
There was a race condition between TelegramBareClient.invoke
receiving part and MtProtoSender._handle_rpc_result actually
reading the result after setting request.confirmed = True.

The .confirmed is now a threading.Event to avoid the sleep(0.1).

RPC errors have been moved inside the request so they're not
raised on a background thread anymore.
2017-09-02 20:41:00 +02:00
Lonami Exo
b908296efa Remove unused TcpClien.read(timeout=...) param, change other accessors 2017-09-02 19:33:42 +02:00
Lonami Exo
36f51e1e3f Remove ability to TcpClient.cancel_read()
This simplifies the process of sending and receiving data,
and makes use of Python's socket.settimeout instead a hand-crafted
version with a sort-of arbitrary self.delay = 0.1 (seconds), which
should improve the speed of the method
2017-09-02 19:14:11 +02:00
Lonami Exo
cc280a129d Remove TcpClient.write/read shared locks
Since they were shared between write and read, and now the read
is done constantly on a separate thread, the read lock would
cause the write method to be locked and not functional at all
2017-09-02 18:49:29 +02:00
Lonami Exo
43b79c3d36 Add a thread to constantly read messages from the network 2017-09-02 18:27:22 +02:00
Lonami Exo
0197271f74 Fix SignUpRequest using an incorrectly named parameter 2017-09-02 16:52:56 +02:00
Lonami Exo
bea1b7f526 Preserve backward compatibility with old .sign_in() code 2017-08-31 10:38:53 +02:00
Lonami
5f636fdf31 Let .sign_in() call .send_code_request() 2017-08-31 10:34:09 +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