From ba0af8043c24e97a0a6ea066a7301b47d81de22b Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 27 Dec 2017 13:05:59 +0100 Subject: [PATCH] Add Null primitive data type --- compiler/api/compiler.py | 1 + compiler/api/source/main_api.tl | 4 +-- pyrogram/api/core/primitives/__init__.py | 1 + pyrogram/api/core/primitives/null.py | 32 ++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 pyrogram/api/core/primitives/null.py diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py index 3f35e52e..82a121cb 100644 --- a/compiler/api/compiler.py +++ b/compiler/api/compiler.py @@ -125,6 +125,7 @@ class Compiler: f.write("\n 0xbc799737: \"core.BoolFalse\",") f.write("\n 0x997275b5: \"core.BoolTrue\",") + f.write("\n 0x56730bcc: \"core.Null\",") f.write("\n 0x1cb5c415: \"core.Vector\",") f.write("\n 0x73f1f8dc: \"core.MsgContainer\",") f.write("\n 0xae500895: \"core.FutureSalts\",") diff --git a/compiler/api/source/main_api.tl b/compiler/api/source/main_api.tl index fba51767..6e07cc08 100644 --- a/compiler/api/source/main_api.tl +++ b/compiler/api/source/main_api.tl @@ -7,7 +7,7 @@ ---types--- // boolFalse#bc799737 = Bool; // Parsed manually -// boolTrue#997275b5 = Bool; // parsed manually +// boolTrue#997275b5 = Bool; // Parsed manually // true#3fedd339 = True; // Not used @@ -15,7 +15,7 @@ // error#c4b9f9bb code:int text:string = Error; // Not used -// null#56730bcc = Null; // Not used +// null#56730bcc = Null; // Parsed manually inputPeerEmpty#7f3b18ea = InputPeer; inputPeerSelf#7da07ec9 = InputPeer; diff --git a/pyrogram/api/core/primitives/__init__.py b/pyrogram/api/core/primitives/__init__.py index 159d85ae..96878073 100644 --- a/pyrogram/api/core/primitives/__init__.py +++ b/pyrogram/api/core/primitives/__init__.py @@ -20,5 +20,6 @@ from .bool import Bool, BoolTrue, BoolFalse from .bytes import Bytes from .double import Double from .int import Int, Long, Int128, Int256 +from .null import Null from .string import String from .vector import Vector diff --git a/pyrogram/api/core/primitives/null.py b/pyrogram/api/core/primitives/null.py new file mode 100644 index 00000000..9c514f95 --- /dev/null +++ b/pyrogram/api/core/primitives/null.py @@ -0,0 +1,32 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017 Dan Tès +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +from io import BytesIO + +from ..object import Object + + +class Null(Object): + ID = 0x56730bcc + + @staticmethod + def read(b: BytesIO, *args) -> None: + return None + + def __new__(cls) -> bytes: + return int.to_bytes(cls.ID, 4, "little")