Commit Graph

409 Commits

Author SHA1 Message Date
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
Lonami Exo
a93abed737 Add ISSUE_TEMPLATE for GitHub 2017-09-05 19:16:22 +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
0e45f46ad5 Properly ignore core types when generating code 2017-09-04 16:38:03 +02:00
Lonami Exo
e8cdcf369d Sort generated code by name for more predictable results 2017-09-04 15:11:46 +02:00
Lonami Exo
c5b562d4f6 Move the from tlobject import TLObject to only the top of the file 2017-09-04 14:08:36 +02:00
Lonami Exo
64f1031a45 Move comments from auto-generated code to the generator itself 2017-09-04 14:05:30 +02:00
Lonami Exo
c3f679597c Move the auto-generated notice to only the top of the file 2017-09-04 13:57:40 +02:00
Lonami Exo
e83b250a22 Replace generated directory modules with simply files 2017-09-04 13:51:47 +02:00
Lonami Exo
7eab28206b Change the code generator to use a single file per namespace 2017-09-04 13:44:39 +02:00
Lonami Exo
dc238df2e0 Update to v0.13 2017-09-04 12:18:45 +02:00
Lonami Exo
a5d86b4572 Update to layer 71 2017-09-04 11:54:37 +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
69d182815f Merge branch 'constant_read'
Since the secondary thread for constant read is not part of the
TelegramClient anymore, there is no need to restart it. It will
be ran when connecting again.
2017-09-02 21:51:11 +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
49c5cf745f Fix SignUpRequest using an incorrectly named parameter 2017-09-02 16:54:06 +02:00
Lonami Exo
0197271f74 Fix SignUpRequest using an incorrectly named parameter 2017-09-02 16:52:56 +02:00
alexvelickiy
5f4e79542f Restore updates thread on reconnection and fix restarting it 2017-08-31 18:57:32 +02:00
Lonami Exo
bea1b7f526 Preserve backward compatibility with old .sign_in() code 2017-08-31 10:38:53 +02:00