Commit Graph

92 Commits

Author SHA1 Message Date
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
Lonami Exo
229cd78df0 Fix markdown's URL regex not acceping newlines 2018-02-27 14:10:02 +01:00
Lonami Exo
6f16aeb553 Add logging calls on the TcpClient 2018-02-26 13:41:07 +01:00
Dmitry Bukhta
0731a1d698 Raise ProxyConnectionError instead looping forever (#621)
We shouldn't try reconnecting when using a proxy if what's
unavailable is the proxy server (and not Telegram servers).
2018-02-20 17:05:02 +01:00
Lonami Exo
83d9d1d78e Fix markdown parser not inverting delimiters dict 2018-02-16 20:30:19 +01:00
Lonami Exo
75d99fbb53 Fix HTML entity parsing failing when needing surrogates 2018-02-15 11:52:46 +01:00
Lonami Exo
2ffe2b71dc Except OSError with errno.WSAEACCES when connecting
"OSError: [WinError 10013] An attempt was made to access a
socket in a way forbidden by its access permissions."
2018-02-03 11:44:05 +01:00
frizzlywitch
3b8365f871 Remove square braces from IPv6 addresses (#561) 2018-01-26 14:38:13 +01:00
Tulir Asokan
5f2f04c6c2 Add HTML parse mode (#554) 2018-01-22 10:06:11 +01:00
Lonami Exo
33e50aaee1 Reuse .on_response/.__str__/.stringify, override iff necessary 2018-01-19 12:12:52 +01:00
Lonami Exo
46b088d44c Also handle ECONNREFUSED on .connect() (report on #392) 2018-01-08 12:26:32 +01:00
Lonami Exo
59a1a6aef2 Stop working with bytes on the markdown parser 2018-01-07 16:19:41 +01:00
Lonami Exo
3eafe18d0b Implement MtProto 2.0 (closes #484, thanks @delivrance!)
Huge shoutout to @delivrance's pyrogram, specially this commit:
pyrogram/pyrogram/commit/42f9a2d6994baaf9ecad590d1ff4d175a8c56454
2018-01-06 01:55:11 +01:00
Lonami Exo
ec4ca5dbfc More consistent with asyncio branch (style/small fixes)
Like passing an extra (invalid) dt parameter when serializing
a datetime, and handling more errors in the TcpClient class.
2018-01-05 18:31:48 +01:00
Dmitry D. Chernov
6ec6967ff9 Make exception types correspond to Python docs 2017-12-28 09:48:02 +10:00
Dmitry D. Chernov
4a2a64ce2f TcpClient: Catch ConnectionError instead of its particular cases
That can be more reliable, especially in the case of using PySocks.
2017-12-23 05:45:23 +10:00
Lonami Exo
992017ddf8 Except ConnectionAbortedError on TcpClient 2017-12-22 11:27:57 +01:00
Lonami Exo
605c103f29 Add unparse markdown method 2017-11-26 17:16:59 +01:00
Lonami Exo
57a70d0d47 Document the extensions/ module 2017-11-26 17:14:28 +01:00
Dmitry D. Chernov
f99d14558f binary_reader: Parse TL 'date' to UTC datetime instead of local 2017-11-23 02:06:43 +10:00
Lonami Exo
9767774147 Fix import in markdown parser not being relative 2017-11-17 15:57:48 +01:00
Lonami Exo
346c5bb303 Add method to md parser to extract text surrounded by entities 2017-11-16 19:13:13 +01:00
Lonami Exo
e5deaf5db8 Fix c4e07cf, md parsing adding unfinished entity at wrong offset 2017-11-16 19:07:53 +01:00
Lonami Exo
4ddbc78699 Ensure IPv6 addresses are surrounded by '[]' (#425) 2017-11-16 13:47:15 +01:00
Lonami
48e96ca15f
Fix ._get_connected failing when .fileno() == 0 ( #427) 2017-11-14 12:01:33 +01:00
Andrey Egorov
84d48ef7bf Safer check to determine whether sockets are connected (#427) 2017-11-12 16:51:32 +01:00
Lonami Exo
c4e07cff57 Fix unfinished markdown delimiters being stripped away 2017-11-10 11:44:27 +01:00
Lonami Exo
cb3f20db65 Clean up markdown parsing since tuples aren't used anymore 2017-11-10 11:41:49 +01:00
Lonami Exo
7d75eebdab Make markdown parser use only Telegram's MessageEntity's 2017-11-10 11:07:36 +01:00
Lonami Exo
83af705cc8 Add more comments to the markdown parser 2017-11-06 11:32:40 +01:00
Lonami Exo
3a2c3a9497 Fix URL regex for markdown was greedy (fix-up) 2017-11-06 11:22:58 +01:00
Lonami Exo
07ece83aba Fix overlapping markdown entities being skipped 2017-11-06 10:37:22 +01:00
Lonami Exo
4f80429215 Work on byte level when parsing markdown
Reasoning: instead encoding every character one by one as we
encounter them to use half their length as the correct offset,
we can simply encode the whole string at once as utf-16le and
work with that directly.
2017-11-06 10:29:32 +01:00
Viktor Oreshkin
49eb281251 Proper offset calculation for markdown (#407)
Dan suca
If Dan shared it with Traitor I'll not have to spend my time on this
Not a, sorry for not letting you sleep
k thx bye
Will this stay in history?
2017-11-06 00:17:22 +01:00
Lonami Exo
82cac4836c Fix markdown URL parsing using character index instead offset 2017-10-30 11:15:53 +01:00