Commit Graph

420 Commits

Author SHA1 Message Date
Lonami Exo
423efc4360 Fix optional vector arguments failing 2017-09-29 11:56:43 +02:00
Lonami Exo
4bedbfe945 Use bytes instead string type on the auth-key methods 2017-09-28 10:32:57 +02:00
Lonami Exo
14791e1df1 Fix wrong type hint for int128 and int256 2017-09-28 10:12:39 +02:00
Lonami Exo
748c2560de Fix auto-generated code didn't actually write int128/int256 2017-09-28 10:12:15 +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
9b7733d6b9 Avoid the use of starred expressions on autogen code (fix #266) 2017-09-27 12:05:35 +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
b40708a8c7 Import get_input_* only once on the generated code 2017-09-25 14:05:13 +02:00
Lonami Exo
dc73744fc4 Add get_input_media calls on the generated code 2017-09-25 13:47:25 +02:00
Lonami Exo
1593a4415e Fix None datetime being type hinted as invalid 2017-09-23 20:07:40 +02:00
Lonami Exo
5701029fbf Stop treating .to_dict() with no args as a special case 2017-09-23 10:59:08 +02:00
Lonami Exo
0b48b1ec8a Add support for non-recursive TLObject.to_dict() 2017-09-23 10:41:36 +02:00
Lonami Exo
81d4d76d16 Fix generated code showing the incorrent type hint for datetime 2017-09-19 13:20:34 +02:00
Lonami Exo
f7e4f3f678 Make type hinting on the generated code more IDE-friendly 2017-09-18 21:00:06 +02:00
Lonami Exo
2595d45bd7 Import os only once on the generated code 2017-09-18 20:23:03 +02:00
Lonami Exo
2c5c674531 Stop using TLObject.__repr__ to show the TL definition 2017-09-18 20:19:39 +02:00
Lonami Exo
b14a7d9e68 Revert layer being a property 2017-09-17 16:19:53 +02:00
Lonami Exo
aea10b103b Rename generated layer variable to uppercase readonly property 2017-09-17 16:17:55 +02:00
Lonami Exo
3a5eab2e83 Fix infering random_id lists failing for ForwardMessages 2017-09-12 10:32:11 +02:00
Lonami Exo
97cab7347b Make lint happier 2017-09-04 17:10:04 +02:00
Lonami Exo
0e45f46ad5 Properly ignore core types when generating code 2017-09-04 16:38:03 +02:00
Lonami Exo
e8cdcf369d Sort generated code by name for more predictable results 2017-09-04 15:11:46 +02:00
Lonami Exo
c5b562d4f6 Move the from tlobject import TLObject to only the top of the file 2017-09-04 14:08:36 +02:00
Lonami Exo
64f1031a45 Move comments from auto-generated code to the generator itself 2017-09-04 14:05:30 +02:00
Lonami Exo
c3f679597c Move the auto-generated notice to only the top of the file 2017-09-04 13:57:40 +02:00
Lonami Exo
e83b250a22 Replace generated directory modules with simply files 2017-09-04 13:51:47 +02:00
Lonami Exo
7eab28206b Change the code generator to use a single file per namespace 2017-09-04 13:44:39 +02:00
Lonami Exo
a5d86b4572 Update to layer 71 2017-09-04 11:54:37 +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
38e0888ea0 Update to layer 70 2017-07-23 17:12:29 +02:00
Lonami Exo
9b17888e3e Make generated code slightly smaller 2017-07-11 11:36:00 +02:00
Lonami Exo
cfea0f80da Consider vector attributes for get_input_* utils (closes #166) 2017-07-11 11:14:58 +02:00
Lonami Exo
bdee94eaf3 Implement automatic cast to InputUser too (closes #159) 2017-07-10 16:04:10 +02:00
Lonami Exo
95a989be2c Automatically cast Channel to InputChannel (similar to InputPeer) 2017-07-07 09:48:06 +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
23e2802215 Update to layer 68 2017-06-30 11:48:45 +02:00
Lonami Exo
79ee98a4dd Infer the object ID from its TL definition when not given 2017-06-30 11:28:54 +02:00
Lonami Exo
b0b814bdb9 Use setup.py to run tl_generator.py instead (plus some cleanup) 2017-06-21 11:27:22 +02:00
Lonami Exo
e7b0c06ca5 Make .get_input_user faster when the right type is given 2017-06-16 10:01:05 +02:00
Lonami Exo
86d45cc276 Improve .get_input_peer and use it only when creating requests*
This avoids cyclic dependencies, so types requiring an InputPeer
as a parameter will NOT convert faulty types to the right ones.
2017-06-15 17:03:59 +02:00
Lonami Exo
b8e46446ba Automatically call .get_input_peer on the requests that need it 2017-06-15 16:35:40 +02:00
Lonami Exo
9e07a2580c Fix extra line being appended on empty .to_dict()'s 2017-06-13 19:46:16 +02:00
Lonami Exo
769692959f Make the TLGenerator class a lot more readable 2017-06-12 10:43:43 +02:00
Lonami Exo
68a625b82b Try to adhere to the 80-characters limit 2017-06-12 10:16:24 +02:00
Goblenus
76166cd1ec Add .to_dict() to the generated types 2017-06-12 09:53:26 +02:00
Lonami Exo
1ca41b5854 Automatically infer the value for 'random_id' parameters 2017-06-11 19:16:59 +02:00
Lonami Exo
c6acd6adc5 Use only ASCII characters on the code (closes #104) 2017-06-10 13:39:37 +02:00
Lonami Exo
9b5d1b02e0 Add return type to the docs of the generated code 2017-05-23 10:10:01 +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
Lonami Exo
befc7a5657 Fix layer 66 not being the real layer 66
Telegram decided to update the scheme.tl without increasing
the layer number, so it had been unnoticed until now.
2017-05-20 11:59:41 +02:00
Lonami Exo
c4447bf226 Distinguish between vector type and constructor (fix #81) 2017-05-19 09:41:22 +02:00
Lonami Exo
b84641023a Handle more cases where the type is a date 2017-05-19 09:30:30 +02:00
Birger Jarl
930dc99f31 Serialize flag_indicator argument to flags:# 2017-05-13 09:38:49 +02:00
Dmitry D. Chernov
6baad93938 SourceBuilder: Don't perform stream flushing twice
stream.close() always perform flush by itself
2017-05-09 19:50:46 +02:00
Lonami Exo
4421c3ac7a Update to layer 66 2017-04-15 18:10:27 +02:00
Belegnar
0e44657963 * doc improvement
* relative imports not allowed when module is not loaded (https://www.python.org/dev/peps/pep-0366/)
2017-03-10 14:13:22 +03:00
Lonami Exo
b5dfc5d514 Fix requests returning vectors not working (closes #26) 2017-02-25 11:28:55 +01:00
Lonami Exo
a5bd740b10 Updated to layer 62 2017-01-04 15:40:53 +01:00
Fadi Hadzh
d087941bd0 Many code-style improvements 2016-11-30 00:29:42 +03:00
Lonami Exo
be94bff576 Patched code generator and updated README.rst removing markdown leftovers 2016-11-23 21:03:58 +01:00
Lonami
6a32c6cd7a Moved requests .constructor_id to be a class-level variable 2016-10-04 18:55:02 +02:00
Lonami
f2728f47c3 Updated scheme to layer 57 and fixes to README links 2016-10-03 19:57:21 +02:00
Lonami
77aa37d2ad Added an .empty() function to the objects, fixes to msgs_ack
The .empty() function returns an "empty" instance of the object
(attributes set to None). This is used rather than using reflection.

The msgs_ack handling broke stuff (InvokeWithLayer when there were
updates), so this is now handled; yet there may be a better fix
2016-09-26 17:18:25 +02:00
Lonami
36b8a9026f Fixed revert by hand (I hope) 2016-09-26 13:13:11 +02:00
Lonami
b68772aab5 Fixed JSON encoding and decoding for lists, added empty() method
The new empty() method retrieves an empty instance of the
given object, with all the attributes set to None
2016-09-25 10:50:48 +02:00
Lonami
fddb3e9aac Added ability to encode/decode TLObjects, updated README 2016-09-24 21:17:41 +02:00
Lonami
6642f73a3d Detect current MTProtoLayer automatically 2016-09-17 21:09:20 +02: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