Commit Graph

435 Commits

Author SHA1 Message Date
Lonami Exo
b83cd98ba0 Replace TLObject.on_send with the new .to_bytes()
This also replaces some int.to_bytes() calls with a faster
struct.pack (up to x4 faster). This approach is also around
x3 faster than creating a BinaryWriter just to serialize a
TLObject as bytes.
2017-09-26 14:36:02 +02:00
Lonami Exo
f233110732 Allow sending several requests at once through new MessageContainer 2017-09-25 20:52:27 +02:00
Lonami Exo
80e9877256 Show the type of children TLObjects on .stringify() 2017-09-23 11:01:25 +02:00
Lonami Exo
12c12fdfaf Fix representing .stringify() for bytes with indent > 0 2017-09-17 16:35:35 +02:00
Lonami Exo
59a4315c28 Avoid calling InitConnectionRequest when it's not needed 2017-09-17 14:26:25 +02:00
Lonami Exo
151e1623d3 Stop saving the session ID, sequence and time offset
After some discussion, storing the session ID is not needed at all.
It can always start off as a new random 8-byte-long number, also
restarting the sequence number at 0. This should prevent some seqno
too low errors.

Also, saving the time offset could cause more trouble than fixing
them, so that has also been removed.
2017-09-14 11:44:42 +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
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
22673aec0e Replace the old Session+pickle with JsonSession (name change) 2017-08-29 15:59:08 +02:00
Lonami Exo
00b5b5021b Report errors to pwrtelegram.xyz by default 2017-08-25 15:34:20 +02:00
Lonami Exo
2517b9787d TLObject.stringify() was showing bytes as lists 2017-08-24 20:56:08 +02:00
Lonami Exo
7e85a3cda4 Attempt at making get_new_msg_id thread-safe (#195) 2017-08-14 15:17:16 +02:00
Lonami Exo
160a3699ac Fix confusing names "MtProtoRequest" and ".confirmed" (#176)
This also fixes the annoyingly confusing message:
"Odd msg_seqno expected (relevant message), but even received."
2017-07-24 16:54:48 +02:00
Lonami Exo
8fd0d7eadd Add a new .stringify() function to visualize TLObjects more easily 2017-07-04 21:15:47 +02:00
Lonami Exo
632fcb7c00 Ensure device model is non-empty (closes #154) 2017-07-04 19:47:55 +02:00
Lonami Exo
23e2802215 Update to layer 68 2017-06-30 11:48:45 +02:00
Lonami Exo
b0173c3ec2 Use more accurate values for msg_ids 2017-06-26 11:01:20 +02:00
Dmitry D. Chernov
8d9e50989b Fix temporary Session fields not being defined 2017-06-19 07:41:47 +10:00
Dmitry D. Chernov
2af962230f Fix error 400:CONNECTION_APP_VERSION_EMPTY when using temporary sessions 2017-06-19 07:40:35 +10:00
Lonami Exo
8afb0a3f6b Rename Request.msg_id to request_msg_id to avoid name clash (fix #122) 2017-06-18 10:01:59 +02:00
Lonami Exo
765ae870cf Fix connection parameters not being copied on reconnection (#129) 2017-06-17 22:05:34 +02:00
Lonami Exo
96d8ca94cf Move TelegramClient.list_sessions to *Session.list_session 2017-06-14 13:57:30 +02:00
Lonami Exo
a73be04da7 Move connection parameters to the session 2017-06-10 13:15:04 +02:00
Lonami Exo
6a043b7371 Fix Session not being able to save auth_key=None 2017-06-08 16:45:09 +02:00
Lonami Exo
1860054ec0 Make generate_sequence() thread-safe and move it to Session 2017-06-07 12:00:01 +01:00
Lonami Exo
49ca5c00c7 Create a more upgrade-resistant JSON-based Session class 2017-06-07 11:48:54 +01:00
Lonami Exo
cf6f300df1 Improve .is_user_authorized() and add a .get_me() method 2017-06-04 17:24:08 +02:00
Lonami Exo
7f84374e98 Attempt at fixing msg_id too low/high (#95) 2017-05-26 16:39:59 +02:00
Lonami Exo
02a847b64a Make lint happier 2017-05-21 13:59:16 +02:00
Lonami Exo
63c89af983 Use relative imports always where possible 2017-05-21 13:02:54 +02:00
Lonami Exo
ca80b05694 Add shebangs and set proper file permissions 2017-05-20 15:58:44 +02:00
Fadi Hadzh
d087941bd0 Many code-style improvements 2016-11-30 00:29:42 +03:00
Lonami
51a531225f Totally refactored source files location
Now it *should* be easier to turn Telethon
into a pip package
2016-09-17 20:45:12 +02:00