Lonami Exo
ab07f0220a
Save dc_id instead layer and salt in the session file
...
Server salts change every 30 minutes after all, so keeping them
in the long-term storage session file doesn't make much sense.
Saving the layer doesn't make sense either, as it was only used
to know whether to init connection or not, but it should be done
always.
2017-12-28 01:06:27 +01:00
Dmitry D. Chernov
6ec6967ff9
Make exception types correspond to Python docs
2017-12-28 09:48:02 +10:00
Lonami Exo
f29ee41f6c
Don't use rowid for the entities table
2017-12-27 13:27:54 +01:00
Lonami Exo
932ed9ea9d
Cast to input peer early on get input entity and close cursor
2017-12-27 13:06:03 +01:00
Lonami Exo
843e777eba
Simplify .process_entities() flow
2017-12-27 12:58:50 +01:00
Lonami Exo
b6b47d175c
Fix username.lower() on instances with username field but None
2017-12-27 12:16:49 +01:00
Lonami Exo
86429e7291
Lowercase usernames before adding them to the database
2017-12-27 11:54:08 +01:00
Lonami Exo
aef96f1b68
Remove custom EntityDatabase and use sqlite3 instead
...
There are still a few things to change, like cleaning up the
code and actually caching the entities as a whole (currently,
although the username/phone/name can be used to fetch their
input version which is an improvement, their full version
needs to be re-fetched. Maybe it's a good thing though?)
2017-12-27 00:50:09 +01:00
Lonami Exo
0a4849b150
Small cleanup of the Session class
2017-12-26 16:59:30 +01:00
Lonami Exo
664417b409
Use sqlite3 instead JSON for the session files
2017-12-26 16:45:47 +01:00
Lonami Exo
238198db5a
Create a convenient class to wrap Dialog instances
2017-12-24 16:18:09 +01:00
Lonami Exo
23ab70fc29
Remove unused request_msg_id from the TLObject class
2017-12-20 17:48:41 +01:00
Lonami Exo
7d189119f4
Fix salt migration failing with valid signed salts
2017-12-20 12:47:39 +01:00
Lonami Exo
d4d7aa9063
Use signed salt
2017-12-03 21:10:22 +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
Vladislav Kolesnichenko
ee5915e86d
Add support for connecting through IPv6 ( #425 for #112 )
2017-11-16 13:30:18 +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
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
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
3db13ccdd2
Add a more descriptive error when serializing bytes
2017-10-25 12:43:57 +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
adb79b21cf
Replace .to_bytes() with the special .__bytes__ function
2017-10-17 19:54:59 +02:00
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
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