Lonami Exo
2873dcf1c6
Add '_' key to TLObject's .to_dict() and remove recursive param
...
Closes #559
2018-01-25 09:44:07 +01:00
Lonami Exo
0e43022959
Remove redundant import, show type instead TLObject on docstring
2018-01-19 13:40:04 +01:00
Lonami Exo
33e50aaee1
Reuse .on_response/.__str__/.stringify, override iff necessary
2018-01-19 12:12:52 +01:00
Lonami Exo
1c9fa76ede
Add new method to .resolve() parameters instead on init
...
TLObject's __init__ used to call utils.get_input_* methods and
similar to auto-cast things like User into InputPeerUser as
required. Now there's a custom .resolve() method for this purpose
with several advantages:
- Old behaviour still works, autocasts work like usual.
- A request can be constructed and later modified, before the
autocast only occured on the constructor but now while invoking.
- This allows us to not only use the utils module but also the
client, so it's even possible to use usernames or phone numbers
for things that require an InputPeer. This actually assumes
the TelegramClient subclass is being used and not the bare version
which would fail when calling .get_input_peer().
2018-01-19 11:47:45 +01:00
Lonami Exo
3537e9bcc9
Support more types to represent a date
2017-12-28 12:32:16 +01:00
Lonami Exo
b11c2e885b
Fix assertion for multiple same flag parameters
2017-12-25 18:00:24 +01:00
Lonami Exo
9c66f0b2b4
Fix empty strings not working as expected for flag parameters
2017-12-24 15:15:19 +01:00
Lonami Exo
2f28050cac
Fix generated __bytes__ failing with flag indicator but no flags
...
Likely since the code was ported to get rid of the BinaryWriter,
since the flag calculation was inlined. Some types (only
channelMessages as of layer 71) had a flag indicator but no flag
arguments, so the calculation of which were not None failed.
This special case is now handled correctly.
2017-10-28 11:09:55 +02:00
Lonami Exo
b3ca68b7d9
Avoid cyclic imports caused by #348 ( fix #357 )
2017-10-24 10:07:31 +02:00
Lonami Exo
5f0faee013
Attempt at fixing redundant import from ee01724
( #357 )
2017-10-22 11:12:42 +02:00
Lonami Exo
0e1249c833
Fix incorrectly generated code
2017-10-19 10:42:09 +02:00
Lonami Exo
f49208f961
Fix assert condition on generated code with flags involved
...
The specific case was SendMessageRequest with
InputMessageEntityMentionName, failing with bot/bot_info
2017-10-18 20:43:46 +02:00
Lonami Exo
adb79b21cf
Replace .to_bytes() with the special .__bytes__ function
2017-10-17 19:54:59 +02:00
Viktor Oreshkin
ee01724cdb
Fix parsing for constructors and not objects ( #348 )
2017-10-16 20:15:22 +02:00
Lonami Exo
83677fc927
Enhance and use .get_input_photo on the generated code
2017-10-08 13:45:14 +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
06bb09b95c
Fix wrong .empty() due to variable shadowing (from ce48c97
)
2017-10-01 10:45:59 +02:00
Lonami Exo
ce48c9752e
Assert flag params with same flag index are all set/unset
2017-09-30 19:47:19 +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
a4fa652d35
Precompute the flag index on the generated code
2017-09-29 13:03:35 +02:00
Lonami Exo
76d14b2dd9
Make generated .to_bytes() more readable
2017-09-29 13:00:22 +02:00
Lonami Exo
195bba6f21
Fix bug where booleans were always serialized as false
2017-09-29 12:57:53 +02:00
Lonami Exo
423efc4360
Fix optional vector arguments failing
2017-09-29 11:56:43 +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
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
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
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
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