Commit Graph

126 Commits

Author SHA1 Message Date
painor
38b929b973 Fix several typos (#1328) 2019-11-10 11:29:43 +01:00
Lonami Exo
c0e4d6c8b6 Slightly simplify BinaryReader
There was no need for the BufferedReader, since everything
is already in memory. Further, the stream parameter was never
used, so it was also unnecessary. The check for None when
reading length was also unnecessary, since we could just pass
-1 to begin with.
2019-08-07 10:33:46 +02:00
Lonami Exo
b719a2a432 Remove unwanted html.unescape() call 2019-08-04 10:09:23 +02:00
binares
2b277dd558 Fix (de)serialization of negative timestamps (#1241) 2019-08-01 18:47:38 +02:00
Lonami Exo
05b770a93f Fix directly nested markdown entities 2019-07-06 12:55:44 +02:00
Lonami Exo
2d0fc8356f Fix markdown parsing for pre blocks and entity after entity 2019-07-05 20:31:43 +02:00
Lonami Exo
4e80e21ba1 Update markdown parser to support nested entities 2019-06-24 13:48:29 +02:00
Tulir Asokan
8b28f4ffbf Add support for unparsing nested entities into HTML (#1209) 2019-06-24 12:28:14 +02:00
Lonami Exo
962949008f Add new message entities to markdown/html parsers 2019-06-23 21:35:33 +02:00
Lonami Exo
baa8970bb6 Fix handling message payloads that are too large 2019-03-06 18:08:51 +01:00
Tulir Asokan
f271316d7d Make logger fully configurable (#1087) 2019-01-11 15:52:30 +01:00
Lonami Exo
229969192a Fix UnicodeDecodeError with malformed input on unparse text 2019-01-01 20:31:39 +01:00
Lonami Exo
aaee092a46 Locally strip outgoing message text respecting entities 2018-11-19 10:15:56 +01:00
Lonami Exo
d854babf22 Make HTML parser yield the correct offset and lengths 2018-11-19 09:20:13 +01:00
Lonami Exo
207d5ebdcb Avoid packing more than 1024 messages in a single container 2018-11-19 08:29:44 +01:00
Lonami Exo
7dece209a0 Cancel tasks on reconnect instead of awaiting them
This prevents us from locking forever on any task that doesn't
rely on cancellation tokens, in this case, Connection.recv()'s
_recv_queue.get() would never complete after the server closed
the connection.

Additionally, working with cancellation tokens in asyncio is
somewhat annoying to do.

Last but not least removing the Connection._disconnected future
avoids the need to use its state (if an exception was set it
should be retrieved) to prevent asyncio from complaining, which
it was before.
2018-10-21 16:20:05 +02:00
Lonami Exo
0686ec4440 Implement after_msg_id back 2018-10-19 16:53:50 +02:00
Lonami Exo
9dc4009152 Handle the right errors 2018-10-19 14:41:50 +02:00
Lonami Exo
e2fe3eb503 Use new broken MessagePacker 2018-10-19 13:24:52 +02:00
Lonami Exo
0cc8bca098 Delete TcpClient 2018-10-05 13:26:44 +02:00
painor
340f5614b5 Add name mention formatting to HTML and Markdown (#1019) 2018-10-04 15:56:32 +02:00
Lonami Exo
92c9bb12b7 Use asyncio.open_connection in the TcpClient
(cherry picked from commit 573fed1f512831cd9790130cc878655fef2fde98)
2018-09-19 19:03:36 +02:00
Lonami Exo
a688c8a4ce Fix exception ignored warnings and invalid state #935 2018-08-04 15:06:11 +02:00
Lonami Exo
200a4e47b8 Clarify some strings 2018-07-25 02:21:44 +02:00
Lonami Exo
aa67f107af Temporarily use blocking SSL sockets on connect 2018-07-19 20:56:45 +02:00
Lonami Exo
4027ac6a6f Wrap socket with SSL after connecting
See https://github.com/Anorov/PySocks/issues/29
2018-07-19 20:38:53 +02:00
Lonami Exo
38c65adf35 Set timezone info when reading datetimes 2018-07-12 00:30:57 +02:00
Lonami
128053750d
Implement HTTP(S) mode (closes #112) (#883) 2018-07-08 17:45:49 +02:00
Lonami Exo
53c660d0dc Don't remove reader if fd == -1 2018-06-30 13:26:28 +02:00
Lonami Exo
d64eb7ea2b Avoid cyclic imports on older Python versions 2018-06-29 11:04:42 +02:00
Lonami Exo
c8ee0bdca9 Fix socket may be None when closing twice 2018-06-20 17:59:11 +02:00
Lonami Exo
4e9a84c3b5 Remove underscore from module names 2018-06-18 21:02:42 +02:00
Lonami Exo
145d4b7105 Remove socket fd from the loop reader upon closing 2018-06-17 15:48:26 +02:00
Lonami Exo
226c35ff8f Pump up default timeout from 5 to 10s 2018-06-17 11:46:56 +02:00
Lonami Exo
0f14f3b16a Support custom event loops 2018-06-14 19:35:12 +02:00
Lonami Exo
df1dfdf8ea Remove some redundant except 2018-06-14 16:13:46 +02:00
Lonami Exo
c9ea1bafc0 Apply @andr-04 asyncio commits to TcpClient 2018-06-14 16:08:23 +02:00
Lonami Exo
64dd957189 Fix None first_query and TcpClient.disconnect() 2018-06-11 19:51:01 +02:00
Lonami Exo
7e68274f26 Keep consistent structure and remove done TODO 2018-06-09 15:42:10 +02:00
Lonami Exo
be279ce3f5 Make TLMessage always have a valid TLObject
This simplifies the flow instead of having separate request/body
attributes, and also means that BinaryReader.tgread_object() can
be used without so many special cases.
2018-06-09 13:48:27 +02:00
Lonami Exo
f7e8907c6f Create RpcResult class and generalise core special cases
This results in a cleaner MTProtoSender, which now can always
read a TLObject with a guaranteed item, if the message is OK.
2018-06-09 13:13:55 +02:00
Lonami Exo
9477c75fce Fix basic requests sending and receiving 2018-06-06 21:42:48 +02:00
Lonami Exo
e469258ab9 Create a new MTProtoSender structure and its foundation
This means that the TcpClient and the Connection (currently only
ConnectionTcpFull) will no longer be concerned about handling
errors, but the MTProtoSender will.

The foundation of the library will now be based on asyncio.
2018-06-06 20:41:01 +02:00
Lonami Exo
2fb5215f5f Fix parsers misbehaving with None text 2018-06-03 13:48:43 +02:00
Lonami Exo
8d7c7a19c0 Add some setters for custom.Message 2018-06-03 11:53:18 +02:00
Lonami Exo
e2a0de1913 Don't retry forever on TcpClient.connect() 2018-04-25 10:06:11 +02:00
Lonami Exo
eabaa3854a Replace offset with match.start() to allow custom regex 2018-04-03 13:47:40 +02:00
Lonami Exo
33e908de42 Fix markdown regex not supporting [] inside URLs 2018-03-22 19:02:08 +01:00
Lonami Exo
987cf41ec6 Higher timeout and log them as warning if any data was received
This might be the cause for  "number of retries reached 0" so
more specific logging calls might be useful. If while reading
a response it times out but  some data had already been read,
said data will be lost.

The sequence of events that triggered reaching 0 retries was:
- Sending requests with IDs XYZ
- socket.timeout while reading
- Items timed out. Retrying
- Processing RPC result
- Received response for XYZ
- Lost request with ID XYZ
2018-03-18 20:08:00 +01:00
Lonami Exo
a7f98fd3cc Ignore bad file descriptor while closing 2018-03-02 17:26:42 +01:00