Lonami Exo
4fd9d361f0
Replace redundant isinstance calls with a tuple parameter
2017-10-13 11:39:34 +02:00
Lonami Exo
f2338e49ae
Allow using a callable key on EntityDatabase
2017-10-12 19:54:23 +02:00
Lonami Exo
16a0cecf46
Fix EntityDatabase.__delitem__
2017-10-12 19:47:13 +02:00
Lonami Exo
0c1170ee61
Replace hardcoded reads with TLObject's .read()
2017-10-12 16:40:59 +02:00
Lonami Exo
da51e71def
Fix .get_input_entity returning marked IDs ( closes #314 )
2017-10-09 19:40:39 +02:00
Lonami Exo
401de913af
Fix EntityDatabase failing with InputPeer keys
2017-10-09 11:20:31 +02:00
Joscha Götzer
4a482b3506
.get_drafts() and a custom Draft class ( #310 )
2017-10-09 09:54:48 +02:00
Lonami Exo
1f54cbfb5a
Make str(TLObject) return valid code to generate it back
2017-10-08 17:51:29 +02:00
Lonami Exo
15e90dcb69
Allow specifying a threshold to handle flood waits
2017-10-08 16:15:30 +02:00
Lonami Exo
91a5d20e93
Replace .on_response with static .from_reader for all types
2017-10-07 13:26:09 +02:00
Lonami Exo
79e36c98bd
Fix EntityDatabase.get_input_peer not actually working
2017-10-06 21:42:04 +02:00
Lonami Exo
dde196d8e4
Swallow errors when processing entities
...
Some bug was causing an infinite lock due to the entity
database failing with InputPeerSelf, since adding a full
entity to the database wasn't disallowing self, and so
wasn't utils get_peer_id. Although last commit fixed that,
just in case, swallow errors there.
2017-10-05 13:34:44 +02:00
Lonami Exo
1fb3d0d00c
Fix EntityDatabase failing to cache self user
2017-10-05 13:34:11 +02:00
Lonami Exo
4f2a44231a
Allow disabling the EntityDatabase fully or partially
2017-10-05 13:06:51 +02:00
Lonami Exo
99cc0778bb
Allow EntityDatabase to be accessed by phone
2017-10-05 13:01:00 +02:00
Lonami Exo
10eca82143
Fix process_entities not working on list of entities
2017-10-05 12:29:52 +02:00
Lonami Exo
d2e244817a
Make EntityDatabase.get a no-op if key is an entity already
2017-10-05 12:28:04 +02:00
Lonami Exo
e5c4df98df
Use EntityDatabase on TelegramClient.get_entity instead lru_cache
2017-10-05 12:27:32 +02:00
Lonami Exo
a0fc5ed54e
Use EntityDatabase in the Session class
2017-10-04 21:02:45 +02:00
Lonami Exo
36dabc4928
Process entities from the MtProtoSender instead TelegramBareClient
...
This way, update objects will also be processed when they occur.
2017-10-01 16:02:29 +02:00
Lonami Exo
9bccd17881
Add an option to allow not saving/processing found entities
2017-10-01 13:32:27 +02:00
Lonami Exo
e4c5396c04
Add cross-thread safety when saving the session
2017-10-01 13:27:08 +02:00
Lonami Exo
a737f33324
Save all found entities to the session file
2017-10-01 13:27:08 +02:00
Lonami Exo
6df38da793
Fix session failing to load if no auth_key present
2017-09-29 19:54:40 +02:00
Lonami Exo
afc4bd9cab
Rename constructor/subclass_of_id to upper case, keep only static
2017-09-29 13:11:33 +02:00
Lonami Exo
cc337328c6
Rename handmade Message class to TLMessage to avoid confusion
2017-09-28 11:59:24 +02:00
Lonami Exo
fb0898b9cb
Don't distinguish between str and bytes when serializing
...
This makes it easier to use some requests like ReqPqRequest which
needs a string of bytes, not a valid utf-8 string per se.
2017-09-28 09:55:29 +02:00
Lonami Exo
c667a00281
Avoid using BinaryWriter where possible
2017-09-27 21:23:59 +02:00
Lonami Exo
8a605f21e6
Remove BinaryWriter dependency on MessageContainer
2017-09-27 21:06:01 +02:00
Lonami Exo
bd3dd371a2
Create a proper Message class (msg_id, seqno, body; only .to_bytes())
2017-09-27 21:01:20 +02:00
Lonami Exo
795cb98909
Move MessageContainer.on_send inside its .to_bytes
2017-09-27 13:49:58 +02:00
Lonami Exo
6df9fc558e
Create and use a new GzipPacked class, also when sending
2017-09-27 13:46:53 +02:00
Lonami Exo
7b736aa6ef
Fix MessageContainer having the wrong constructor id
2017-09-27 13:46:02 +02:00
Lonami Exo
98c2e1dd4f
Replace 4 .append calls with a single one when serializing bytes
2017-09-26 14:41:11 +02:00
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