mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
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
This commit is contained in:
@@ -132,6 +132,17 @@ class TLGenerator:
|
||||
TLGenerator.write_onsend_code(builder, arg, tlobject.args)
|
||||
builder.end_block()
|
||||
|
||||
# Write the empty() function, which returns an "empty"
|
||||
# instance, in which all attributes are set to None
|
||||
builder.writeln('@staticmethod')
|
||||
builder.writeln('def empty():')
|
||||
builder.writeln('"""Returns an "empty" instance (all attributes are None)"""')
|
||||
builder.writeln('return {}({})'.format(
|
||||
TLGenerator.get_class_name(tlobject),
|
||||
', '.join('None' for _ in range(len(args)))
|
||||
))
|
||||
builder.end_block()
|
||||
|
||||
# Write the on_response(self, reader) function
|
||||
builder.writeln('def on_response(self, reader):')
|
||||
# Do not read constructor's ID, since that's already been read somewhere else
|
||||
|
Reference in New Issue
Block a user