Commit Graph

623 Commits

Author SHA1 Message Date
Lonami Exo
6662f49bcb Remove another redundant if 2017-11-30 21:10:02 +01:00
Lonami Exo
21a93d58ec Use a synchronized queue instead event/deque pair 2017-11-30 21:09:34 +01:00
Lonami Exo
7d7b2cb1fa Remove redundant checks from UpdateState 2017-11-30 20:40:35 +01:00
Lonami Exo
9046b46fcd Document the network/ module 2017-11-30 13:21:01 +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
Lonami Exo
71eb542626 Document the errors/ module 2017-11-26 17:06:09 +01:00
Lonami Exo
a932fb6470 Document the crypto/ module 2017-11-26 16:57:40 +01:00
Lonami Exo
74ec6391d9 Fix-up security assertion (b42b4bb for #453) 2017-11-24 19:05:52 +01:00
Maxim Smirnov
b42b4bb326 Add OpenSSL assertion on authenticator.py (#453)
aes_ige.c(88): OpenSSL internal error, assertion failed
2017-11-24 18:47:36 +01:00
Dmitry D. Chernov
5a4d6d4a57 tlobject: Represent timestamp as 'int' instead of 'float' 2017-11-23 22:39:35 +10: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
152856dfbc Add a force_fetch parameter to .get_entity 2017-11-20 10:58:11 +01:00
Lonami Exo
9767774147 Fix import in markdown parser not being relative 2017-11-17 15:57:48 +01:00
Lonami Exo
01f55200f2 Update to v0.15.5 2017-11-16 19:18:26 +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 Exo
edd73ed69a Allow switching from IPv4 to IPv6 and vice versa 2017-11-16 13:40:25 +01:00
Vladislav Kolesnichenko
ee5915e86d Add support for connecting through IPv6 (#425 for #112) 2017-11-16 13:30:18 +01:00
Lonami Exo
959e824c1c Reduce indent level to simplify flow on __call__ 2017-11-16 13:26:49 +01:00
Lonami Exo
778c844a64 Use logger.exception instead logger.error on ReadThread 2017-11-16 13:25:13 +01:00
Lonami Exo
b346561f89 Remove unnecessary call to .get_input_entity() 2017-11-16 13:24:32 +01:00
Lonami
48e96ca15f
Fix ._get_connected failing when .fileno() == 0 ( #427) 2017-11-14 12:01:33 +01:00
Lonami Exo
bfc408b00a Use NullHandler as default for the library 2017-11-13 10:59:43 +01:00
Lonami Exo
4ac88a1505 Use ._logger.exception when .connect fails (#373) 2017-11-13 10:58:10 +01:00
Lonami Exo
07cb001854 Attempt at cleaning up reconnection logic 2017-11-13 10:31:32 +01:00
Lonami Exo
f3e2887452 Add missing ChannelFull case to .get_peer_id() 2017-11-12 18:15:32 +01:00
Lonami Exo
08abef78d6 Add missing InputUserSelf case to .get_input_peer() 2017-11-12 18:05:01 +01:00
Andrey Egorov
84d48ef7bf Safer check to determine whether sockets are connected (#427) 2017-11-12 16:51:32 +01:00
Lonami Exo
99512875a2 Reconnect if invoking failed (#270) 2017-11-12 16:25:56 +01:00
Lonami Exo
5a57a8a498 Fix message history failing if sender fwd from channel
Closes #424
2017-11-11 19:35:57 +01:00
Lonami Exo
81baced12b Support t.me/ links when resolving usernames/joinchat links
Closes #419
2017-11-10 13:27:51 +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
cad1e883a6 Don't save full entities unless they have access_hash 2017-11-10 09:32:40 +01:00
Lonami Exo
f65322af18 Fix entity database not using the phone on {phone: id}
Closes #412
2017-11-07 10:15:55 +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
f381b26790 Add optional force_sms parameter to .send_code_request() 2017-11-04 20:46:02 +01:00
Lonami Exo
c8a0953f8e Update to v0.15.4 2017-11-04 13:40:56 +01:00
Lonami Exo
1741608f28 Use larger batches for .get_dialogs(limit=None) 2017-11-04 12:35:12 +01:00
Dan
0bfd8ff032 Add much faster integer factorization (#403 related to #199) 2017-11-03 12:59:17 +01:00
Lonami Exo
9a12738f0e Fix .get_message_history not working with limit=0 2017-10-31 13:52:43 +01:00
Lonami Exo
3d6c8915e3 Allow >100 limits when getting message history (implements #290) 2017-10-31 12:52:07 +01:00
Lonami
6c2363acd2
Merge pull request #396 from LonamiWebs/md-parsing
Support markdown again (implements  #118)
2017-10-30 11:19:48 +01:00
Lonami Exo
7e204632e2 Add parse_mode parameter to TelegramClient.send_message() 2017-10-30 11:17:22 +01:00
Lonami Exo
82cac4836c Fix markdown URL parsing using character index instead offset 2017-10-30 11:15:53 +01:00
Lonami Exo
0a14aa1bc6 Remove additional check when calculating emojies length
This special check treated some emojies as 3 characters long but
this shouldn't have actually been done, likely due to the old
regex matching more things as emoji than it should (which would
have count as 2 too, making up for 1+3 from the new is_emoji()).
2017-10-30 10:56:39 +01:00
Lonami Exo
05f7f076d5 Fix InputPeer* with None hash, drop them off database (closes #354) 2017-10-30 10:33:45 +01:00
Lonami Exo
05626c8274 Implement missing .to_dict() and .stringify() on message/container 2017-10-29 20:13:36 +01:00
Lonami Exo
6567f4b567 Clean .download_contact and a wrong indent level 2017-10-29 20:13:36 +01:00
Lonami Exo
2609bd9bd1 Use constants and allow empty URL regex when parsing markdown 2017-10-29 18:21:21 +01:00
Lonami Exo
d47a9f83d0 Fix some special cases which are not treated as emojis (offset 1) 2017-10-29 17:07:37 +01:00
Lonami Exo
bcaa8007a3 Fix inline URL matching swallowing all parse entities 2017-10-29 16:43:30 +01:00
Lonami Exo
f5fafc6a27 Enhance emoji detection 2017-10-29 16:41:30 +01:00
Lonami Exo
368269cb11 Add ability to parse inline URLs 2017-10-29 16:33:10 +01:00
Lonami Exo
9600a9ea0b Fix markdown parsing failing if delimiter was last character 2017-10-28 19:17:18 +02:00
Lonami Exo
5adec2e1ab Initial attempt at parsing Markdown-like syntax 2017-10-28 19:06:41 +02:00
Andrei Fokau
ef794bf75d Fix importing dependencies during installing (#384) 2017-10-28 12:21:07 +02:00
Lonami Exo
e48f15be80 Fix-up af08d59 (missing parenthesis) 2017-10-28 11:11:51 +02:00
Tanuj
af08d59cb7 Fix bug with semicolons when downloading contacts (#319) 2017-10-28 11:09:46 +02:00
Lonami Exo
c6d30ffceb Fix exception when logging exceptions 2017-10-25 13:06:51 +02:00
Lonami Exo
3db13ccdd2 Add a more descriptive error when serializing bytes 2017-10-25 12:43:57 +02:00
Lonami Exo
ceb37cd4c5 Move auth_key generation and InitConnection logic to .invoke()
The reasoning behind this is that .connect() should not call
any request at all, it should only connect to the servers
although it currently still calls GetStateRequest.

There were some issues (#291, #360) where the auth_key was None
(possibly due to .connect() returning False), so this may
fix some of the cases where it returned False. This way we also
ensure that we always have an auth_key, or even if it "breaks"
(it's not the right key for the server anymore).

A few additional changes have been introduced to accommodate
this, such as moving InitConnection logic too or importing auths.
2017-10-24 15:40:51 +02:00
Lonami Exo
d58c729af0 Add missing InputPeerSelf case to .get_input_user 2017-10-24 09:43:59 +02:00
Lonami Exo
b04eed82eb Add new .idle() method to listen for updates from MainThread 2017-10-22 13:16:34 +02:00
Andrey Egorov
8057cea294 Fix resending requests on bad salt/msg notification (#369)
These responses from the server could indicate container IDs,
which weren't being saved. This fix also accounts for that case.
2017-10-22 13:13:49 +02:00
Lonami Exo
5de8350d85 Reorder another import for #357 2017-10-22 11:23:15 +02:00
Lonami Exo
6759beac21 Add __str__ methods to TLMessage and MessageContainer 2017-10-21 20:23:53 +02:00
Lonami Exo
d7f917ebfc Update docstrings 2017-10-21 16:59:20 +02:00
Lonami Exo
7596f2b797 Fix and enhance "no workers set" warning 2017-10-21 13:48:57 +02:00
Lonami Exo
5cdf92e509 Update to v0.15.3 2017-10-20 23:33:08 +02:00
Lonami Exo
d70811b693 Fix infinite loop when invoking on update handlers (fix #336)
Every update that hadn't been acknowledged on the main connection
yet would be resent on any new connection. These new connections
are made temporary when invoking anything from any thread that's
not the main thread. It would also process all the updates, hence,
Telegram would be resending these not-acknowledged updates to the
temporary connection, and the updates would be processed again,
then the update handler would react to the duplicated updates over
and over.

To fix this, simply don't process updates on the temporary thread
at all. With this reasoning, if we don't acknowledge updates on
the temporary connections, Telegram will resend them on the main
connection, so we should not lose any.
2017-10-20 23:30:02 +02:00
Lonami Exo
2782a08ed0 Add note for future self when handling gzip packed data 2017-10-20 22:44:00 +02:00
Lonami Exo
1a91c024fc Revert 63dfb1e as many updates were being dropped 2017-10-20 22:12:03 +02:00
Lonami Exo
033119e9b8 Make MtProtoSender._need_confirmation a set
This will avoid adding duplicated items to it
2017-10-20 22:07:45 +02:00
Lonami Exo
38ccd6d1d9 Generate errors from PWRTelegram's API 2017-10-20 17:20:05 +02:00
Andrey Egorov
f37b9ed20e Fix new salt not being saved to session file (#362) 2017-10-20 16:48:54 +02:00
Andrey Egorov
050cd95d32 Remove unnecessary .disconnect() from ._invoke() (#356) 2017-10-19 10:51:34 +02:00
Andrey Egorov
e349910eb9 Fix attribute access order being swapped (#353) 2017-10-18 15:34:04 +02:00
Andrey Egorov
16cf94c9ad Fix ._clear_all_pending failing due to a wrong call (#352) 2017-10-18 14:47:03 +02:00
Lonami Exo
87dc476dae Fix ReadThread not starting on reconnect if already authorized 2017-10-18 14:45:08 +02:00
Lonami Exo
5a1074dc7c Avoid calling .sync_updates when not needed 2017-10-18 12:17:13 +02:00
Lonami Exo
adb79b21cf Replace .to_bytes() with the special .__bytes__ function 2017-10-17 19:54:59 +02:00
Lonami Exo
63dfb1e3ea Fix processing messages pending of acknowledge many times 2017-10-17 10:15:13 +02:00
Andrey Egorov
ed77ba6f8f Likely fix .log_out crashing "calling Event" (#349) 2017-10-17 00:39:04 +02:00
Lonami Exo
27728be242 Revert "Attempt at not calling .connect for every file chunk"
This reverts commit 280a700655.
The reason for this is that it was causing a lot of files to
be downloaded corrupted for some reason. This should be
revisited to avoid creating a new connection for every chunk.
2017-10-15 11:05:56 +02:00
Lonami Exo
d92e8e11ad Update to v0.15.2 2017-10-14 12:05:28 +02:00
Lonami Exo
280a700655 Attempt at not calling .connect for every file chunk 2017-10-14 12:03:01 +02:00
Nikolay
9907d763a8 Use peer as key instead top_message on .get_dialogs (fix #329) 2017-10-14 11:50:48 +02:00
Lonami Exo
f4b8772a85 Temporary fix for abusive duplicated updates (closes #336) 2017-10-14 11:37:47 +02:00
Lonami Exo
4fd9d361f0 Replace redundant isinstance calls with a tuple parameter 2017-10-13 11:39:34 +02:00
88ee55
db63b5e39a Fix .send_message not expecting UpdateNewChannelMessage (#331) 2017-10-13 10:53:36 +02:00
Lonami Exo
9cf5506ee4 Don't .disconnect() on FloodWaitError
Since other requests can still be invoked, it makes no
sense to call .disconnect().
2017-10-13 09:59:37 +02:00
Lonami Exo
bec5f9fb89 Add stub methods for more server responses 2017-10-12 21:09:09 +02:00