From f78309e2f48539715cf017c783e1d5a85ddced1d Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 8 Mar 2024 14:10:46 +0100 Subject: [PATCH] Fixes --- docs | 2 +- src/MTProto.php | 6 +- src/TL/TLParser.php | 6752 ++++++++++++++++++++++++++++++++++++++++-- tools/TL/Builder.php | 4 +- 4 files changed, 6552 insertions(+), 212 deletions(-) diff --git a/docs b/docs index b7104e4c1..52232ea10 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit b7104e4c18ccec8c0fc94950f3d73768ba927fda +Subproject commit 52232ea10ed26c86e5ca6bd6b3c217a9fecc986f diff --git a/src/MTProto.php b/src/MTProto.php index e59bc1788..13765980b 100644 --- a/src/MTProto.php +++ b/src/MTProto.php @@ -1568,9 +1568,9 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter if (!\extension_loaded('uv')) { $warning .= "

".htmlentities(sprintf(Lang::$current_lang['extensionRecommended'], 'uv'))."

"; } - if (Magic::$hasBasedirLimitation) { - $warning .= "

".htmlentities(Lang::$current_lang['extensionRecommended'])."

"; - } + /*if (Magic::$hasBasedirLimitation) { + $warning .= "

".htmlentities(Lang::$current_lang['baseDirLimitation'])."

"; + }*/ if (Lang::$currentPercentage !== 100) { $warning .= "

".sprintf(Lang::$current_lang['translate_madelineproto_web'], Lang::$currentPercentage)."

"; } diff --git a/src/TL/TLParser.php b/src/TL/TLParser.php index db26cfd49..758242d6d 100644 --- a/src/TL/TLParser.php +++ b/src/TL/TLParser.php @@ -1,239 +1,6577 @@ - $stream, - default => self::err($stream) - }; + private static function gzdecode_vector(mixed $stream): mixed { + $res = fopen('php://memory', 'rw+b'); + fwrite($res, gzdecode(self::deserialize_string($stream))); + rewind($res); + return match (stream_get_contents($stream, 4)) { + '警' => $stream, + default => self::err($stream) + }; + } - private static function deserialize_bytes(mixed $stream): mixed - { + private static function deserialize_bytes(mixed $stream): mixed { - $l = \ord(stream_get_contents($stream, 1)); - if ($l > 254) { - throw new Exception(Lang::$current_lang["length_too_big"]); - } - if ($l === 254) { - $l = unpack("V", stream_get_contents($stream, 3).\chr(0))[1]; - $x = stream_get_contents($stream, $l); + + $l = \ord(stream_get_contents($stream, 1)); + if ($l > 254) { + throw new Exception(Lang::$current_lang["length_too_big"]); + } + if ($l === 254) { + $l = unpack("V", stream_get_contents($stream, 3).\chr(0))[1]; + $x = stream_get_contents($stream, $l); + $resto = (-$l) % 4; + $resto = $resto < 0 ? $resto + 4 : $resto; + if ($resto > 0) { + stream_get_contents($stream, $resto); + } + } else { + $x = $l ? stream_get_contents($stream, $l) : ""; + $resto = (-$l+1) % 4; + $resto = $resto < 0 ? $resto + 4 : $resto; + if ($resto > 0) { + stream_get_contents($stream, $resto); + } + } + + return new Types\Bytes($x); + + } + private static function deserialize_string(mixed $stream): mixed { + + + $l = \ord(stream_get_contents($stream, 1)); + if ($l > 254) { + throw new Exception(Lang::$current_lang["length_too_big"]); + } + if ($l === 254) { + $l = unpack("V", stream_get_contents($stream, 3).\chr(0))[1]; + $x = stream_get_contents($stream, $l); + $resto = (-$l) % 4; + $resto = $resto < 0 ? $resto + 4 : $resto; + if ($resto > 0) { + stream_get_contents($stream, $resto); + } + } else { + $x = $l ? stream_get_contents($stream, $l) : ""; + $resto = (-$l+1) % 4; + $resto = $resto < 0 ? $resto + 4 : $resto; + if ($resto > 0) { + stream_get_contents($stream, $resto); + } + } + + return $x; + + } + private static function deserialize_waveform(mixed $stream): mixed { + + + $l = \ord(stream_get_contents($stream, 1)); + if ($l > 254) { + throw new Exception(Lang::$current_lang["length_too_big"]); + } + if ($l === 254) { + $l = unpack("V", stream_get_contents($stream, 3).\chr(0))[1]; + $x = stream_get_contents($stream, $l); + $resto = (-$l) % 4; + $resto = $resto < 0 ? $resto + 4 : $resto; + if ($resto > 0) { + stream_get_contents($stream, $resto); + } + } else { + $x = $l ? stream_get_contents($stream, $l) : ""; + $resto = (-$l+1) % 4; + $resto = $resto < 0 ? $resto + 4 : $resto; + if ($resto > 0) { + stream_get_contents($stream, $resto); + } + } + + return TL::extractWaveform($x); + + } + private static function deserialize_random_bytes(mixed $stream): void { + + $l = \ord(stream_get_contents($stream, 1)); + if ($l > 254) { + throw new Exception(Lang::$current_lang["length_too_big"]); + } + if ($l === 254) { + $l = unpack("V", stream_get_contents($stream, 3).\chr(0))[1]; + if ($l < 15) { + throw new SecurityException("Random_bytes is too small!"); + } + } else { + if ($l < 15) { + throw new SecurityException("Random_bytes is too small!"); + } + $l += 1; + } $resto = (-$l) % 4; $resto = $resto < 0 ? $resto + 4 : $resto; if ($resto > 0) { - stream_get_contents($stream, $resto); + $l += $resto; } - } else { - $x = $l ? stream_get_contents($stream, $l) : ""; - $resto = (-$l+1) % 4; - $resto = $resto < 0 ? $resto + 4 : $resto; - if ($resto > 0) { - stream_get_contents($stream, $resto); - } - } - - return new Types\Bytes($x); - + stream_get_contents($stream, $l); + } - private static function deserialize_string(mixed $stream): mixed - { - - $l = \ord(stream_get_contents($stream, 1)); - if ($l > 254) { - throw new Exception(Lang::$current_lang["length_too_big"]); - } - if ($l === 254) { - $l = unpack("V", stream_get_contents($stream, 3).\chr(0))[1]; - $x = stream_get_contents($stream, $l); - $resto = (-$l) % 4; - $resto = $resto < 0 ? $resto + 4 : $resto; - if ($resto > 0) { - stream_get_contents($stream, $resto); - } - } else { - $x = $l ? stream_get_contents($stream, $l) : ""; - $resto = (-$l+1) % 4; - $resto = $resto < 0 ? $resto + 4 : $resto; - if ($resto > 0) { - stream_get_contents($stream, $resto); - } - } - - return $x; + private function deserialize_type_array_of_int(mixed $stream): array { + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + unpack('l', stream_get_contents($stream, 4))[1]; + } + return $result; + } - private static function deserialize_waveform(mixed $stream): mixed - { - - $l = \ord(stream_get_contents($stream, 1)); - if ($l > 254) { - throw new Exception(Lang::$current_lang["length_too_big"]); - } - if ($l === 254) { - $l = unpack("V", stream_get_contents($stream, 3).\chr(0))[1]; - $x = stream_get_contents($stream, $l); - $resto = (-$l) % 4; - $resto = $resto < 0 ? $resto + 4 : $resto; - if ($resto > 0) { - stream_get_contents($stream, $resto); - } - } else { - $x = $l ? stream_get_contents($stream, $l) : ""; - $resto = (-$l+1) % 4; - $resto = $resto < 0 ? $resto + 4 : $resto; - if ($resto > 0) { - stream_get_contents($stream, $resto); - } - } - - return TL::extractWaveform($x); + private function deserialize_type_array_of_long(mixed $stream): array { + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + unpack('q', stream_get_contents($stream, 8))[1]; + } + return $result; + } - private static function deserialize_random_bytes(mixed $stream): void - { - - $l = \ord(stream_get_contents($stream, 1)); - if ($l > 254) { - throw new Exception(Lang::$current_lang["length_too_big"]); - } - if ($l === 254) { - $l = unpack("V", stream_get_contents($stream, 3).\chr(0))[1]; - if ($l < 15) { - throw new SecurityException("Random_bytes is too small!"); - } - } else { - if ($l < 15) { - throw new SecurityException("Random_bytes is too small!"); - } - $l += 1; - } - $resto = (-$l) % 4; - $resto = $resto < 0 ? $resto + 4 : $resto; - if ($resto > 0) { - $l += $resto; - } - stream_get_contents($stream, $l); + private function deserialize_type_array_of_double(mixed $stream): array { + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + unpack('d', stream_get_contents($stream, 8))[1]; + } + return $result; + } - private function deserialize_type_array_of_int(mixed $stream): array - { - - $stream = match(stream_get_contents($stream, 4)) { - '警' => $stream, - '+r0' => self::gzdecode_vector($stream) - }; - $result = []; - for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { - unpack('l', stream_get_contents($stream, 4))[1]; - } - return $result; + private function deserialize_type_array_of_strlong(mixed $stream): array { + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + stream_get_contents($stream, 8); + } + return $result; + } - private function deserialize_type_array_of_long(mixed $stream): array - { - - $stream = match(stream_get_contents($stream, 4)) { - '警' => $stream, - '+r0' => self::gzdecode_vector($stream) - }; - $result = []; - for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { - unpack('q', stream_get_contents($stream, 8))[1]; - } - return $result; + private function deserialize_type_array_of_string(mixed $stream): array { + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $this->deserialize_string($stream); + } + return $result; + } - private function deserialize_type_array_of_double(mixed $stream): array - { - - $stream = match(stream_get_contents($stream, 4)) { - '警' => $stream, - '+r0' => self::gzdecode_vector($stream) - }; - $result = []; - for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { - unpack('d', stream_get_contents($stream, 8))[1]; - } - return $result; + private function deserialize_type_array_of_bytes(mixed $stream): array { + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $this->deserialize_bytes($stream); + } + return $result; + } - private function deserialize_type_array_of_strlong(mixed $stream): array - { - - $stream = match(stream_get_contents($stream, 4)) { - '警' => $stream, - '+r0' => self::gzdecode_vector($stream) - }; - $result = []; - for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { - stream_get_contents($stream, 8); - } - return $result; - + private function deserialize_type_Peer(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'"QY' => unpack('q', stream_get_contents($stream, 8))[1], +'6' => -unpack('q', stream_get_contents($stream, 8))[1], +'7失' => -1000000000000 - unpack('q', stream_get_contents($stream, 8))[1], +'+r0' => $this->deserialize_type_Peer($stream), +default => self::err($stream) +} +; } - private function deserialize_type_array_of_string(mixed $stream): array - { - - $stream = match(stream_get_contents($stream, 4)) { - '警' => $stream, - '+r0' => self::gzdecode_vector($stream) - }; - $result = []; - for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { - $this->deserialize_string($stream); - } - return $result; + private static function deserialize_messageEmpty(mixed $stream): mixed { +$tmp = ['_' => 'messageEmpty']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['peer_id'] = self::deserialize_type_Peer($stream); +return $tmp; } - private function deserialize_type_array_of_bytes(mixed $stream): array - { - - $stream = match(stream_get_contents($stream, 4)) { - '警' => $stream, - '+r0' => self::gzdecode_vector($stream) - }; - $result = []; - for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { - $this->deserialize_bytes($stream); - } - return $result; + private static function deserialize_messageFwdHeader(mixed $stream): mixed { +$tmp = ['_' => 'messageFwdHeader']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['imported'] = ($flags & 128) !== 0; +$tmp['saved_out'] = ($flags & 2048) !== 0; +if (($flags & 1) !== 0) $tmp['from_id'] = self::deserialize_type_Peer($stream); +if (($flags & 32) !== 0) $tmp['from_name'] = $this->deserialize_string($stream); +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 4) !== 0) $tmp['channel_post'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['post_author'] = $this->deserialize_string($stream); +if (($flags & 16) !== 0) $tmp['saved_from_peer'] = self::deserialize_type_Peer($stream); +if (($flags & 16) !== 0) $tmp['saved_from_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 256) !== 0) $tmp['saved_from_id'] = self::deserialize_type_Peer($stream); +if (($flags & 512) !== 0) $tmp['saved_from_name'] = $this->deserialize_string($stream); +if (($flags & 1024) !== 0) $tmp['saved_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 64) !== 0) $tmp['psa_type'] = $this->deserialize_string($stream); +return $tmp; } - public function deserialize_type_Object(mixed $stream): mixed - { - return match (stream_get_contents($stream, 4)) { - '犵!' => [ - '_' => 'rpc_error', - 'error_code' => unpack('l', stream_get_contents($stream, 4))[1], - 'error_message' => $this->deserialize_string($stream), - ], - '+r0' => $this->deserialize($stream), - default => self::err($stream) - }; + private function deserialize_type_MessageFwdHeader(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'齊MN' => $this->deserialize_messageFwdHeader($stream), +'+r0' => $this->deserialize_type_MessageFwdHeader($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_PhotoSize(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'<' => [ +'_' => 'photoSizeEmpty', +'type' => $this->deserialize_string($stream), +], +'`ポ' => [ +'_' => 'photoSize', +'type' => $this->deserialize_string($stream), +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'size' => unpack('l', stream_get_contents($stream, 4))[1], +], +'' => [ +'_' => 'photoCachedSize', +'type' => $this->deserialize_string($stream), +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'bytes' => $this->deserialize_bytes($stream), +], +'.摯' => [ +'_' => 'photoStrippedSize', +'type' => $this->deserialize_string($stream), +'inflated' => new Types\Bytes(Tools::inflateStripped($this->deserialize_string($stream))), +], +'>' => [ +'_' => 'photoSizeProgressive', +'type' => $this->deserialize_string($stream), +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'sizes' => self::deserialize_type_array_of_int($stream), +], +'AM!' => [ +'_' => 'photoPathSize', +'type' => $this->deserialize_string($stream), +'bytes' => $this->deserialize_bytes($stream), +], +'馭w' => [ +'_' => 'photoSize', +'type' => $this->deserialize_string($stream), +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'size' => unpack('l', stream_get_contents($stream, 4))[1], +], +'4折' => [ +'_' => 'photoCachedSize', +'type' => $this->deserialize_string($stream), +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'bytes' => $this->deserialize_bytes($stream), +], +'+r0' => $this->deserialize_type_PhotoSize($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_videoSize(mixed $stream): mixed { +$tmp = ['_' => 'videoSize']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['type'] = $this->deserialize_string($stream); +$tmp['w'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['h'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['size'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['video_start_ts'] = unpack('d', stream_get_contents($stream, 8))[1]; + +return $tmp; + } + private function deserialize_type_InputStickerSet(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'+' => [ +'_' => 'inputStickerSetEmpty', +], +'iY' => [ +'_' => 'inputStickerSetID', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +'' => [ +'_' => 'inputStickerSetShortName', +'short_name' => $this->deserialize_string($stream), +], +'' => [ +'_' => 'inputStickerSetAnimatedEmoji', +], +'R' => [ +'_' => 'inputStickerSetDice', +'emoticon' => $this->deserialize_string($stream), +], +'97 ' => [ +'_' => 'inputStickerSetAnimatedEmojiAnimations', +], +';' => [ +'_' => 'inputStickerSetPremiumGifts', +], +'拏' => [ +'_' => 'inputStickerSetEmojiGenericAnimations', +], +'隰)' => [ +'_' => 'inputStickerSetEmojiDefaultStatuses', +], +'澮磺' => [ +'_' => 'inputStickerSetEmojiDefaultTopicIcons', +], +'StI' => [ +'_' => 'inputStickerSetEmojiChannelDefaultStatuses', +], +'+r0' => $this->deserialize_type_InputStickerSet($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_VideoSize(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'3' => $this->deserialize_videoSize($stream), +' [ +'_' => 'videoSizeEmojiMarkup', +'emoji_id' => unpack('q', stream_get_contents($stream, 8))[1], +'background_colors' => self::deserialize_type_array_of_int($stream), +], +' ' => [ +'_' => 'videoSizeStickerMarkup', +'stickerset' => self::deserialize_type_InputStickerSet($stream), +'sticker_id' => unpack('q', stream_get_contents($stream, 8))[1], +'background_colors' => self::deserialize_type_array_of_int($stream), +], +'+r0' => $this->deserialize_type_VideoSize($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_photo(mixed $stream): mixed { +$tmp = ['_' => 'photo']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['has_stickers'] = ($flags & 1) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['file_reference'] = $this->deserialize_bytes($stream); +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['sizes'] = self::deserialize_type_array_of_PhotoSize($stream); +if (($flags & 2) !== 0) $tmp['video_sizes'] = self::deserialize_type_array_of_VideoSize($stream); +$tmp['dc_id'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_Photo(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'-1#' => [ +'_' => 'photoEmpty', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'ez' => $this->deserialize_photo($stream), +'+r0' => $this->deserialize_type_Photo($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageMediaPhoto(mixed $stream): mixed { +$tmp = ['_' => 'messageMediaPhoto']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['spoiler'] = ($flags & 8) !== 0; +if (($flags & 1) !== 0) $tmp['photo'] = self::deserialize_type_Photo($stream); +if (($flags & 4) !== 0) $tmp['ttl_seconds'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_geoPoint(mixed $stream): mixed { +$tmp = ['_' => 'geoPoint']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['long'] = unpack('d', stream_get_contents($stream, 8))[1]; +$tmp['lat'] = unpack('d', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['accuracy_radius'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_GeoPoint(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'_' => [ +'_' => 'geoPointEmpty', +], +'c髍' => $this->deserialize_geoPoint($stream), +'+r0' => $this->deserialize_type_GeoPoint($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_MaskCoords(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'羞眳' => [ +'_' => 'maskCoords', +'n' => unpack('l', stream_get_contents($stream, 4))[1], +'x' => unpack('d', stream_get_contents($stream, 8))[1], +'y' => unpack('d', stream_get_contents($stream, 8))[1], +'zoom' => unpack('d', stream_get_contents($stream, 8))[1], +], +'+r0' => $this->deserialize_type_MaskCoords($stream), +default => self::err($stream) +} +; + } + private static function deserialize_documentAttributeSticker(mixed $stream): mixed { +$tmp = ['_' => 'documentAttributeSticker']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['mask'] = ($flags & 2) !== 0; +$tmp['alt'] = $this->deserialize_string($stream); +$tmp['stickerset'] = self::deserialize_type_InputStickerSet($stream); +if (($flags & 1) !== 0) $tmp['mask_coords'] = self::deserialize_type_MaskCoords($stream); + +return $tmp; + } + private static function deserialize_documentAttributeVideo(mixed $stream): mixed { +$tmp = ['_' => 'documentAttributeVideo']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['round_message'] = ($flags & 1) !== 0; +$tmp['supports_streaming'] = ($flags & 2) !== 0; +$tmp['nosound'] = ($flags & 8) !== 0; +$tmp['duration'] = unpack('d', stream_get_contents($stream, 8))[1]; +$tmp['w'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['h'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 4) !== 0) $tmp['preload_prefix_size'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_documentAttributeAudio(mixed $stream): mixed { +$tmp = ['_' => 'documentAttributeAudio']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['voice'] = ($flags & 1024) !== 0; +$tmp['duration'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['title'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['performer'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['waveform'] = $this->deserialize_waveform($stream); + +return $tmp; + } + private static function deserialize_documentAttributeCustomEmoji(mixed $stream): mixed { +$tmp = ['_' => 'documentAttributeCustomEmoji']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['free'] = ($flags & 1) !== 0; +$tmp['text_color'] = ($flags & 2) !== 0; +$tmp['alt'] = $this->deserialize_string($stream); +$tmp['stickerset'] = self::deserialize_type_InputStickerSet($stream); + +return $tmp; + } + private function deserialize_type_array_of_DocumentAttribute(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'\\7l' => [ +'_' => 'documentAttributeImageSize', +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +], +'9' => [ +'_' => 'documentAttributeAnimated', +], +'c' => $this->deserialize_documentAttributeSticker($stream), +'鎚' => $this->deserialize_documentAttributeVideo($stream), +'アR' => $this->deserialize_documentAttributeAudio($stream), +'h' . "\0" . 'Y' => [ +'_' => 'documentAttributeFilename', +'file_name' => $this->deserialize_string($stream), +], +'壨' => [ +'_' => 'documentAttributeHasStickers', +], +'' => $this->deserialize_documentAttributeCustomEmoji($stream), +'\'W +' => $this->deserialize_documentAttributeSticker($stream), +'佮Y' => $this->deserialize_documentAttributeVideo($stream), +'嘺' => $this->deserialize_documentAttributeAudio($stream), +'cU:' => $this->deserialize_documentAttributeSticker($stream), +'砨' => $this->deserialize_documentAttributeAudio($stream), +',' => $this->deserialize_documentAttributeVideo($stream), +'+r0' => $this->deserialize_type_DocumentAttribute($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_document(mixed $stream): mixed { +$tmp = ['_' => 'document']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['file_reference'] = $this->deserialize_bytes($stream); +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['mime_type'] = $this->deserialize_string($stream); +$tmp['size'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['thumbs'] = self::deserialize_type_array_of_PhotoSize($stream); +if (($flags & 2) !== 0) $tmp['video_thumbs'] = self::deserialize_type_array_of_VideoSize($stream); +$tmp['dc_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['attributes'] = self::deserialize_type_array_of_DocumentAttribute($stream); + +return $tmp; + } + private function deserialize_type_Document(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'q6' => [ +'_' => 'documentEmpty', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'媊' => $this->deserialize_document($stream), +'+r0' => $this->deserialize_type_Document($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageMediaDocument(mixed $stream): mixed { +$tmp = ['_' => 'messageMediaDocument']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['nopremium'] = ($flags & 8) !== 0; +$tmp['spoiler'] = ($flags & 16) !== 0; +$tmp['video'] = ($flags & 64) !== 0; +$tmp['round'] = ($flags & 128) !== 0; +$tmp['voice'] = ($flags & 256) !== 0; +if (($flags & 1) !== 0) $tmp['document'] = self::deserialize_type_Document($stream); +if (($flags & 32) !== 0) $tmp['alt_document'] = self::deserialize_type_Document($stream); +if (($flags & 4) !== 0) $tmp['ttl_seconds'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_webPageEmpty(mixed $stream): mixed { +$tmp = ['_' => 'webPageEmpty']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['url'] = $this->deserialize_string($stream); + +return $tmp; + } + private static function deserialize_webPagePending(mixed $stream): mixed { +$tmp = ['_' => 'webPagePending']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['url'] = $this->deserialize_string($stream); +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_array_of_RichText(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'O=' => [ +'_' => 'textEmpty', +], +'Ft' => [ +'_' => 'textPlain', +'text' => $this->deserialize_string($stream), +], +'蘋$g' => [ +'_' => 'textBold', +'text' => $this->deserialize_type_RichText($stream), +], +'' => [ +'_' => 'textItalic', +'text' => $this->deserialize_type_RichText($stream), +], +'"&' => [ +'_' => 'textUnderline', +'text' => $this->deserialize_type_RichText($stream), +], +'僵' => [ +'_' => 'textStrike', +'text' => $this->deserialize_type_RichText($stream), +], +'?l' => [ +'_' => 'textFixed', +'text' => $this->deserialize_type_RichText($stream), +], +'(<' => [ +'_' => 'textUrl', +'text' => $this->deserialize_type_RichText($stream), +'url' => $this->deserialize_string($stream), +'webpage_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +' Z' => [ +'_' => 'textEmail', +'text' => $this->deserialize_type_RichText($stream), +'email' => $this->deserialize_string($stream), +], +'荴b~' => [ +'_' => 'textConcat', +'texts' => $this->deserialize_type_array_of_RichText($stream), +], +'j' => [ +'_' => 'textSubscript', +'text' => $this->deserialize_type_RichText($stream), +], +'^' => [ +'_' => 'textSuperscript', +'text' => $this->deserialize_type_RichText($stream), +], +'!K' => [ +'_' => 'textMarked', +'text' => $this->deserialize_type_RichText($stream), +], +'j' => [ +'_' => 'textPhone', +'text' => $this->deserialize_type_RichText($stream), +'phone' => $this->deserialize_string($stream), +], +'O' => [ +'_' => 'textImage', +'document_id' => unpack('q', stream_get_contents($stream, 8))[1], +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +], +'b7U5' => [ +'_' => 'textAnchor', +'text' => $this->deserialize_type_RichText($stream), +'name' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_RichText($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_RichText(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'O=' => [ +'_' => 'textEmpty', +], +'Ft' => [ +'_' => 'textPlain', +'text' => $this->deserialize_string($stream), +], +'蘋$g' => [ +'_' => 'textBold', +'text' => $this->deserialize_type_RichText($stream), +], +'' => [ +'_' => 'textItalic', +'text' => $this->deserialize_type_RichText($stream), +], +'"&' => [ +'_' => 'textUnderline', +'text' => $this->deserialize_type_RichText($stream), +], +'僵' => [ +'_' => 'textStrike', +'text' => $this->deserialize_type_RichText($stream), +], +'?l' => [ +'_' => 'textFixed', +'text' => $this->deserialize_type_RichText($stream), +], +'(<' => [ +'_' => 'textUrl', +'text' => $this->deserialize_type_RichText($stream), +'url' => $this->deserialize_string($stream), +'webpage_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +' Z' => [ +'_' => 'textEmail', +'text' => $this->deserialize_type_RichText($stream), +'email' => $this->deserialize_string($stream), +], +'荴b~' => [ +'_' => 'textConcat', +'texts' => self::deserialize_type_array_of_RichText($stream), +], +'j' => [ +'_' => 'textSubscript', +'text' => $this->deserialize_type_RichText($stream), +], +'^' => [ +'_' => 'textSuperscript', +'text' => $this->deserialize_type_RichText($stream), +], +'!K' => [ +'_' => 'textMarked', +'text' => $this->deserialize_type_RichText($stream), +], +'j' => [ +'_' => 'textPhone', +'text' => $this->deserialize_type_RichText($stream), +'phone' => $this->deserialize_string($stream), +], +'O' => [ +'_' => 'textImage', +'document_id' => unpack('q', stream_get_contents($stream, 8))[1], +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +], +'b7U5' => [ +'_' => 'textAnchor', +'text' => $this->deserialize_type_RichText($stream), +'name' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_RichText($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_PageListItem(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'芘/' => [ +'_' => 'pageListItemText', +'text' => self::deserialize_type_RichText($stream), +], +'s%' => [ +'_' => 'pageListItemBlocks', +'blocks' => $this->deserialize_type_array_of_PageBlock($stream), +], +'+r0' => $this->deserialize_type_PageListItem($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_PageCaption(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'Wvto' => [ +'_' => 'pageCaption', +'text' => self::deserialize_type_RichText($stream), +'credit' => self::deserialize_type_RichText($stream), +], +'+r0' => $this->deserialize_type_PageCaption($stream), +default => self::err($stream) +} +; + } + private static function deserialize_pageBlockPhoto(mixed $stream): mixed { +$tmp = ['_' => 'pageBlockPhoto']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['photo_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['caption'] = self::deserialize_type_PageCaption($stream); +if (($flags & 1) !== 0) $tmp['url'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['webpage_id'] = unpack('q', stream_get_contents($stream, 8))[1]; + +return $tmp; + } + private static function deserialize_pageBlockVideo(mixed $stream): mixed { +$tmp = ['_' => 'pageBlockVideo']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['autoplay'] = ($flags & 1) !== 0; +$tmp['loop'] = ($flags & 2) !== 0; +$tmp['video_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['caption'] = self::deserialize_type_PageCaption($stream); + +return $tmp; + } + private static function deserialize_pageBlockEmbed(mixed $stream): mixed { +$tmp = ['_' => 'pageBlockEmbed']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['full_width'] = ($flags & 1) !== 0; +$tmp['allow_scrolling'] = ($flags & 8) !== 0; +if (($flags & 2) !== 0) $tmp['url'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['html'] = $this->deserialize_string($stream); +if (($flags & 16) !== 0) $tmp['poster_photo_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 32) !== 0) $tmp['w'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 32) !== 0) $tmp['h'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['caption'] = self::deserialize_type_PageCaption($stream); + +return $tmp; + } + private static function deserialize_chatPhoto(mixed $stream): mixed { +$tmp = ['_' => 'chatPhoto']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['has_video'] = ($flags & 1) !== 0; +$tmp['photo_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 2) !== 0) $tmp['stripped_thumb'] = $this->deserialize_bytes($stream); +$tmp['dc_id'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_ChatPhoto(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'7' => [ +'_' => 'chatPhotoEmpty', +], +'n' => $this->deserialize_chatPhoto($stream), +'+r0' => $this->deserialize_type_ChatPhoto($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_InputPeer(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +';' => [ +'_' => 'inputPeerEmpty', +], +'氕}' => [ +'_' => 'inputPeerSelf', +], +'鈾\5' => [ +'_' => 'inputPeerChat', +'chat_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'L亥' => [ +'_' => 'inputPeerUser', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +'遞\'' => [ +'_' => 'inputPeerChannel', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +' +{' => [ +'_' => 'inputPeerUserFromMessage', +'peer' => $this->deserialize_type_InputPeer($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'@*' => [ +'_' => 'inputPeerChannelFromMessage', +'peer' => $this->deserialize_type_InputPeer($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'+r0' => $this->deserialize_type_InputPeer($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_InputChannel(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'' => [ +'_' => 'inputChannelEmpty', +], +'(頯' => [ +'_' => 'inputChannel', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +'O[' => [ +'_' => 'inputChannelFromMessage', +'peer' => self::deserialize_type_InputPeer($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'+r0' => $this->deserialize_type_InputChannel($stream), +default => self::err($stream) +} +; + } + private static function deserialize_chatAdminRights(mixed $stream): mixed { +$tmp = ['_' => 'chatAdminRights']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['change_info'] = ($flags & 1) !== 0; +$tmp['post_messages'] = ($flags & 2) !== 0; +$tmp['edit_messages'] = ($flags & 4) !== 0; +$tmp['delete_messages'] = ($flags & 8) !== 0; +$tmp['ban_users'] = ($flags & 16) !== 0; +$tmp['invite_users'] = ($flags & 32) !== 0; +$tmp['pin_messages'] = ($flags & 128) !== 0; +$tmp['add_admins'] = ($flags & 512) !== 0; +$tmp['anonymous'] = ($flags & 1024) !== 0; +$tmp['manage_call'] = ($flags & 2048) !== 0; +$tmp['other'] = ($flags & 4096) !== 0; +$tmp['manage_topics'] = ($flags & 8192) !== 0; +$tmp['post_stories'] = ($flags & 16384) !== 0; +$tmp['edit_stories'] = ($flags & 32768) !== 0; +$tmp['delete_stories'] = ($flags & 65536) !== 0; + +return $tmp; + } + private function deserialize_type_ChatAdminRights(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'$淪' => $this->deserialize_chatAdminRights($stream), +'+r0' => $this->deserialize_type_ChatAdminRights($stream), +default => self::err($stream) +} +; + } + private static function deserialize_chatBannedRights(mixed $stream): mixed { +$tmp = ['_' => 'chatBannedRights']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['view_messages'] = ($flags & 1) !== 0; +$tmp['send_messages'] = ($flags & 2) !== 0; +$tmp['send_media'] = ($flags & 4) !== 0; +$tmp['send_stickers'] = ($flags & 8) !== 0; +$tmp['send_gifs'] = ($flags & 16) !== 0; +$tmp['send_games'] = ($flags & 32) !== 0; +$tmp['send_inline'] = ($flags & 64) !== 0; +$tmp['embed_links'] = ($flags & 128) !== 0; +$tmp['send_polls'] = ($flags & 256) !== 0; +$tmp['change_info'] = ($flags & 1024) !== 0; +$tmp['invite_users'] = ($flags & 32768) !== 0; +$tmp['pin_messages'] = ($flags & 131072) !== 0; +$tmp['manage_topics'] = ($flags & 262144) !== 0; +$tmp['send_photos'] = ($flags & 524288) !== 0; +$tmp['send_videos'] = ($flags & 1048576) !== 0; +$tmp['send_roundvideos'] = ($flags & 2097152) !== 0; +$tmp['send_audios'] = ($flags & 4194304) !== 0; +$tmp['send_voices'] = ($flags & 8388608) !== 0; +$tmp['send_docs'] = ($flags & 16777216) !== 0; +$tmp['send_plain'] = ($flags & 33554432) !== 0; +$tmp['until_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_ChatBannedRights(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'' => $this->deserialize_chatBannedRights($stream), +'+r0' => $this->deserialize_type_ChatBannedRights($stream), +default => self::err($stream) +} +; + } + private static function deserialize_chat(mixed $stream): mixed { +$tmp = ['_' => 'chat']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['creator'] = ($flags & 1) !== 0; +$tmp['left'] = ($flags & 4) !== 0; +$tmp['deactivated'] = ($flags & 32) !== 0; +$tmp['call_active'] = ($flags & 8388608) !== 0; +$tmp['call_not_empty'] = ($flags & 16777216) !== 0; +$tmp['noforwards'] = ($flags & 33554432) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['title'] = $this->deserialize_string($stream); +$tmp['photo'] = self::deserialize_type_ChatPhoto($stream); +$tmp['participants_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['version'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 64) !== 0) $tmp['migrated_to'] = self::deserialize_type_InputChannel($stream); +if (($flags & 16384) !== 0) $tmp['admin_rights'] = self::deserialize_type_ChatAdminRights($stream); +if (($flags & 262144) !== 0) $tmp['default_banned_rights'] = self::deserialize_type_ChatBannedRights($stream); + +return $tmp; + } + private function deserialize_type_array_of_RestrictionReason(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'摒r' => [ +'_' => 'restrictionReason', +'platform' => $this->deserialize_string($stream), +'reason' => $this->deserialize_string($stream), +'text' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_RestrictionReason($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_username(mixed $stream): mixed { +$tmp = ['_' => 'username']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['editable'] = ($flags & 1) !== 0; +$tmp['active'] = ($flags & 2) !== 0; +$tmp['username'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_array_of_Username(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'G6' => $this->deserialize_username($stream), +'+r0' => $this->deserialize_type_Username($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_peerColor(mixed $stream): mixed { +$tmp = ['_' => 'peerColor']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['color'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['background_emoji_id'] = unpack('q', stream_get_contents($stream, 8))[1]; + +return $tmp; + } + private function deserialize_type_PeerColor(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'柌K' => $this->deserialize_peerColor($stream), +'+r0' => $this->deserialize_type_PeerColor($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_EmojiStatus(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'-' => [ +'_' => 'emojiStatusEmpty', +], +'a' => [ +'_' => 'emojiStatus', +'document_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'ヮ0' => [ +'_' => 'emojiStatusUntil', +'document_id' => unpack('q', stream_get_contents($stream, 8))[1], +'until' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_EmojiStatus($stream), +default => self::err($stream) +} +; + } + private static function deserialize_channel(mixed $stream): mixed { +$tmp = ['_' => 'channel']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['creator'] = ($flags & 1) !== 0; +$tmp['left'] = ($flags & 4) !== 0; +$tmp['broadcast'] = ($flags & 32) !== 0; +$tmp['verified'] = ($flags & 128) !== 0; +$tmp['megagroup'] = ($flags & 256) !== 0; +$tmp['restricted'] = ($flags & 512) !== 0; +$tmp['signatures'] = ($flags & 2048) !== 0; +$tmp['min'] = ($flags & 4096) !== 0; +$tmp['scam'] = ($flags & 524288) !== 0; +$tmp['has_link'] = ($flags & 1048576) !== 0; +$tmp['has_geo'] = ($flags & 2097152) !== 0; +$tmp['slowmode_enabled'] = ($flags & 4194304) !== 0; +$tmp['call_active'] = ($flags & 8388608) !== 0; +$tmp['call_not_empty'] = ($flags & 16777216) !== 0; +$tmp['fake'] = ($flags & 33554432) !== 0; +$tmp['gigagroup'] = ($flags & 67108864) !== 0; +$tmp['noforwards'] = ($flags & 134217728) !== 0; +$tmp['join_to_send'] = ($flags & 268435456) !== 0; +$tmp['join_request'] = ($flags & 536870912) !== 0; +$tmp['forum'] = ($flags & 1073741824) !== 0; +$flags2 = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['stories_hidden'] = ($flags2 & 2) !== 0; +$tmp['stories_hidden_min'] = ($flags2 & 4) !== 0; +$tmp['stories_unavailable'] = ($flags2 & 8) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 8192) !== 0) $tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['title'] = $this->deserialize_string($stream); +if (($flags & 64) !== 0) $tmp['username'] = $this->deserialize_string($stream); +$tmp['photo'] = self::deserialize_type_ChatPhoto($stream); +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 512) !== 0) $tmp['restriction_reason'] = self::deserialize_type_array_of_RestrictionReason($stream); +if (($flags & 16384) !== 0) $tmp['admin_rights'] = self::deserialize_type_ChatAdminRights($stream); +if (($flags & 32768) !== 0) $tmp['banned_rights'] = self::deserialize_type_ChatBannedRights($stream); +if (($flags & 262144) !== 0) $tmp['default_banned_rights'] = self::deserialize_type_ChatBannedRights($stream); +if (($flags & 131072) !== 0) $tmp['participants_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags2 & 1) !== 0) $tmp['usernames'] = self::deserialize_type_array_of_Username($stream); +if (($flags2 & 16) !== 0) $tmp['stories_max_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags2 & 128) !== 0) $tmp['color'] = self::deserialize_type_PeerColor($stream); +if (($flags2 & 256) !== 0) $tmp['profile_color'] = self::deserialize_type_PeerColor($stream); +if (($flags2 & 512) !== 0) $tmp['emoji_status'] = self::deserialize_type_EmojiStatus($stream); +if (($flags2 & 1024) !== 0) $tmp['level'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_channelForbidden(mixed $stream): mixed { +$tmp = ['_' => 'channelForbidden']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['broadcast'] = ($flags & 32) !== 0; +$tmp['megagroup'] = ($flags & 256) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['title'] = $this->deserialize_string($stream); +if (($flags & 65536) !== 0) $tmp['until_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_Chat(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'e(V)' => [ +'_' => 'chatEmpty', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'V藨A' => $this->deserialize_chat($stream), +'均e' => [ +'_' => 'chatForbidden', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'title' => $this->deserialize_string($stream), +], +' +' => $this->deserialize_channel($stream), +'' => $this->deserialize_channelForbidden($stream), +'+r0' => $this->deserialize_type_Chat($stream), +default => self::err($stream) +} +; + } + private static function deserialize_pageTableCell(mixed $stream): mixed { +$tmp = ['_' => 'pageTableCell']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['header'] = ($flags & 1) !== 0; +$tmp['align_center'] = ($flags & 8) !== 0; +$tmp['align_right'] = ($flags & 16) !== 0; +$tmp['valign_middle'] = ($flags & 32) !== 0; +$tmp['valign_bottom'] = ($flags & 64) !== 0; +if (($flags & 128) !== 0) $tmp['text'] = self::deserialize_type_RichText($stream); +if (($flags & 2) !== 0) $tmp['colspan'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 4) !== 0) $tmp['rowspan'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_array_of_PageTableCell(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'jkV4' => $this->deserialize_pageTableCell($stream), +'+r0' => $this->deserialize_type_PageTableCell($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_array_of_PageTableRow(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'暩濬' => [ +'_' => 'pageTableRow', +'cells' => self::deserialize_type_array_of_PageTableCell($stream), +], +'+r0' => $this->deserialize_type_PageTableRow($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_pageBlockTable(mixed $stream): mixed { +$tmp = ['_' => 'pageBlockTable']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['bordered'] = ($flags & 1) !== 0; +$tmp['striped'] = ($flags & 2) !== 0; +$tmp['title'] = self::deserialize_type_RichText($stream); +$tmp['rows'] = self::deserialize_type_array_of_PageTableRow($stream); + +return $tmp; + } + private function deserialize_type_array_of_PageListOrderedItem(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'G^' => [ +'_' => 'pageListOrderedItemText', +'num' => $this->deserialize_string($stream), +'text' => self::deserialize_type_RichText($stream), +], +'6' => [ +'_' => 'pageListOrderedItemBlocks', +'num' => $this->deserialize_string($stream), +'blocks' => $this->deserialize_type_array_of_PageBlock($stream), +], +'+r0' => $this->deserialize_type_PageListOrderedItem($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_pageBlockDetails(mixed $stream): mixed { +$tmp = ['_' => 'pageBlockDetails']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['open'] = ($flags & 1) !== 0; +$tmp['blocks'] = $this->deserialize_type_array_of_PageBlock($stream); +$tmp['title'] = self::deserialize_type_RichText($stream); + +return $tmp; + } + private static function deserialize_pageRelatedArticle(mixed $stream): mixed { +$tmp = ['_' => 'pageRelatedArticle']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['url'] = $this->deserialize_string($stream); +$tmp['webpage_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['title'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['description'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['photo_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 8) !== 0) $tmp['author'] = $this->deserialize_string($stream); +if (($flags & 16) !== 0) $tmp['published_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_array_of_PageRelatedArticle(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'' => $this->deserialize_pageRelatedArticle($stream), +'+r0' => $this->deserialize_type_PageRelatedArticle($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_PageBlock(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'~V' => [ +'_' => 'pageBlockUnsupported', +], +'禱p' => [ +'_' => 'pageBlockTitle', +'text' => self::deserialize_type_RichText($stream), +], +'' => [ +'_' => 'pageBlockSubtitle', +'text' => self::deserialize_type_RichText($stream), +], +'馲笑' => [ +'_' => 'pageBlockAuthorDate', +'author' => self::deserialize_type_RichText($stream), +'published_date' => unpack('l', stream_get_contents($stream, 4))[1], +], +'駤郈' => [ +'_' => 'pageBlockHeader', +'text' => self::deserialize_type_RichText($stream), +], +'廑+' => [ +'_' => 'pageBlockSubheader', +'text' => self::deserialize_type_RichText($stream), +], +'fzF' => [ +'_' => 'pageBlockParagraph', +'text' => self::deserialize_type_RichText($stream), +], +'>揗' => [ +'_' => 'pageBlockPreformatted', +'text' => self::deserialize_type_RichText($stream), +'language' => $this->deserialize_string($stream), +], +' H' => [ +'_' => 'pageBlockFooter', +'text' => self::deserialize_type_RichText($stream), +], +' ' => [ +'_' => 'pageBlockDivider', +], +'7 ' => [ +'_' => 'pageBlockAnchor', +'name' => $this->deserialize_string($stream), +], +'鳼' => [ +'_' => 'pageBlockList', +'items' => self::deserialize_type_array_of_PageListItem($stream), +], +'&|=&' => [ +'_' => 'pageBlockBlockquote', +'text' => self::deserialize_type_RichText($stream), +'caption' => self::deserialize_type_RichText($stream), +], +'紓DO' => [ +'_' => 'pageBlockPullquote', +'text' => self::deserialize_type_RichText($stream), +'caption' => self::deserialize_type_RichText($stream), +], +'`驃' => $this->deserialize_pageBlockPhoto($stream), +'嗥|' => $this->deserialize_pageBlockVideo($stream), +'' . "\0" . '39' => [ +'_' => 'pageBlockCover', +'cover' => $this->deserialize_type_PageBlock($stream), +], +'q' => $this->deserialize_pageBlockEmbed($stream), +' 沆' => [ +'_' => 'pageBlockEmbedPost', +'url' => $this->deserialize_string($stream), +'webpage_id' => unpack('q', stream_get_contents($stream, 8))[1], +'author_photo_id' => unpack('q', stream_get_contents($stream, 8))[1], +'author' => $this->deserialize_string($stream), +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'blocks' => $this->deserialize_type_array_of_PageBlock($stream), +'caption' => self::deserialize_type_PageCaption($stream), +], +'Me' => [ +'_' => 'pageBlockCollage', +'items' => $this->deserialize_type_array_of_PageBlock($stream), +'caption' => self::deserialize_type_PageCaption($stream), +], +'' => [ +'_' => 'pageBlockSlideshow', +'items' => $this->deserialize_type_array_of_PageBlock($stream), +'caption' => self::deserialize_type_PageCaption($stream), +], +'犄' => [ +'_' => 'pageBlockChannel', +'channel' => self::deserialize_type_Chat($stream), +], +'獪C' => [ +'_' => 'pageBlockAudio', +'audio_id' => unpack('q', stream_get_contents($stream, 8))[1], +'caption' => self::deserialize_type_PageCaption($stream), +], +'' => [ +'_' => 'pageBlockKicker', +'text' => self::deserialize_type_RichText($stream), +], +'燁' => $this->deserialize_pageBlockTable($stream), +'摽' => [ +'_' => 'pageBlockOrderedList', +'items' => self::deserialize_type_array_of_PageListOrderedItem($stream), +], +'vv' => $this->deserialize_pageBlockDetails($stream), +'Z' => [ +'_' => 'pageBlockRelatedArticles', +'title' => self::deserialize_type_RichText($stream), +'articles' => self::deserialize_type_array_of_PageRelatedArticle($stream), +], +'>O' => [ +'_' => 'pageBlockMap', +'geo' => self::deserialize_type_GeoPoint($stream), +'zoom' => unpack('l', stream_get_contents($stream, 4))[1], +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'caption' => self::deserialize_type_PageCaption($stream), +], +'+r0' => $this->deserialize_type_PageBlock($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_PageBlock(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'~V' => [ +'_' => 'pageBlockUnsupported', +], +'禱p' => [ +'_' => 'pageBlockTitle', +'text' => self::deserialize_type_RichText($stream), +], +'' => [ +'_' => 'pageBlockSubtitle', +'text' => self::deserialize_type_RichText($stream), +], +'馲笑' => [ +'_' => 'pageBlockAuthorDate', +'author' => self::deserialize_type_RichText($stream), +'published_date' => unpack('l', stream_get_contents($stream, 4))[1], +], +'駤郈' => [ +'_' => 'pageBlockHeader', +'text' => self::deserialize_type_RichText($stream), +], +'廑+' => [ +'_' => 'pageBlockSubheader', +'text' => self::deserialize_type_RichText($stream), +], +'fzF' => [ +'_' => 'pageBlockParagraph', +'text' => self::deserialize_type_RichText($stream), +], +'>揗' => [ +'_' => 'pageBlockPreformatted', +'text' => self::deserialize_type_RichText($stream), +'language' => $this->deserialize_string($stream), +], +' H' => [ +'_' => 'pageBlockFooter', +'text' => self::deserialize_type_RichText($stream), +], +' ' => [ +'_' => 'pageBlockDivider', +], +'7 ' => [ +'_' => 'pageBlockAnchor', +'name' => $this->deserialize_string($stream), +], +'鳼' => [ +'_' => 'pageBlockList', +'items' => self::deserialize_type_array_of_PageListItem($stream), +], +'&|=&' => [ +'_' => 'pageBlockBlockquote', +'text' => self::deserialize_type_RichText($stream), +'caption' => self::deserialize_type_RichText($stream), +], +'紓DO' => [ +'_' => 'pageBlockPullquote', +'text' => self::deserialize_type_RichText($stream), +'caption' => self::deserialize_type_RichText($stream), +], +'`驃' => $this->deserialize_pageBlockPhoto($stream), +'嗥|' => $this->deserialize_pageBlockVideo($stream), +'' . "\0" . '39' => [ +'_' => 'pageBlockCover', +'cover' => self::deserialize_type_PageBlock($stream), +], +'q' => $this->deserialize_pageBlockEmbed($stream), +' 沆' => [ +'_' => 'pageBlockEmbedPost', +'url' => $this->deserialize_string($stream), +'webpage_id' => unpack('q', stream_get_contents($stream, 8))[1], +'author_photo_id' => unpack('q', stream_get_contents($stream, 8))[1], +'author' => $this->deserialize_string($stream), +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'blocks' => $this->deserialize_type_array_of_PageBlock($stream), +'caption' => self::deserialize_type_PageCaption($stream), +], +'Me' => [ +'_' => 'pageBlockCollage', +'items' => $this->deserialize_type_array_of_PageBlock($stream), +'caption' => self::deserialize_type_PageCaption($stream), +], +'' => [ +'_' => 'pageBlockSlideshow', +'items' => $this->deserialize_type_array_of_PageBlock($stream), +'caption' => self::deserialize_type_PageCaption($stream), +], +'犄' => [ +'_' => 'pageBlockChannel', +'channel' => self::deserialize_type_Chat($stream), +], +'獪C' => [ +'_' => 'pageBlockAudio', +'audio_id' => unpack('q', stream_get_contents($stream, 8))[1], +'caption' => self::deserialize_type_PageCaption($stream), +], +'' => [ +'_' => 'pageBlockKicker', +'text' => self::deserialize_type_RichText($stream), +], +'燁' => $this->deserialize_pageBlockTable($stream), +'摽' => [ +'_' => 'pageBlockOrderedList', +'items' => self::deserialize_type_array_of_PageListOrderedItem($stream), +], +'vv' => $this->deserialize_pageBlockDetails($stream), +'Z' => [ +'_' => 'pageBlockRelatedArticles', +'title' => self::deserialize_type_RichText($stream), +'articles' => self::deserialize_type_array_of_PageRelatedArticle($stream), +], +'>O' => [ +'_' => 'pageBlockMap', +'geo' => self::deserialize_type_GeoPoint($stream), +'zoom' => unpack('l', stream_get_contents($stream, 4))[1], +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'caption' => self::deserialize_type_PageCaption($stream), +], +'+r0' => self::deserialize_type_PageBlock($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_array_of_Photo(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'-1#' => [ +'_' => 'photoEmpty', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'ez' => $this->deserialize_photo($stream), +'+r0' => self::deserialize_type_Photo($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_array_of_Document(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'q6' => [ +'_' => 'documentEmpty', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'媊' => $this->deserialize_document($stream), +'+r0' => self::deserialize_type_Document($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_page(mixed $stream): mixed { +$tmp = ['_' => 'page']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['part'] = ($flags & 1) !== 0; +$tmp['rtl'] = ($flags & 2) !== 0; +$tmp['v2'] = ($flags & 4) !== 0; +$tmp['url'] = $this->deserialize_string($stream); +$tmp['blocks'] = self::deserialize_type_array_of_PageBlock($stream); +$tmp['photos'] = self::deserialize_type_array_of_Photo($stream); +$tmp['documents'] = self::deserialize_type_array_of_Document($stream); +if (($flags & 8) !== 0) $tmp['views'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_Page(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' e' => $this->deserialize_page($stream), +'+r0' => $this->deserialize_type_Page($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_BaseTheme(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'b$ ̄' => [ +'_' => 'baseThemeClassic', +], +'惢' => [ +'_' => 'baseThemeDay', +], +'雪' => [ +'_' => 'baseThemeNight', +], +'褷_m' => [ +'_' => 'baseThemeTinted', +], +'Z[' => [ +'_' => 'baseThemeArctic', +], +'+r0' => $this->deserialize_type_BaseTheme($stream), +default => self::err($stream) +} +; + } + private static function deserialize_wallPaperSettings(mixed $stream): mixed { +$tmp = ['_' => 'wallPaperSettings']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['blur'] = ($flags & 2) !== 0; +$tmp['motion'] = ($flags & 4) !== 0; +if (($flags & 1) !== 0) $tmp['background_color'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 16) !== 0) $tmp['second_background_color'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 32) !== 0) $tmp['third_background_color'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 64) !== 0) $tmp['fourth_background_color'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['intensity'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 16) !== 0) $tmp['rotation'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 128) !== 0) $tmp['emoticon'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_WallPaperSettings(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'唑.7' => $this->deserialize_wallPaperSettings($stream), +'+r0' => $this->deserialize_type_WallPaperSettings($stream), +default => self::err($stream) +} +; + } + private static function deserialize_wallPaper(mixed $stream): mixed { +$tmp = ['_' => 'wallPaper']; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['creator'] = ($flags & 1) !== 0; +$tmp['default'] = ($flags & 2) !== 0; +$tmp['pattern'] = ($flags & 8) !== 0; +$tmp['dark'] = ($flags & 16) !== 0; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['slug'] = $this->deserialize_string($stream); +$tmp['document'] = self::deserialize_type_Document($stream); +if (($flags & 4) !== 0) $tmp['settings'] = self::deserialize_type_WallPaperSettings($stream); + +return $tmp; + } + private static function deserialize_wallPaperNoFile(mixed $stream): mixed { +$tmp = ['_' => 'wallPaperNoFile']; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['default'] = ($flags & 2) !== 0; +$tmp['dark'] = ($flags & 16) !== 0; +if (($flags & 4) !== 0) $tmp['settings'] = self::deserialize_type_WallPaperSettings($stream); + +return $tmp; + } + private function deserialize_type_WallPaper(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'篳7' => $this->deserialize_wallPaper($stream), +'A' => $this->deserialize_wallPaperNoFile($stream), +'+r0' => $this->deserialize_type_WallPaper($stream), +default => self::err($stream) +} +; + } + private static function deserialize_themeSettings(mixed $stream): mixed { +$tmp = ['_' => 'themeSettings']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['message_colors_animated'] = ($flags & 4) !== 0; +$tmp['base_theme'] = self::deserialize_type_BaseTheme($stream); +$tmp['accent_color'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['outbox_accent_color'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['message_colors'] = self::deserialize_type_array_of_int($stream); +if (($flags & 2) !== 0) $tmp['wallpaper'] = self::deserialize_type_WallPaper($stream); + +return $tmp; + } + private function deserialize_type_ThemeSettings(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'堈X' => $this->deserialize_themeSettings($stream), +'+r0' => $this->deserialize_type_ThemeSettings($stream), +default => self::err($stream) +} +; + } + private static function deserialize_webPageAttributeTheme(mixed $stream): mixed { +$tmp = ['_' => 'webPageAttributeTheme']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['documents'] = self::deserialize_type_array_of_Document($stream); +if (($flags & 2) !== 0) $tmp['settings'] = self::deserialize_type_ThemeSettings($stream); + +return $tmp; + } + private static function deserialize_storyItemSkipped(mixed $stream): mixed { +$tmp = ['_' => 'storyItemSkipped']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['close_friends'] = ($flags & 256) !== 0; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['expire_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_storyFwdHeader(mixed $stream): mixed { +$tmp = ['_' => 'storyFwdHeader']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['modified'] = ($flags & 8) !== 0; +if (($flags & 1) !== 0) $tmp['from'] = self::deserialize_type_Peer($stream); +if (($flags & 2) !== 0) $tmp['from_name'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['story_id'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_StoryFwdHeader(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'P&' => $this->deserialize_storyFwdHeader($stream), +'+r0' => $this->deserialize_type_StoryFwdHeader($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_InputUser(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'' => [ +'_' => 'inputUserEmpty', +], +'?掄' => [ +'_' => 'inputUserSelf', +], +'籬' => [ +'_' => 'inputUser', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +'榎' => [ +'_' => 'inputUserFromMessage', +'peer' => self::deserialize_type_InputPeer($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'+r0' => $this->deserialize_type_InputUser($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_MessageEntity(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'' => [ +'_' => 'messageEntityUnknown', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'W' => [ +'_' => 'messageEntityMention', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +' [co' => [ +'_' => 'messageEntityHashtag', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'鮞' => [ +'_' => 'messageEntityBotCommand', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'8%茇' => [ +'_' => 'messageEntityUrl', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'燼輐' => [ +'_' => 'messageEntityEmail', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +' a' => [ +'_' => 'messageEntityBold', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'`o' => [ +'_' => 'messageEntityItalic', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'q(' => [ +'_' => 'messageEntityCode', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'誂s' => [ +'_' => 'messageEntityPre', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +'language' => $this->deserialize_string($stream), +], +'\'茼v' => [ +'_' => 'messageEntityTextUrl', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +'url' => $this->deserialize_string($stream), +], +'@{' => [ +'_' => 'messageEntityMentionName', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'仡 ' => [ +'_' => 'inputMessageEntityMentionName', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +'user_id' => self::deserialize_type_InputUser($stream), +], +'K緅' => [ +'_' => 'messageEntityPhone', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'?tNL' => [ +'_' => 'messageEntityCashtag', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'~N' => [ +'_' => 'messageEntityUnderline', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'' => [ +'_' => 'messageEntityStrike', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'爓v' => [ +'_' => 'messageEntityBankCard', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'2' => [ +'_' => 'messageEntitySpoiler', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'珂' => [ +'_' => 'messageEntityCustomEmoji', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +'document_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'哳 ' => [ +'_' => 'messageEntityBlockquote', +'offset' => unpack('l', stream_get_contents($stream, 4))[1], +'length' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_MessageEntity($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_MediaAreaCoordinates(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'N縠' => [ +'_' => 'mediaAreaCoordinates', +'x' => unpack('d', stream_get_contents($stream, 8))[1], +'y' => unpack('d', stream_get_contents($stream, 8))[1], +'w' => unpack('d', stream_get_contents($stream, 8))[1], +'h' => unpack('d', stream_get_contents($stream, 8))[1], +'rotation' => unpack('d', stream_get_contents($stream, 8))[1], +], +'+r0' => $this->deserialize_type_MediaAreaCoordinates($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_Reaction(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'崋y' => [ +'_' => 'reactionEmpty', +], +'"' => [ +'_' => 'reactionEmoji', +'emoticon' => $this->deserialize_string($stream), +], +'s5' => [ +'_' => 'reactionCustomEmoji', +'document_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'+r0' => $this->deserialize_type_Reaction($stream), +default => self::err($stream) +} +; + } + private static function deserialize_mediaAreaSuggestedReaction(mixed $stream): mixed { +$tmp = ['_' => 'mediaAreaSuggestedReaction']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['dark'] = ($flags & 1) !== 0; +$tmp['flipped'] = ($flags & 2) !== 0; +$tmp['coordinates'] = self::deserialize_type_MediaAreaCoordinates($stream); +$tmp['reaction'] = self::deserialize_type_Reaction($stream); + +return $tmp; + } + private function deserialize_type_array_of_MediaArea(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'' => [ +'_' => 'mediaAreaVenue', +'coordinates' => self::deserialize_type_MediaAreaCoordinates($stream), +'geo' => self::deserialize_type_GeoPoint($stream), +'title' => $this->deserialize_string($stream), +'address' => $this->deserialize_string($stream), +'provider' => $this->deserialize_string($stream), +'venue_id' => $this->deserialize_string($stream), +'venue_type' => $this->deserialize_string($stream), +], +'!' => [ +'_' => 'inputMediaAreaVenue', +'coordinates' => self::deserialize_type_MediaAreaCoordinates($stream), +'query_id' => unpack('q', stream_get_contents($stream, 8))[1], +'result_id' => $this->deserialize_string($stream), +], +'";' => [ +'_' => 'mediaAreaGeoPoint', +'coordinates' => self::deserialize_type_MediaAreaCoordinates($stream), +'geo' => self::deserialize_type_GeoPoint($stream), +], +'qXE' => $this->deserialize_mediaAreaSuggestedReaction($stream), +'w' => [ +'_' => 'mediaAreaChannelPost', +'coordinates' => self::deserialize_type_MediaAreaCoordinates($stream), +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'遺q"' => [ +'_' => 'inputMediaAreaChannelPost', +'coordinates' => self::deserialize_type_MediaAreaCoordinates($stream), +'channel' => self::deserialize_type_InputChannel($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_MediaArea($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_array_of_PrivacyRule(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'' => [ +'_' => 'privacyValueAllowContacts', +], +'{Be' => [ +'_' => 'privacyValueAllowAll', +], +'淪' => [ +'_' => 'privacyValueAllowUsers', +'users' => self::deserialize_type_array_of_long($stream), +], +'' => [ +'_' => 'privacyValueDisallowContacts', +], +'c蓧' => [ +'_' => 'privacyValueDisallowAll', +], +'Ab' => [ +'_' => 'privacyValueDisallowUsers', +'users' => self::deserialize_type_array_of_long($stream), +], +'Nk' => [ +'_' => 'privacyValueAllowChatParticipants', +'chats' => self::deserialize_type_array_of_long($stream), +], +'euA' => [ +'_' => 'privacyValueDisallowChatParticipants', +'chats' => self::deserialize_type_array_of_long($stream), +], +'嵙' => [ +'_' => 'privacyValueAllowCloseFriends', +], +'+r0' => $this->deserialize_type_PrivacyRule($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_reactionCount(mixed $stream): mixed { +$tmp = ['_' => 'reactionCount']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['chosen_order'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['reaction'] = self::deserialize_type_Reaction($stream); +$tmp['count'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_array_of_ReactionCount(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'刲' => $this->deserialize_reactionCount($stream), +'+r0' => $this->deserialize_type_ReactionCount($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_storyViews(mixed $stream): mixed { +$tmp = ['_' => 'storyViews']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['has_viewers'] = ($flags & 2) !== 0; +$tmp['views_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 4) !== 0) $tmp['forwards_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['reactions'] = self::deserialize_type_array_of_ReactionCount($stream); +if (($flags & 16) !== 0) $tmp['reactions_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['recent_viewers'] = self::deserialize_type_array_of_long($stream); + +return $tmp; + } + private function deserialize_type_StoryViews(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'牾\Y' => $this->deserialize_storyViews($stream), +'+r0' => $this->deserialize_type_StoryViews($stream), +default => self::err($stream) +} +; + } + private static function deserialize_storyItem(mixed $stream): mixed { +$tmp = ['_' => 'storyItem']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['pinned'] = ($flags & 32) !== 0; +$tmp['public'] = ($flags & 128) !== 0; +$tmp['close_friends'] = ($flags & 256) !== 0; +$tmp['min'] = ($flags & 512) !== 0; +$tmp['noforwards'] = ($flags & 1024) !== 0; +$tmp['edited'] = ($flags & 2048) !== 0; +$tmp['contacts'] = ($flags & 4096) !== 0; +$tmp['selected_contacts'] = ($flags & 8192) !== 0; +$tmp['out'] = ($flags & 65536) !== 0; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 262144) !== 0) $tmp['from_id'] = self::deserialize_type_Peer($stream); +if (($flags & 131072) !== 0) $tmp['fwd_from'] = self::deserialize_type_StoryFwdHeader($stream); +$tmp['expire_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['caption'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['entities'] = self::deserialize_type_array_of_MessageEntity($stream); +$tmp['media'] = $this->deserialize_type_MessageMedia($stream); +if (($flags & 16384) !== 0) $tmp['media_areas'] = self::deserialize_type_array_of_MediaArea($stream); +if (($flags & 4) !== 0) $tmp['privacy'] = self::deserialize_type_array_of_PrivacyRule($stream); +if (($flags & 8) !== 0) $tmp['views'] = self::deserialize_type_StoryViews($stream); +if (($flags & 32768) !== 0) $tmp['sent_reaction'] = self::deserialize_type_Reaction($stream); + +return $tmp; + } + private function deserialize_type_StoryItem(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'O鍻Q' => [ +'_' => 'storyItemDeleted', +'id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'伬' => $this->deserialize_storyItemSkipped($stream), +'$j球' => $this->deserialize_storyItem($stream), +'+r0' => $this->deserialize_type_StoryItem($stream), +default => self::err($stream) +} +; + } + private static function deserialize_webPageAttributeStory(mixed $stream): mixed { +$tmp = ['_' => 'webPageAttributeStory']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['peer'] = self::deserialize_type_Peer($stream); +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['story'] = self::deserialize_type_StoryItem($stream); + +return $tmp; + } + private function deserialize_type_array_of_WebPageAttribute(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'f猥' => $this->deserialize_webPageAttributeTheme($stream), +'褌.' => $this->deserialize_webPageAttributeStory($stream), +'+r0' => $this->deserialize_type_WebPageAttribute($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_webPage(mixed $stream): mixed { +$tmp = ['_' => 'webPage']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['has_large_media'] = ($flags & 8192) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['url'] = $this->deserialize_string($stream); +$tmp['display_url'] = $this->deserialize_string($stream); +$tmp['hash'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['type'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['site_name'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['title'] = $this->deserialize_string($stream); +if (($flags & 8) !== 0) $tmp['description'] = $this->deserialize_string($stream); +if (($flags & 16) !== 0) $tmp['photo'] = self::deserialize_type_Photo($stream); +if (($flags & 32) !== 0) $tmp['embed_url'] = $this->deserialize_string($stream); +if (($flags & 32) !== 0) $tmp['embed_type'] = $this->deserialize_string($stream); +if (($flags & 64) !== 0) $tmp['embed_width'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 64) !== 0) $tmp['embed_height'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 128) !== 0) $tmp['duration'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 256) !== 0) $tmp['author'] = $this->deserialize_string($stream); +if (($flags & 512) !== 0) $tmp['document'] = self::deserialize_type_Document($stream); +if (($flags & 1024) !== 0) $tmp['cached_page'] = self::deserialize_type_Page($stream); +if (($flags & 4096) !== 0) $tmp['attributes'] = self::deserialize_type_array_of_WebPageAttribute($stream); + +return $tmp; + } + private static function deserialize_webPageNotModified(mixed $stream): mixed { +$tmp = ['_' => 'webPageNotModified']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['cached_page_views'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_WebPage(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'!' => $this->deserialize_webPageEmpty($stream), +'G>扆' => $this->deserialize_webPagePending($stream), +'淳' => $this->deserialize_webPage($stream), +'s' => $this->deserialize_webPageNotModified($stream), +'+r0' => $this->deserialize_type_WebPage($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageMediaWebPage(mixed $stream): mixed { +$tmp = ['_' => 'messageMediaWebPage']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['force_large_media'] = ($flags & 1) !== 0; +$tmp['force_small_media'] = ($flags & 2) !== 0; +$tmp['manual'] = ($flags & 8) !== 0; +$tmp['safe'] = ($flags & 16) !== 0; +$tmp['webpage'] = self::deserialize_type_WebPage($stream); + +return $tmp; + } + private static function deserialize_game(mixed $stream): mixed { +$tmp = ['_' => 'game']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['short_name'] = $this->deserialize_string($stream); +$tmp['title'] = $this->deserialize_string($stream); +$tmp['description'] = $this->deserialize_string($stream); +$tmp['photo'] = self::deserialize_type_Photo($stream); +if (($flags & 1) !== 0) $tmp['document'] = self::deserialize_type_Document($stream); + +return $tmp; + } + private function deserialize_type_Game(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +';e虌' => $this->deserialize_game($stream), +'+r0' => $this->deserialize_type_Game($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_WebDocument(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'W' => [ +'_' => 'webDocument', +'url' => $this->deserialize_string($stream), +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +'size' => unpack('l', stream_get_contents($stream, 4))[1], +'mime_type' => $this->deserialize_string($stream), +'attributes' => self::deserialize_type_array_of_DocumentAttribute($stream), +], +'じ' => [ +'_' => 'webDocumentNoProxy', +'url' => $this->deserialize_string($stream), +'size' => unpack('l', stream_get_contents($stream, 4))[1], +'mime_type' => $this->deserialize_string($stream), +'attributes' => self::deserialize_type_array_of_DocumentAttribute($stream), +], +'+r0' => $this->deserialize_type_WebDocument($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_PhotoSize(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'<' => [ +'_' => 'photoSizeEmpty', +'type' => $this->deserialize_string($stream), +], +'`ポ' => [ +'_' => 'photoSize', +'type' => $this->deserialize_string($stream), +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'size' => unpack('l', stream_get_contents($stream, 4))[1], +], +'' => [ +'_' => 'photoCachedSize', +'type' => $this->deserialize_string($stream), +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'bytes' => $this->deserialize_bytes($stream), +], +'.摯' => [ +'_' => 'photoStrippedSize', +'type' => $this->deserialize_string($stream), +'inflated' => new Types\Bytes(Tools::inflateStripped($this->deserialize_string($stream))), +], +'>' => [ +'_' => 'photoSizeProgressive', +'type' => $this->deserialize_string($stream), +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'sizes' => self::deserialize_type_array_of_int($stream), +], +'AM!' => [ +'_' => 'photoPathSize', +'type' => $this->deserialize_string($stream), +'bytes' => $this->deserialize_bytes($stream), +], +'馭w' => [ +'_' => 'photoSize', +'type' => $this->deserialize_string($stream), +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'size' => unpack('l', stream_get_contents($stream, 4))[1], +], +'4折' => [ +'_' => 'photoCachedSize', +'type' => $this->deserialize_string($stream), +'w' => unpack('l', stream_get_contents($stream, 4))[1], +'h' => unpack('l', stream_get_contents($stream, 4))[1], +'bytes' => $this->deserialize_bytes($stream), +], +'+r0' => $this->deserialize_type_PhotoSize($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageExtendedMediaPreview(mixed $stream): mixed { +$tmp = ['_' => 'messageExtendedMediaPreview']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['w'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['h'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['thumb'] = self::deserialize_type_PhotoSize($stream); +if (($flags & 4) !== 0) $tmp['video_duration'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_MessageExtendedMedia(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'b' => $this->deserialize_messageExtendedMediaPreview($stream), +'dG' => [ +'_' => 'messageExtendedMedia', +'media' => $this->deserialize_type_MessageMedia($stream), +], +'+r0' => $this->deserialize_type_MessageExtendedMedia($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageMediaInvoice(mixed $stream): mixed { +$tmp = ['_' => 'messageMediaInvoice']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['shipping_address_requested'] = ($flags & 2) !== 0; +$tmp['test'] = ($flags & 8) !== 0; +$tmp['title'] = $this->deserialize_string($stream); +$tmp['description'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['photo'] = self::deserialize_type_WebDocument($stream); +if (($flags & 4) !== 0) $tmp['receipt_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['currency'] = $this->deserialize_string($stream); +$tmp['total_amount'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['start_param'] = $this->deserialize_string($stream); +if (($flags & 16) !== 0) $tmp['extended_media'] = self::deserialize_type_MessageExtendedMedia($stream); + +return $tmp; + } + private static function deserialize_messageMediaGeoLive(mixed $stream): mixed { +$tmp = ['_' => 'messageMediaGeoLive']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['geo'] = self::deserialize_type_GeoPoint($stream); +if (($flags & 1) !== 0) $tmp['heading'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['period'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['proximity_notification_radius'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_array_of_PollAnswer(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'樲始' => [ +'_' => 'pollAnswer', +'text' => $this->deserialize_string($stream), +'option' => $this->deserialize_bytes($stream), +], +'+r0' => $this->deserialize_type_PollAnswer($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_poll(mixed $stream): mixed { +$tmp = ['_' => 'poll']; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['closed'] = ($flags & 1) !== 0; +$tmp['public_voters'] = ($flags & 2) !== 0; +$tmp['multiple_choice'] = ($flags & 4) !== 0; +$tmp['quiz'] = ($flags & 8) !== 0; +$tmp['question'] = $this->deserialize_string($stream); +$tmp['answers'] = self::deserialize_type_array_of_PollAnswer($stream); +if (($flags & 16) !== 0) $tmp['close_period'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 32) !== 0) $tmp['close_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_Poll(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'a' => $this->deserialize_poll($stream), +'+r0' => $this->deserialize_type_Poll($stream), +default => self::err($stream) +} +; + } + private static function deserialize_pollAnswerVoters(mixed $stream): mixed { +$tmp = ['_' => 'pollAnswerVoters']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['chosen'] = ($flags & 1) !== 0; +$tmp['correct'] = ($flags & 2) !== 0; +$tmp['option'] = $this->deserialize_bytes($stream); +$tmp['voters'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_array_of_PollAnswerVoters(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'砬m;' => $this->deserialize_pollAnswerVoters($stream), +'+r0' => $this->deserialize_type_PollAnswerVoters($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_array_of_Peer(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'"QY' => unpack('q', stream_get_contents($stream, 8))[1], +'6' => -unpack('q', stream_get_contents($stream, 8))[1], +'7失' => -1000000000000 - unpack('q', stream_get_contents($stream, 8))[1], +'+r0' => self::deserialize_type_Peer($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_pollResults(mixed $stream): mixed { +$tmp = ['_' => 'pollResults']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['min'] = ($flags & 1) !== 0; +if (($flags & 2) !== 0) $tmp['results'] = self::deserialize_type_array_of_PollAnswerVoters($stream); +if (($flags & 4) !== 0) $tmp['total_voters'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['recent_voters'] = self::deserialize_type_array_of_Peer($stream); +if (($flags & 16) !== 0) $tmp['solution'] = $this->deserialize_string($stream); +if (($flags & 16) !== 0) $tmp['solution_entities'] = self::deserialize_type_array_of_MessageEntity($stream); + +return $tmp; + } + private function deserialize_type_PollResults(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' $朡' => $this->deserialize_pollResults($stream), +'+r0' => $this->deserialize_type_PollResults($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageMediaStory(mixed $stream): mixed { +$tmp = ['_' => 'messageMediaStory']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['via_mention'] = ($flags & 2) !== 0; +$tmp['peer'] = self::deserialize_type_Peer($stream); +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['story'] = self::deserialize_type_StoryItem($stream); + +return $tmp; + } + private static function deserialize_messageMediaGiveaway(mixed $stream): mixed { +$tmp = ['_' => 'messageMediaGiveaway']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['only_new_subscribers'] = ($flags & 1) !== 0; +$tmp['winners_are_visible'] = ($flags & 4) !== 0; +$tmp['channels'] = self::deserialize_type_array_of_long($stream); +if (($flags & 2) !== 0) $tmp['countries_iso2'] = self::deserialize_type_array_of_string($stream); +if (($flags & 8) !== 0) $tmp['prize_description'] = $this->deserialize_string($stream); +$tmp['quantity'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['months'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['until_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_messageMediaGiveawayResults(mixed $stream): mixed { +$tmp = ['_' => 'messageMediaGiveawayResults']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['only_new_subscribers'] = ($flags & 1) !== 0; +$tmp['refunded'] = ($flags & 4) !== 0; +$tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 8) !== 0) $tmp['additional_peers_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['launch_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['winners_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['unclaimed_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['winners'] = self::deserialize_type_array_of_long($stream); +$tmp['months'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['prize_description'] = $this->deserialize_string($stream); +$tmp['until_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_MessageMedia(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' c=' => [ +'_' => 'messageMediaEmpty', +], +'脝Qi' => $this->deserialize_messageMediaPhoto($stream), +'t婄V' => [ +'_' => 'messageMediaGeo', +'geo' => self::deserialize_type_GeoPoint($stream), +], +'I)2p' => [ +'_' => 'messageMediaContact', +'phone_number' => $this->deserialize_string($stream), +'first_name' => $this->deserialize_string($stream), +'last_name' => $this->deserialize_string($stream), +'vcard' => $this->deserialize_string($stream), +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'' => [ +'_' => 'messageMediaUnsupported', +], +'-酚L' => $this->deserialize_messageMediaDocument($stream), +'; 鵚' => $this->deserialize_messageMediaWebPage($stream), +'?S.' => [ +'_' => 'messageMediaVenue', +'geo' => self::deserialize_type_GeoPoint($stream), +'title' => $this->deserialize_string($stream), +'address' => $this->deserialize_string($stream), +'provider' => $this->deserialize_string($stream), +'venue_id' => $this->deserialize_string($stream), +'venue_type' => $this->deserialize_string($stream), +], +'欲' => [ +'_' => 'messageMediaGame', +'game' => self::deserialize_type_Game($stream), +], +'笒仳' => $this->deserialize_messageMediaInvoice($stream), +'f讖' => $this->deserialize_messageMediaGeoLive($stream), +'誸K' => [ +'_' => 'messageMediaPoll', +'poll' => self::deserialize_type_Poll($stream), +'results' => self::deserialize_type_PollResults($stream), +], +'憉?' => [ +'_' => 'messageMediaDice', +'value' => unpack('l', stream_get_contents($stream, 4))[1], +'emoticon' => $this->deserialize_string($stream), +], +'b玕' => $this->deserialize_messageMediaStory($stream), +'俾' => $this->deserialize_messageMediaGiveaway($stream), +'h' => $this->deserialize_messageMediaGiveawayResults($stream), +'+r0' => $this->deserialize_type_MessageMedia($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageReplyHeader(mixed $stream): mixed { +$tmp = ['_' => 'messageReplyHeader']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['reply_to_scheduled'] = ($flags & 4) !== 0; +$tmp['forum_topic'] = ($flags & 8) !== 0; +$tmp['quote'] = ($flags & 512) !== 0; +if (($flags & 16) !== 0) $tmp['reply_to_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['reply_to_peer_id'] = self::deserialize_type_Peer($stream); +if (($flags & 32) !== 0) $tmp['reply_from'] = self::deserialize_type_MessageFwdHeader($stream); +if (($flags & 256) !== 0) $tmp['reply_media'] = self::deserialize_type_MessageMedia($stream); +if (($flags & 2) !== 0) $tmp['reply_to_top_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 64) !== 0) $tmp['quote_text'] = $this->deserialize_string($stream); +if (($flags & 128) !== 0) $tmp['quote_entities'] = self::deserialize_type_array_of_MessageEntity($stream); +if (($flags & 1024) !== 0) $tmp['quote_offset'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_MessageReplyHeader(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' 摩' => $this->deserialize_messageReplyHeader($stream), +'9鱨' => [ +'_' => 'messageReplyStoryHeader', +'peer' => self::deserialize_type_Peer($stream), +'story_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_MessageReplyHeader($stream), +default => self::err($stream) +} +; + } + private static function deserialize_replyKeyboardHide(mixed $stream): mixed { +$tmp = ['_' => 'replyKeyboardHide']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['selective'] = ($flags & 4) !== 0; + +return $tmp; + } + private static function deserialize_replyKeyboardForceReply(mixed $stream): mixed { +$tmp = ['_' => 'replyKeyboardForceReply']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['single_use'] = ($flags & 2) !== 0; +$tmp['selective'] = ($flags & 4) !== 0; +if (($flags & 8) !== 0) $tmp['placeholder'] = $this->deserialize_string($stream); + +return $tmp; + } + private static function deserialize_keyboardButtonCallback(mixed $stream): mixed { +$tmp = ['_' => 'keyboardButtonCallback']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['requires_password'] = ($flags & 1) !== 0; +$tmp['text'] = $this->deserialize_string($stream); +$tmp['data'] = $this->deserialize_bytes($stream); + +return $tmp; + } + private function deserialize_type_array_of_InlineQueryPeerType(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'0' => [ +'_' => 'inlineQueryPeerTypeSameBotPM', +], +'<' => [ +'_' => 'inlineQueryPeerTypePM', +], +' +黯' => [ +'_' => 'inlineQueryPeerTypeChat', +], +'C奮^' => [ +'_' => 'inlineQueryPeerTypeMegagroup', +], +'4c' => [ +'_' => 'inlineQueryPeerTypeBroadcast', +], +' -;' => [ +'_' => 'inlineQueryPeerTypeBotPM', +], +'+r0' => $this->deserialize_type_InlineQueryPeerType($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_keyboardButtonSwitchInline(mixed $stream): mixed { +$tmp = ['_' => 'keyboardButtonSwitchInline']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['same_peer'] = ($flags & 1) !== 0; +$tmp['text'] = $this->deserialize_string($stream); +$tmp['query'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['peer_types'] = self::deserialize_type_array_of_InlineQueryPeerType($stream); + +return $tmp; + } + private static function deserialize_keyboardButtonUrlAuth(mixed $stream): mixed { +$tmp = ['_' => 'keyboardButtonUrlAuth']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['text'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['fwd_text'] = $this->deserialize_string($stream); +$tmp['url'] = $this->deserialize_string($stream); +$tmp['button_id'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_inputKeyboardButtonUrlAuth(mixed $stream): mixed { +$tmp = ['_' => 'inputKeyboardButtonUrlAuth']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['request_write_access'] = ($flags & 1) !== 0; +$tmp['text'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['fwd_text'] = $this->deserialize_string($stream); +$tmp['url'] = $this->deserialize_string($stream); +$tmp['bot'] = self::deserialize_type_InputUser($stream); + +return $tmp; + } + private static function deserialize_keyboardButtonRequestPoll(mixed $stream): mixed { +$tmp = ['_' => 'keyboardButtonRequestPoll']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['quiz'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; +$tmp['text'] = $this->deserialize_string($stream); + +return $tmp; + } + private static function deserialize_requestPeerTypeUser(mixed $stream): mixed { +$tmp = ['_' => 'requestPeerTypeUser']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['bot'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; +if (($flags & 2) !== 0) $tmp['premium'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; + +return $tmp; + } + private static function deserialize_requestPeerTypeChat(mixed $stream): mixed { +$tmp = ['_' => 'requestPeerTypeChat']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['creator'] = ($flags & 1) !== 0; +$tmp['bot_participant'] = ($flags & 32) !== 0; +if (($flags & 8) !== 0) $tmp['has_username'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; +if (($flags & 16) !== 0) $tmp['forum'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; +if (($flags & 2) !== 0) $tmp['user_admin_rights'] = self::deserialize_type_ChatAdminRights($stream); +if (($flags & 4) !== 0) $tmp['bot_admin_rights'] = self::deserialize_type_ChatAdminRights($stream); + +return $tmp; + } + private static function deserialize_requestPeerTypeBroadcast(mixed $stream): mixed { +$tmp = ['_' => 'requestPeerTypeBroadcast']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['creator'] = ($flags & 1) !== 0; +if (($flags & 8) !== 0) $tmp['has_username'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; +if (($flags & 2) !== 0) $tmp['user_admin_rights'] = self::deserialize_type_ChatAdminRights($stream); +if (($flags & 4) !== 0) $tmp['bot_admin_rights'] = self::deserialize_type_ChatAdminRights($stream); + +return $tmp; + } + private function deserialize_type_RequestPeerType(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'' . "\0" . ';_' => $this->deserialize_requestPeerTypeUser($stream), +'n蟘' => $this->deserialize_requestPeerTypeChat($stream), +'l3' => $this->deserialize_requestPeerTypeBroadcast($stream), +'+r0' => $this->deserialize_type_RequestPeerType($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_KeyboardButton(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'H' => [ +'_' => 'keyboardButton', +'text' => $this->deserialize_string($stream), +], +'%' => [ +'_' => 'keyboardButtonUrl', +'text' => $this->deserialize_string($stream), +'url' => $this->deserialize_string($stream), +], +'k蛬5' => $this->deserialize_keyboardButtonCallback($stream), +')lj' => [ +'_' => 'keyboardButtonRequestPhone', +'text' => $this->deserialize_string($stream), +], +'?ky' => [ +'_' => 'keyboardButtonRequestGeoLocation', +'text' => $this->deserialize_string($stream), +], +'評' => $this->deserialize_keyboardButtonSwitchInline($stream), +'曨' => [ +'_' => 'keyboardButtonGame', +'text' => $this->deserialize_string($stream), +], +'?棬' => [ +'_' => 'keyboardButtonBuy', +'text' => $this->deserialize_string($stream), +], +')' => $this->deserialize_keyboardButtonUrlAuth($stream), +'.' => $this->deserialize_inputKeyboardButtonUrlAuth($stream), +']QУ' => $this->deserialize_keyboardButtonRequestPoll($stream), +'{' => [ +'_' => 'inputKeyboardButtonUserProfile', +'text' => $this->deserialize_string($stream), +'user_id' => self::deserialize_type_InputUser($stream), +], +'總0' => [ +'_' => 'keyboardButtonUserProfile', +'text' => $this->deserialize_string($stream), +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'0rv' => [ +'_' => 'keyboardButtonWebView', +'text' => $this->deserialize_string($stream), +'url' => $this->deserialize_string($stream), +], +'\\P' => [ +'_' => 'keyboardButtonSimpleWebView', +'text' => $this->deserialize_string($stream), +'url' => $this->deserialize_string($stream), +], +'媬舸' => [ +'_' => 'keyboardButtonRequestPeer', +'text' => $this->deserialize_string($stream), +'button_id' => unpack('l', stream_get_contents($stream, 4))[1], +'peer_type' => self::deserialize_type_RequestPeerType($stream), +'max_quantity' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_KeyboardButton($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_array_of_KeyboardButtonRow(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'`w' => [ +'_' => 'keyboardButtonRow', +'buttons' => self::deserialize_type_array_of_KeyboardButton($stream), +], +'+r0' => $this->deserialize_type_KeyboardButtonRow($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_replyKeyboardMarkup(mixed $stream): mixed { +$tmp = ['_' => 'replyKeyboardMarkup']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['resize'] = ($flags & 1) !== 0; +$tmp['single_use'] = ($flags & 2) !== 0; +$tmp['selective'] = ($flags & 4) !== 0; +$tmp['persistent'] = ($flags & 16) !== 0; +$tmp['rows'] = self::deserialize_type_array_of_KeyboardButtonRow($stream); +if (($flags & 8) !== 0) $tmp['placeholder'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_ReplyMarkup(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'[>' => $this->deserialize_replyKeyboardHide($stream), +' ' => $this->deserialize_replyKeyboardForceReply($stream), +'' => $this->deserialize_replyKeyboardMarkup($stream), +'TΕ' => [ +'_' => 'replyInlineMarkup', +'rows' => self::deserialize_type_array_of_KeyboardButtonRow($stream), +], +'+r0' => $this->deserialize_type_ReplyMarkup($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageReplies(mixed $stream): mixed { +$tmp = ['_' => 'messageReplies']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['comments'] = ($flags & 1) !== 0; +$tmp['replies'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['replies_pts'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['recent_repliers'] = self::deserialize_type_array_of_Peer($stream); +if (($flags & 1) !== 0) $tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 4) !== 0) $tmp['max_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['read_max_id'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_MessageReplies(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'' => $this->deserialize_messageReplies($stream), +'+r0' => $this->deserialize_type_MessageReplies($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messagePeerReaction(mixed $stream): mixed { +$tmp = ['_' => 'messagePeerReaction']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['big'] = ($flags & 1) !== 0; +$tmp['unread'] = ($flags & 2) !== 0; +$tmp['my'] = ($flags & 4) !== 0; +$tmp['peer_id'] = self::deserialize_type_Peer($stream); +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['reaction'] = self::deserialize_type_Reaction($stream); + +return $tmp; + } + private function deserialize_type_array_of_MessagePeerReaction(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'<鈇' => $this->deserialize_messagePeerReaction($stream), +'+r0' => $this->deserialize_type_MessagePeerReaction($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_messageReactions(mixed $stream): mixed { +$tmp = ['_' => 'messageReactions']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['min'] = ($flags & 1) !== 0; +$tmp['can_see_list'] = ($flags & 4) !== 0; +$tmp['reactions_as_tags'] = ($flags & 8) !== 0; +$tmp['results'] = self::deserialize_type_array_of_ReactionCount($stream); +if (($flags & 2) !== 0) $tmp['recent_reactions'] = self::deserialize_type_array_of_MessagePeerReaction($stream); + +return $tmp; + } + private function deserialize_type_MessageReactions(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'y+O' => $this->deserialize_messageReactions($stream), +'+r0' => $this->deserialize_type_MessageReactions($stream), +default => self::err($stream) +} +; + } + private static function deserialize_message(mixed $stream): mixed { +$tmp = ['_' => 'message']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['out'] = ($flags & 2) !== 0; +$tmp['mentioned'] = ($flags & 16) !== 0; +$tmp['media_unread'] = ($flags & 32) !== 0; +$tmp['silent'] = ($flags & 8192) !== 0; +$tmp['post'] = ($flags & 16384) !== 0; +$tmp['from_scheduled'] = ($flags & 262144) !== 0; +$tmp['legacy'] = ($flags & 524288) !== 0; +$tmp['edit_hide'] = ($flags & 2097152) !== 0; +$tmp['pinned'] = ($flags & 16777216) !== 0; +$tmp['noforwards'] = ($flags & 67108864) !== 0; +$tmp['invert_media'] = ($flags & 134217728) !== 0; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 256) !== 0) $tmp['from_id'] = self::deserialize_type_Peer($stream); +if (($flags & 536870912) !== 0) $tmp['from_boosts_applied'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['peer_id'] = self::deserialize_type_Peer($stream); +if (($flags & 268435456) !== 0) $tmp['saved_peer_id'] = self::deserialize_type_Peer($stream); +if (($flags & 4) !== 0) $tmp['fwd_from'] = self::deserialize_type_MessageFwdHeader($stream); +if (($flags & 2048) !== 0) $tmp['via_bot_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 8) !== 0) $tmp['reply_to'] = self::deserialize_type_MessageReplyHeader($stream); +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['message'] = $this->deserialize_string($stream); +if (($flags & 512) !== 0) $tmp['media'] = self::deserialize_type_MessageMedia($stream); +if (($flags & 64) !== 0) $tmp['reply_markup'] = self::deserialize_type_ReplyMarkup($stream); +if (($flags & 128) !== 0) $tmp['entities'] = self::deserialize_type_array_of_MessageEntity($stream); +if (($flags & 1024) !== 0) $tmp['views'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1024) !== 0) $tmp['forwards'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8388608) !== 0) $tmp['replies'] = self::deserialize_type_MessageReplies($stream); +if (($flags & 32768) !== 0) $tmp['edit_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 65536) !== 0) $tmp['post_author'] = $this->deserialize_string($stream); +if (($flags & 131072) !== 0) $tmp['grouped_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1048576) !== 0) $tmp['reactions'] = self::deserialize_type_MessageReactions($stream); +if (($flags & 4194304) !== 0) $tmp['restriction_reason'] = self::deserialize_type_array_of_RestrictionReason($stream); +if (($flags & 33554432) !== 0) $tmp['ttl_period'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1073741824) !== 0) $tmp['quick_reply_shortcut_id'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_PostAddress(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'諈' => [ +'_' => 'postAddress', +'street_line1' => $this->deserialize_string($stream), +'street_line2' => $this->deserialize_string($stream), +'city' => $this->deserialize_string($stream), +'state' => $this->deserialize_string($stream), +'country_iso2' => $this->deserialize_string($stream), +'post_code' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_PostAddress($stream), +default => self::err($stream) +} +; + } + private static function deserialize_paymentRequestedInfo(mixed $stream): mixed { +$tmp = ['_' => 'paymentRequestedInfo']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['name'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['phone'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['email'] = $this->deserialize_string($stream); +if (($flags & 8) !== 0) $tmp['shipping_address'] = self::deserialize_type_PostAddress($stream); + +return $tmp; + } + private function deserialize_type_PaymentRequestedInfo(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'?' => $this->deserialize_paymentRequestedInfo($stream), +'+r0' => $this->deserialize_type_PaymentRequestedInfo($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_PaymentCharge(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'~' => [ +'_' => 'paymentCharge', +'id' => $this->deserialize_string($stream), +'provider_charge_id' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_PaymentCharge($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageActionPaymentSentMe(mixed $stream): mixed { +$tmp = ['_' => 'messageActionPaymentSentMe']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['recurring_init'] = ($flags & 4) !== 0; +$tmp['recurring_used'] = ($flags & 8) !== 0; +$tmp['currency'] = $this->deserialize_string($stream); +$tmp['total_amount'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['payload'] = $this->deserialize_bytes($stream); +if (($flags & 1) !== 0) $tmp['info'] = self::deserialize_type_PaymentRequestedInfo($stream); +if (($flags & 2) !== 0) $tmp['shipping_option_id'] = $this->deserialize_string($stream); +$tmp['charge'] = self::deserialize_type_PaymentCharge($stream); + +return $tmp; + } + private static function deserialize_messageActionPaymentSent(mixed $stream): mixed { +$tmp = ['_' => 'messageActionPaymentSent']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['recurring_init'] = ($flags & 4) !== 0; +$tmp['recurring_used'] = ($flags & 8) !== 0; +$tmp['currency'] = $this->deserialize_string($stream); +$tmp['total_amount'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['invoice_slug'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_PhoneCallDiscardReason(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'#' => [ +'_' => 'phoneCallDiscardReasonMissed', +], +'' => [ +'_' => 'phoneCallDiscardReasonDisconnect', +], +'ぉW' => [ +'_' => 'phoneCallDiscardReasonHangup', +], +'扢蠳' => [ +'_' => 'phoneCallDiscardReasonBusy', +], +'+r0' => $this->deserialize_type_PhoneCallDiscardReason($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageActionPhoneCall(mixed $stream): mixed { +$tmp = ['_' => 'messageActionPhoneCall']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['video'] = ($flags & 4) !== 0; +$tmp['call_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['reason'] = self::deserialize_type_PhoneCallDiscardReason($stream); +if (($flags & 2) !== 0) $tmp['duration'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_botApp(mixed $stream): mixed { +$tmp = ['_' => 'botApp']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['short_name'] = $this->deserialize_string($stream); +$tmp['title'] = $this->deserialize_string($stream); +$tmp['description'] = $this->deserialize_string($stream); +$tmp['photo'] = self::deserialize_type_Photo($stream); +if (($flags & 1) !== 0) $tmp['document'] = self::deserialize_type_Document($stream); +$tmp['hash'] = unpack('q', stream_get_contents($stream, 8))[1]; + +return $tmp; + } + private function deserialize_type_BotApp(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'暗因' => [ +'_' => 'botAppNotModified', +], +'笤' => $this->deserialize_botApp($stream), +'+r0' => $this->deserialize_type_BotApp($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageActionBotAllowed(mixed $stream): mixed { +$tmp = ['_' => 'messageActionBotAllowed']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['attach_menu'] = ($flags & 2) !== 0; +$tmp['from_request'] = ($flags & 8) !== 0; +if (($flags & 1) !== 0) $tmp['domain'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['app'] = self::deserialize_type_BotApp($stream); + +return $tmp; + } + private function deserialize_type_SecureValueType(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'*' => [ +'_' => 'secureValueTypePersonalDetails', +], +'' . "\0" . 'j=' => [ +'_' => 'secureValueTypePassport', +], +'%' => [ +'_' => 'secureValueTypeDriverLicense', +], +'Kt' => [ +'_' => 'secureValueTypeIdentityCard', +], +'#' => [ +'_' => 'secureValueTypeInternalPassport', +], +'&蒶' => [ +'_' => 'secureValueTypeAddress', +], +'N6' => [ +'_' => 'secureValueTypeUtilityBill', +], +' |' => [ +'_' => 'secureValueTypeBankStatement', +], +'4' => [ +'_' => 'secureValueTypeRentalAgreement', +], +'j' => [ +'_' => 'secureValueTypePassportRegistration', +], +'3' => [ +'_' => 'secureValueTypeTemporaryRegistration', +], +'菄 ' => [ +'_' => 'secureValueTypePhone', +], +'謏<' => [ +'_' => 'secureValueTypeEmail', +], +'+r0' => $this->deserialize_type_SecureValueType($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_SecureData(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'臘' => [ +'_' => 'secureData', +'data' => $this->deserialize_bytes($stream), +'data_hash' => $this->deserialize_bytes($stream), +'secret' => $this->deserialize_bytes($stream), +], +'+r0' => $this->deserialize_type_SecureData($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_SecureFile(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'Dd' => [ +'_' => 'secureFileEmpty', +], +'~ }' => [ +'_' => 'secureFile', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +'size' => unpack('q', stream_get_contents($stream, 8))[1], +'dc_id' => unpack('l', stream_get_contents($stream, 4))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'file_hash' => $this->deserialize_bytes($stream), +'secret' => $this->deserialize_bytes($stream), +], +'+r0' => $this->deserialize_type_SecureFile($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_SecureFile(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'Dd' => [ +'_' => 'secureFileEmpty', +], +'~ }' => [ +'_' => 'secureFile', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +'size' => unpack('q', stream_get_contents($stream, 8))[1], +'dc_id' => unpack('l', stream_get_contents($stream, 4))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'file_hash' => $this->deserialize_bytes($stream), +'secret' => $this->deserialize_bytes($stream), +], +'+r0' => self::deserialize_type_SecureFile($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_SecurePlainData(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'`}' => [ +'_' => 'securePlainPhone', +'phone' => $this->deserialize_string($stream), +], +'_Z!' => [ +'_' => 'securePlainEmail', +'email' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_SecurePlainData($stream), +default => self::err($stream) +} +; + } + private static function deserialize_secureValue(mixed $stream): mixed { +$tmp = ['_' => 'secureValue']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['type'] = self::deserialize_type_SecureValueType($stream); +if (($flags & 1) !== 0) $tmp['data'] = self::deserialize_type_SecureData($stream); +if (($flags & 2) !== 0) $tmp['front_side'] = self::deserialize_type_SecureFile($stream); +if (($flags & 4) !== 0) $tmp['reverse_side'] = self::deserialize_type_SecureFile($stream); +if (($flags & 8) !== 0) $tmp['selfie'] = self::deserialize_type_SecureFile($stream); +if (($flags & 64) !== 0) $tmp['translation'] = self::deserialize_type_array_of_SecureFile($stream); +if (($flags & 16) !== 0) $tmp['files'] = self::deserialize_type_array_of_SecureFile($stream); +if (($flags & 32) !== 0) $tmp['plain_data'] = self::deserialize_type_SecurePlainData($stream); +$tmp['hash'] = $this->deserialize_bytes($stream); + +return $tmp; + } + private function deserialize_type_array_of_SecureValue(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'' => $this->deserialize_secureValue($stream), +'+r0' => $this->deserialize_type_SecureValue($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_SecureCredentialsEncrypted(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'G膴3' => [ +'_' => 'secureCredentialsEncrypted', +'data' => $this->deserialize_bytes($stream), +'hash' => $this->deserialize_bytes($stream), +'secret' => $this->deserialize_bytes($stream), +], +'+r0' => $this->deserialize_type_SecureCredentialsEncrypted($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_SecureValueType(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'*' => [ +'_' => 'secureValueTypePersonalDetails', +], +'' . "\0" . 'j=' => [ +'_' => 'secureValueTypePassport', +], +'%' => [ +'_' => 'secureValueTypeDriverLicense', +], +'Kt' => [ +'_' => 'secureValueTypeIdentityCard', +], +'#' => [ +'_' => 'secureValueTypeInternalPassport', +], +'&蒶' => [ +'_' => 'secureValueTypeAddress', +], +'N6' => [ +'_' => 'secureValueTypeUtilityBill', +], +' |' => [ +'_' => 'secureValueTypeBankStatement', +], +'4' => [ +'_' => 'secureValueTypeRentalAgreement', +], +'j' => [ +'_' => 'secureValueTypePassportRegistration', +], +'3' => [ +'_' => 'secureValueTypeTemporaryRegistration', +], +'菄 ' => [ +'_' => 'secureValueTypePhone', +], +'謏<' => [ +'_' => 'secureValueTypeEmail', +], +'+r0' => self::deserialize_type_SecureValueType($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_InputGroupCall(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'臾' => [ +'_' => 'inputGroupCall', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +'+r0' => $this->deserialize_type_InputGroupCall($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageActionGroupCall(mixed $stream): mixed { +$tmp = ['_' => 'messageActionGroupCall']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['call'] = self::deserialize_type_InputGroupCall($stream); +if (($flags & 1) !== 0) $tmp['duration'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_messageActionSetMessagesTTL(mixed $stream): mixed { +$tmp = ['_' => 'messageActionSetMessagesTTL']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['period'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['auto_setting_from'] = unpack('q', stream_get_contents($stream, 8))[1]; + +return $tmp; + } + private static function deserialize_messageActionGiftPremium(mixed $stream): mixed { +$tmp = ['_' => 'messageActionGiftPremium']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['currency'] = $this->deserialize_string($stream); +$tmp['amount'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['months'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['crypto_currency'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['crypto_amount'] = unpack('q', stream_get_contents($stream, 8))[1]; + +return $tmp; + } + private static function deserialize_messageActionTopicCreate(mixed $stream): mixed { +$tmp = ['_' => 'messageActionTopicCreate']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['title'] = $this->deserialize_string($stream); +$tmp['icon_color'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['icon_emoji_id'] = unpack('q', stream_get_contents($stream, 8))[1]; + +return $tmp; + } + private static function deserialize_messageActionTopicEdit(mixed $stream): mixed { +$tmp = ['_' => 'messageActionTopicEdit']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['title'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['icon_emoji_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 4) !== 0) $tmp['closed'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; +if (($flags & 8) !== 0) $tmp['hidden'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; + +return $tmp; + } + private static function deserialize_messageActionSetChatWallPaper(mixed $stream): mixed { +$tmp = ['_' => 'messageActionSetChatWallPaper']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['same'] = ($flags & 1) !== 0; +$tmp['for_both'] = ($flags & 2) !== 0; +$tmp['wallpaper'] = self::deserialize_type_WallPaper($stream); + +return $tmp; + } + private static function deserialize_messageActionGiftCode(mixed $stream): mixed { +$tmp = ['_' => 'messageActionGiftCode']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['via_giveaway'] = ($flags & 1) !== 0; +$tmp['unclaimed'] = ($flags & 4) !== 0; +if (($flags & 2) !== 0) $tmp['boost_peer'] = self::deserialize_type_Peer($stream); +$tmp['months'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['slug'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['currency'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['amount'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 8) !== 0) $tmp['crypto_currency'] = $this->deserialize_string($stream); +if (($flags & 8) !== 0) $tmp['crypto_amount'] = unpack('q', stream_get_contents($stream, 8))[1]; + +return $tmp; + } + private function deserialize_type_MessageAction(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'夠振' => [ +'_' => 'messageActionEmpty', +], +'倒G' => [ +'_' => 'messageActionChatCreate', +'title' => $this->deserialize_string($stream), +'users' => self::deserialize_type_array_of_long($stream), +], +'Z峞' => [ +'_' => 'messageActionChatEditTitle', +'title' => $this->deserialize_string($stream), +], +'' => [ +'_' => 'messageActionChatEditPhoto', +'photo' => self::deserialize_type_Photo($stream), +], +'燹' => [ +'_' => 'messageActionChatDeletePhoto', +], +'' . "\0" . '' => [ +'_' => 'messageActionChatAddUser', +'users' => self::deserialize_type_array_of_long($stream), +], +'0?' => [ +'_' => 'messageActionChatDeleteUser', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'$' => [ +'_' => 'messageActionChatJoinedByLink', +'inviter_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'皆' => [ +'_' => 'messageActionChannelCreate', +'title' => $this->deserialize_string($stream), +], +'' => [ +'_' => 'messageActionChatMigrateTo', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'圛9' => [ +'_' => 'messageActionChannelMigrateFrom', +'title' => $this->deserialize_string($stream), +'chat_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'8' => [ +'_' => 'messageActionPinMessage', +], +'飯' => [ +'_' => 'messageActionHistoryClear', +], +'v(' => [ +'_' => 'messageActionGameScore', +'game_id' => unpack('q', stream_get_contents($stream, 8))[1], +'score' => unpack('l', stream_get_contents($stream, 4))[1], +], +'\'1' => $this->deserialize_messageActionPaymentSentMe($stream), +'V?' => $this->deserialize_messageActionPaymentSent($stream), +'' => $this->deserialize_messageActionPhoneCall($stream), +'G' => [ +'_' => 'messageActionScreenshotTaken', +], +'V翨' => [ +'_' => 'messageActionCustomAction', +'message' => $this->deserialize_string($stream), +], +'y' => $this->deserialize_messageActionBotAllowed($stream), +'Ss(' => [ +'_' => 'messageActionSecureValuesSentMe', +'values' => self::deserialize_type_array_of_SecureValue($stream), +'credentials' => self::deserialize_type_SecureCredentialsEncrypted($stream), +], +'Ta\\' => [ +'_' => 'messageActionSecureValuesSent', +'types' => self::deserialize_type_array_of_SecureValueType($stream), +], +'v_覷' => [ +'_' => 'messageActionContactSignUp', +], +'粖' => [ +'_' => 'messageActionGeoProximityReached', +'from_id' => self::deserialize_type_Peer($stream), +'to_id' => self::deserialize_type_Peer($stream), +'distance' => unpack('l', stream_get_contents($stream, 4))[1], +], +'B z' => $this->deserialize_messageActionGroupCall($stream), +'/P' => [ +'_' => 'messageActionInviteToGroupCall', +'call' => self::deserialize_type_InputGroupCall($stream), +'users' => self::deserialize_type_array_of_long($stream), +], +'{M<' => $this->deserialize_messageActionSetMessagesTTL($stream), +'av' => [ +'_' => 'messageActionGroupCallScheduled', +'call' => self::deserialize_type_InputGroupCall($stream), +'schedule_date' => unpack('l', stream_get_contents($stream, 4))[1], +], +'Ecx' => [ +'_' => 'messageActionSetChatTheme', +'emoticon' => $this->deserialize_string($stream), +], +'芄潺' => [ +'_' => 'messageActionChatJoinedByRequest', +], +'y媐' => [ +'_' => 'messageActionWebViewDataSentMe', +'text' => $this->deserialize_string($stream), +'data' => $this->deserialize_string($stream), +], +'繫' => [ +'_' => 'messageActionWebViewDataSent', +'text' => $this->deserialize_string($stream), +], +'骹=' => $this->deserialize_messageActionGiftPremium($stream), +'V ' => $this->deserialize_messageActionTopicCreate($stream), +' H' => $this->deserialize_messageActionTopicEdit($stream), +'^c溦' => [ +'_' => 'messageActionSuggestProfilePhoto', +'photo' => self::deserialize_type_Photo($stream), +], +'Q1' => [ +'_' => 'messageActionRequestedPeer', +'button_id' => unpack('l', stream_get_contents($stream, 4))[1], +'peers' => self::deserialize_type_array_of_Peer($stream), +], +'穬`P' => $this->deserialize_messageActionSetChatWallPaper($stream), +' .g' => $this->deserialize_messageActionGiftCode($stream), +'磼+3' => [ +'_' => 'messageActionGiveawayLaunch', +], +'躑*' => [ +'_' => 'messageActionGiveawayResults', +'winners_count' => unpack('l', stream_get_contents($stream, 4))[1], +'unclaimed_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'m' => [ +'_' => 'messageActionBoostApply', +'boosts' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_MessageAction($stream), +default => self::err($stream) +} +; + } + private static function deserialize_messageService(mixed $stream): mixed { +$tmp = ['_' => 'messageService']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['out'] = ($flags & 2) !== 0; +$tmp['mentioned'] = ($flags & 16) !== 0; +$tmp['media_unread'] = ($flags & 32) !== 0; +$tmp['silent'] = ($flags & 8192) !== 0; +$tmp['post'] = ($flags & 16384) !== 0; +$tmp['legacy'] = ($flags & 524288) !== 0; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 256) !== 0) $tmp['from_id'] = self::deserialize_type_Peer($stream); +$tmp['peer_id'] = self::deserialize_type_Peer($stream); +if (($flags & 8) !== 0) $tmp['reply_to'] = self::deserialize_type_MessageReplyHeader($stream); +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['action'] = self::deserialize_type_MessageAction($stream); +if (($flags & 33554432) !== 0) $tmp['ttl_period'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_Message(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'呇' => $this->deserialize_messageEmpty($stream), +'~l' => $this->deserialize_message($stream), +'bX+' => $this->deserialize_messageService($stream), +'+r0' => $this->deserialize_type_Message($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_DataJSON(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'t}' => json_decode($this->deserialize_string($stream), true, 512, \JSON_THROW_ON_ERROR), +'+r0' => $this->deserialize_type_DataJSON($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_SendMessageAction(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'Nt' => [ +'_' => 'sendMessageTypingAction', +], +'孇^' => [ +'_' => 'sendMessageCancelAction', +], +'o' => [ +'_' => 'sendMessageRecordVideoAction', +], +':v' => [ +'_' => 'sendMessageUploadVideoAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'顪/' => [ +'_' => 'sendMessageRecordAudioAction', +], +'度Q' => [ +'_' => 'sendMessageUploadAudioAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'&J衭' => [ +'_' => 'sendMessageUploadPhotoAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'駇 ' => [ +'_' => 'sendMessageUploadDocumentAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'o' => [ +'_' => 'sendMessageGeoLocationAction', +], +'ob' => [ +'_' => 'sendMessageChooseContactAction', +], +'Hj' => [ +'_' => 'sendMessageGamePlayAction', +], +'' => [ +'_' => 'sendMessageRecordRoundAction', +], +'f>$' => [ +'_' => 'sendMessageUploadRoundAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'",' => [ +'_' => 'speakingInGroupCallAction', +], +'F窙' => [ +'_' => 'sendMessageHistoryImportAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'排Z' => [ +'_' => 'sendMessageChooseStickerAction', +], +'+%' => [ +'_' => 'sendMessageEmojiInteraction', +'emoticon' => $this->deserialize_string($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'interaction' => self::deserialize_type_DataJSON($stream), +], +'.e' => [ +'_' => 'sendMessageEmojiInteractionSeen', +'emoticon' => $this->deserialize_string($stream), +], +'/' => [ +'_' => 'sendMessageUploadVideoAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'o祆' => [ +'_' => 'sendMessageUploadAudioAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'< +' => [ +'_' => 'sendMessageUploadPhotoAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'擙' => [ +'_' => 'sendMessageUploadDocumentAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'$q' => [ +'_' => 'sendMessageUploadRoundAction', +'progress' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_SendMessageAction($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_ChatParticipant(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'@-' => [ +'_' => 'chatParticipant', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'inviter_id' => unpack('q', stream_get_contents($stream, 8))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +], +'餂k' => [ +'_' => 'chatParticipantCreator', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'[?' => [ +'_' => 'chatParticipantAdmin', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'inviter_id' => unpack('q', stream_get_contents($stream, 8))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_ChatParticipant($stream), +default => self::err($stream) +} +; + } + private static function deserialize_chatParticipantsForbidden(mixed $stream): mixed { +$tmp = ['_' => 'chatParticipantsForbidden']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['chat_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['self_participant'] = self::deserialize_type_ChatParticipant($stream); + +return $tmp; + } + private function deserialize_type_array_of_ChatParticipant(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'@-' => [ +'_' => 'chatParticipant', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'inviter_id' => unpack('q', stream_get_contents($stream, 8))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +], +'餂k' => [ +'_' => 'chatParticipantCreator', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'[?' => [ +'_' => 'chatParticipantAdmin', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'inviter_id' => unpack('q', stream_get_contents($stream, 8))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => self::deserialize_type_ChatParticipant($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_ChatParticipants(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'慪c' => $this->deserialize_chatParticipantsForbidden($stream), +'<' => [ +'_' => 'chatParticipants', +'chat_id' => unpack('q', stream_get_contents($stream, 8))[1], +'participants' => self::deserialize_type_array_of_ChatParticipant($stream), +'version' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_ChatParticipants($stream), +default => self::err($stream) +} +; + } + private static function deserialize_userStatusRecently(mixed $stream): mixed { +$tmp = ['_' => 'userStatusRecently']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['by_me'] = ($flags & 1) !== 0; + +return $tmp; + } + private static function deserialize_userStatusLastWeek(mixed $stream): mixed { +$tmp = ['_' => 'userStatusLastWeek']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['by_me'] = ($flags & 1) !== 0; + +return $tmp; + } + private static function deserialize_userStatusLastMonth(mixed $stream): mixed { +$tmp = ['_' => 'userStatusLastMonth']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['by_me'] = ($flags & 1) !== 0; + +return $tmp; + } + private function deserialize_type_UserStatus(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'IP ' => [ +'_' => 'userStatusEmpty', +], +'I9寤' => [ +'_' => 'userStatusOnline', +'expires' => unpack('l', stream_get_contents($stream, 4))[1], +], +'?p' . "\0" . '' => [ +'_' => 'userStatusOffline', +'was_online' => unpack('l', stream_get_contents($stream, 4))[1], +], +'}{' => $this->deserialize_userStatusRecently($stream), +'T' => $this->deserialize_userStatusLastWeek($stream), +'we' => $this->deserialize_userStatusLastMonth($stream), +'+r0' => $this->deserialize_type_UserStatus($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateNewAuthorization(mixed $stream): mixed { +$tmp = ['_' => 'updateNewAuthorization']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['unconfirmed'] = ($flags & 1) !== 0; +$tmp['hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['device'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['location'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_EncryptedFile(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'~I' => [ +'_' => 'encryptedFileEmpty', +], +'' . "\0" . '' => [ +'_' => 'encryptedFile', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +'size' => unpack('q', stream_get_contents($stream, 8))[1], +'dc_id' => unpack('l', stream_get_contents($stream, 4))[1], +'key_fingerprint' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_EncryptedFile($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_EncryptedMessage(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'' => [ +'_' => 'encryptedMessage', +'random_id' => unpack('q', stream_get_contents($stream, 8))[1], +'chat_id' => unpack('l', stream_get_contents($stream, 4))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'bytes' => $this->deserialize_bytes($stream), +'file' => self::deserialize_type_EncryptedFile($stream), +], +'Ks#' => [ +'_' => 'encryptedMessageService', +'random_id' => unpack('q', stream_get_contents($stream, 8))[1], +'chat_id' => unpack('l', stream_get_contents($stream, 4))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'bytes' => $this->deserialize_bytes($stream), +], +'+r0' => $this->deserialize_type_EncryptedMessage($stream), +default => self::err($stream) +} +; + } + private static function deserialize_encryptedChatRequested(mixed $stream): mixed { +$tmp = ['_' => 'encryptedChatRequested']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['folder_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['admin_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['participant_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['g_a'] = $this->deserialize_bytes($stream); + +return $tmp; + } + private static function deserialize_encryptedChatDiscarded(mixed $stream): mixed { +$tmp = ['_' => 'encryptedChatDiscarded']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['history_deleted'] = ($flags & 1) !== 0; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_EncryptedChat(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'嚇' => [ +'_' => 'encryptedChatEmpty', +'id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'SY淬' => [ +'_' => 'encryptedChatWaiting', +'id' => unpack('l', stream_get_contents($stream, 4))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'admin_id' => unpack('q', stream_get_contents($stream, 8))[1], +'participant_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'L渫H' => $this->deserialize_encryptedChatRequested($stream), +'л簜' => [ +'_' => 'encryptedChat', +'id' => unpack('l', stream_get_contents($stream, 4))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'admin_id' => unpack('q', stream_get_contents($stream, 8))[1], +'participant_id' => unpack('q', stream_get_contents($stream, 8))[1], +'g_a_or_b' => $this->deserialize_bytes($stream), +'key_fingerprint' => stream_get_contents($stream, 8), +], +'E|' => $this->deserialize_encryptedChatDiscarded($stream), +'+r0' => $this->deserialize_type_EncryptedChat($stream), +default => self::err($stream) +} +; + } + private static function deserialize_dcOption(mixed $stream): mixed { +$tmp = ['_' => 'dcOption']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['ipv6'] = ($flags & 1) !== 0; +$tmp['media_only'] = ($flags & 2) !== 0; +$tmp['tcpo_only'] = ($flags & 4) !== 0; +$tmp['cdn'] = ($flags & 8) !== 0; +$tmp['static'] = ($flags & 16) !== 0; +$tmp['this_port_only'] = ($flags & 32) !== 0; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['ip_address'] = $this->deserialize_string($stream); +$tmp['port'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1024) !== 0) $tmp['secret'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_array_of_DcOption(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +' ◎' => $this->deserialize_dcOption($stream), +'+r0' => $this->deserialize_type_DcOption($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_NotifyPeer(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' ' => [ +'_' => 'notifyPeer', +'peer' => self::deserialize_type_Peer($stream), +], +'L;' => [ +'_' => 'notifyUsers', +], +'襞' => [ +'_' => 'notifyChats', +], +'歞' => [ +'_' => 'notifyBroadcasts', +], +'cn"' => [ +'_' => 'notifyForumTopic', +'peer' => self::deserialize_type_Peer($stream), +'top_msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_NotifyPeer($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_NotificationSound(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'噢' => [ +'_' => 'notificationSoundDefault', +], +'4 o' => [ +'_' => 'notificationSoundNone', +], +' ' => [ +'_' => 'notificationSoundLocal', +'title' => $this->deserialize_string($stream), +'data' => $this->deserialize_string($stream), +], +'Il' => [ +'_' => 'notificationSoundRingtone', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'+r0' => $this->deserialize_type_NotificationSound($stream), +default => self::err($stream) +} +; + } + private static function deserialize_peerNotifySettings(mixed $stream): mixed { +$tmp = ['_' => 'peerNotifySettings']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['show_previews'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; +if (($flags & 2) !== 0) $tmp['silent'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; +if (($flags & 4) !== 0) $tmp['mute_until'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['ios_sound'] = self::deserialize_type_NotificationSound($stream); +if (($flags & 16) !== 0) $tmp['android_sound'] = self::deserialize_type_NotificationSound($stream); +if (($flags & 32) !== 0) $tmp['other_sound'] = self::deserialize_type_NotificationSound($stream); +if (($flags & 64) !== 0) $tmp['stories_muted'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; +if (($flags & 128) !== 0) $tmp['stories_hide_sender'] = match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }; +if (($flags & 256) !== 0) $tmp['stories_ios_sound'] = self::deserialize_type_NotificationSound($stream); +if (($flags & 512) !== 0) $tmp['stories_android_sound'] = self::deserialize_type_NotificationSound($stream); +if (($flags & 1024) !== 0) $tmp['stories_other_sound'] = self::deserialize_type_NotificationSound($stream); + +return $tmp; + } + private function deserialize_type_PeerNotifySettings(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' ,b' => $this->deserialize_peerNotifySettings($stream), +'+r0' => $this->deserialize_type_PeerNotifySettings($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateServiceNotification(mixed $stream): mixed { +$tmp = ['_' => 'updateServiceNotification']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['popup'] = ($flags & 1) !== 0; +$tmp['invert_media'] = ($flags & 4) !== 0; +if (($flags & 2) !== 0) $tmp['inbox_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['type'] = $this->deserialize_string($stream); +$tmp['message'] = $this->deserialize_string($stream); +$tmp['media'] = self::deserialize_type_MessageMedia($stream); +$tmp['entities'] = self::deserialize_type_array_of_MessageEntity($stream); + +return $tmp; + } + private function deserialize_type_PrivacyKey(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'0.' => [ +'_' => 'privacyKeyStatusTimestamp', +], +'mP' => [ +'_' => 'privacyKeyChatInvite', +], +'{+f=' => [ +'_' => 'privacyKeyPhoneCall', +], +'I9' => [ +'_' => 'privacyKeyPhoneP2P', +], +'Τ駧' => [ +'_' => 'privacyKeyForwards', +], +'' => [ +'_' => 'privacyKeyProfilePhoto', +], +'m' => [ +'_' => 'privacyKeyPhoneNumber', +], +'+B' => [ +'_' => 'privacyKeyAddedByPhone', +], +'' => [ +'_' => 'privacyKeyVoiceMessages', +], +'a' => [ +'_' => 'privacyKeyAbout', +], +'+r0' => $this->deserialize_type_PrivacyKey($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateReadHistoryInbox(mixed $stream): mixed { +$tmp = ['_' => 'updateReadHistoryInbox']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['folder_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['peer'] = self::deserialize_type_Peer($stream); +$tmp['max_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['still_unread_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['pts'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['pts_count'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_updateReadMessagesContents(mixed $stream): mixed { +$tmp = ['_' => 'updateReadMessagesContents']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['messages'] = self::deserialize_type_array_of_int($stream); +$tmp['pts'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['pts_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_updateChannelTooLong(mixed $stream): mixed { +$tmp = ['_' => 'updateChannelTooLong']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['pts'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_updateReadChannelInbox(mixed $stream): mixed { +$tmp = ['_' => 'updateReadChannelInbox']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['folder_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['max_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['still_unread_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['pts'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_stickerSet(mixed $stream): mixed { +$tmp = ['_' => 'stickerSet']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['archived'] = ($flags & 2) !== 0; +$tmp['official'] = ($flags & 4) !== 0; +$tmp['masks'] = ($flags & 8) !== 0; +$tmp['animated'] = ($flags & 32) !== 0; +$tmp['videos'] = ($flags & 64) !== 0; +$tmp['emojis'] = ($flags & 128) !== 0; +$tmp['text_color'] = ($flags & 512) !== 0; +$tmp['channel_emoji_status'] = ($flags & 1024) !== 0; +if (($flags & 1) !== 0) $tmp['installed_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['title'] = $this->deserialize_string($stream); +$tmp['short_name'] = $this->deserialize_string($stream); +if (($flags & 16) !== 0) $tmp['thumbs'] = self::deserialize_type_array_of_PhotoSize($stream); +if (($flags & 16) !== 0) $tmp['thumb_dc_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 16) !== 0) $tmp['thumb_version'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 256) !== 0) $tmp['thumb_document_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['count'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['hash'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_StickerSet(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'逴-' => $this->deserialize_stickerSet($stream), +'+r0' => $this->deserialize_type_StickerSet($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_StickerPack(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'' => [ +'_' => 'stickerPack', +'emoticon' => $this->deserialize_string($stream), +'documents' => self::deserialize_type_array_of_long($stream), +], +'+r0' => $this->deserialize_type_StickerPack($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_array_of_StickerKeyword(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'荼' => [ +'_' => 'stickerKeyword', +'document_id' => unpack('q', stream_get_contents($stream, 8))[1], +'keyword' => self::deserialize_type_array_of_string($stream), +], +'+r0' => $this->deserialize_type_StickerKeyword($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_messages___StickerSet(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'?n' => [ +'_' => 'messages.stickerSet', +'set' => self::deserialize_type_StickerSet($stream), +'packs' => self::deserialize_type_array_of_StickerPack($stream), +'keywords' => self::deserialize_type_array_of_StickerKeyword($stream), +'documents' => self::deserialize_type_array_of_Document($stream), +], +'$齾' => [ +'_' => 'messages.stickerSetNotModified', +], +'+r0' => $this->deserialize_type_messages___StickerSet($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateStickerSetsOrder(mixed $stream): mixed { +$tmp = ['_' => 'updateStickerSetsOrder']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['masks'] = ($flags & 1) !== 0; +$tmp['emojis'] = ($flags & 2) !== 0; +$tmp['order'] = self::deserialize_type_array_of_long($stream); + +return $tmp; + } + private static function deserialize_updateStickerSets(mixed $stream): mixed { +$tmp = ['_' => 'updateStickerSets']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['masks'] = ($flags & 1) !== 0; +$tmp['emojis'] = ($flags & 2) !== 0; + +return $tmp; + } + private function deserialize_type_InlineQueryPeerType(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'0' => [ +'_' => 'inlineQueryPeerTypeSameBotPM', +], +'<' => [ +'_' => 'inlineQueryPeerTypePM', +], +' +黯' => [ +'_' => 'inlineQueryPeerTypeChat', +], +'C奮^' => [ +'_' => 'inlineQueryPeerTypeMegagroup', +], +'4c' => [ +'_' => 'inlineQueryPeerTypeBroadcast', +], +' -;' => [ +'_' => 'inlineQueryPeerTypeBotPM', +], +'+r0' => $this->deserialize_type_InlineQueryPeerType($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateBotInlineQuery(mixed $stream): mixed { +$tmp = ['_' => 'updateBotInlineQuery']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['query_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['query'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['geo'] = self::deserialize_type_GeoPoint($stream); +if (($flags & 2) !== 0) $tmp['peer_type'] = self::deserialize_type_InlineQueryPeerType($stream); +$tmp['offset'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_InputBotInlineMessageID(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'= ' => [ +'_' => 'inputBotInlineMessageID', +'dc_id' => unpack('l', stream_get_contents($stream, 4))[1], +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +'棤' => [ +'_' => 'inputBotInlineMessageID64', +'dc_id' => unpack('l', stream_get_contents($stream, 4))[1], +'owner_id' => unpack('q', stream_get_contents($stream, 8))[1], +'id' => unpack('l', stream_get_contents($stream, 4))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +'+r0' => $this->deserialize_type_InputBotInlineMessageID($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateBotInlineSend(mixed $stream): mixed { +$tmp = ['_' => 'updateBotInlineSend']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['query'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['geo'] = self::deserialize_type_GeoPoint($stream); +$tmp['id'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['msg_id'] = self::deserialize_type_InputBotInlineMessageID($stream); + +return $tmp; + } + private static function deserialize_updateBotCallbackQuery(mixed $stream): mixed { +$tmp = ['_' => 'updateBotCallbackQuery']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['query_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['peer'] = self::deserialize_type_Peer($stream); +$tmp['msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['chat_instance'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['data'] = $this->deserialize_bytes($stream); +if (($flags & 2) !== 0) $tmp['game_short_name'] = $this->deserialize_string($stream); + +return $tmp; + } + private static function deserialize_updateInlineBotCallbackQuery(mixed $stream): mixed { +$tmp = ['_' => 'updateInlineBotCallbackQuery']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['query_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['msg_id'] = self::deserialize_type_InputBotInlineMessageID($stream); +$tmp['chat_instance'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['data'] = $this->deserialize_bytes($stream); +if (($flags & 2) !== 0) $tmp['game_short_name'] = $this->deserialize_string($stream); + +return $tmp; + } + private static function deserialize_draftMessageEmpty(mixed $stream): mixed { +$tmp = ['_' => 'draftMessageEmpty']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_inputReplyToMessage(mixed $stream): mixed { +$tmp = ['_' => 'inputReplyToMessage']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['reply_to_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['top_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['reply_to_peer_id'] = self::deserialize_type_InputPeer($stream); +if (($flags & 4) !== 0) $tmp['quote_text'] = $this->deserialize_string($stream); +if (($flags & 8) !== 0) $tmp['quote_entities'] = self::deserialize_type_array_of_MessageEntity($stream); +if (($flags & 16) !== 0) $tmp['quote_offset'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_InputReplyTo(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'淊"' => $this->deserialize_inputReplyToMessage($stream), +':2X' => [ +'_' => 'inputReplyToStory', +'peer' => self::deserialize_type_InputPeer($stream), +'story_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_InputReplyTo($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_InputFile(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'/' => [ +'_' => 'inputFile', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'parts' => unpack('l', stream_get_contents($stream, 4))[1], +'name' => $this->deserialize_string($stream), +'md5_checksum' => $this->deserialize_string($stream), +], +' O' => [ +'_' => 'inputFileBig', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'parts' => unpack('l', stream_get_contents($stream, 4))[1], +'name' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_InputFile($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_InputDocument(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'栓繢' => [ +'_' => 'inputDocumentEmpty', +], +'u翕' => [ +'_' => 'inputDocument', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +'file_reference' => $this->deserialize_bytes($stream), +], +'+r0' => $this->deserialize_type_InputDocument($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_inputMediaUploadedPhoto(mixed $stream): mixed { +$tmp = ['_' => 'inputMediaUploadedPhoto']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['spoiler'] = ($flags & 4) !== 0; +$tmp['file'] = self::deserialize_type_InputFile($stream); +if (($flags & 1) !== 0) $tmp['stickers'] = self::deserialize_type_array_of_InputDocument($stream); +if (($flags & 2) !== 0) $tmp['ttl_seconds'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_InputPhoto(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' 謂' => [ +'_' => 'inputPhotoEmpty', +], +'J像;' => [ +'_' => 'inputPhoto', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +'file_reference' => $this->deserialize_bytes($stream), +], +'+r0' => $this->deserialize_type_InputPhoto($stream), +default => self::err($stream) +} +; + } + private static function deserialize_inputMediaPhoto(mixed $stream): mixed { +$tmp = ['_' => 'inputMediaPhoto']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['spoiler'] = ($flags & 2) !== 0; +$tmp['id'] = self::deserialize_type_InputPhoto($stream); +if (($flags & 1) !== 0) $tmp['ttl_seconds'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_inputGeoPoint(mixed $stream): mixed { +$tmp = ['_' => 'inputGeoPoint']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['lat'] = unpack('d', stream_get_contents($stream, 8))[1]; +$tmp['long'] = unpack('d', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['accuracy_radius'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_InputGeoPoint(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'#鍵' => [ +'_' => 'inputGeoPointEmpty', +], +'/"H' => $this->deserialize_inputGeoPoint($stream), +'+r0' => $this->deserialize_type_InputGeoPoint($stream), +default => self::err($stream) +} +; + } + private static function deserialize_inputMediaUploadedDocument(mixed $stream): mixed { +$tmp = ['_' => 'inputMediaUploadedDocument']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['nosound_video'] = ($flags & 8) !== 0; +$tmp['force_file'] = ($flags & 16) !== 0; +$tmp['spoiler'] = ($flags & 32) !== 0; +$tmp['file'] = self::deserialize_type_InputFile($stream); +if (($flags & 4) !== 0) $tmp['thumb'] = self::deserialize_type_InputFile($stream); +$tmp['mime_type'] = $this->deserialize_string($stream); +$tmp['attributes'] = self::deserialize_type_array_of_DocumentAttribute($stream); +if (($flags & 1) !== 0) $tmp['stickers'] = self::deserialize_type_array_of_InputDocument($stream); +if (($flags & 2) !== 0) $tmp['ttl_seconds'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_InputDocument(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'栓繢' => [ +'_' => 'inputDocumentEmpty', +], +'u翕' => [ +'_' => 'inputDocument', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +'file_reference' => $this->deserialize_bytes($stream), +], +'+r0' => $this->deserialize_type_InputDocument($stream), +default => self::err($stream) +} +; + } + private static function deserialize_inputMediaDocument(mixed $stream): mixed { +$tmp = ['_' => 'inputMediaDocument']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['spoiler'] = ($flags & 4) !== 0; +$tmp['id'] = self::deserialize_type_InputDocument($stream); +if (($flags & 1) !== 0) $tmp['ttl_seconds'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['query'] = $this->deserialize_string($stream); + +return $tmp; + } + private static function deserialize_inputMediaPhotoExternal(mixed $stream): mixed { +$tmp = ['_' => 'inputMediaPhotoExternal']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['spoiler'] = ($flags & 2) !== 0; +$tmp['url'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['ttl_seconds'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_inputMediaDocumentExternal(mixed $stream): mixed { +$tmp = ['_' => 'inputMediaDocumentExternal']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['spoiler'] = ($flags & 2) !== 0; +$tmp['url'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['ttl_seconds'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_InputGame(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'w>,' => [ +'_' => 'inputGameID', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +' +1' => [ +'_' => 'inputGameShortName', +'bot_id' => self::deserialize_type_InputUser($stream), +'short_name' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_InputGame($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_InputWebDocument(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'MC' => [ +'_' => 'inputWebDocument', +'url' => $this->deserialize_string($stream), +'size' => unpack('l', stream_get_contents($stream, 4))[1], +'mime_type' => $this->deserialize_string($stream), +'attributes' => self::deserialize_type_array_of_DocumentAttribute($stream), +], +'+r0' => $this->deserialize_type_InputWebDocument($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_LabeledPrice(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'鷦)' => [ +'_' => 'labeledPrice', +'label' => $this->deserialize_string($stream), +'amount' => unpack('q', stream_get_contents($stream, 8))[1], +], +'+r0' => $this->deserialize_type_LabeledPrice($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_invoice(mixed $stream): mixed { +$tmp = ['_' => 'invoice']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['test'] = ($flags & 1) !== 0; +$tmp['name_requested'] = ($flags & 2) !== 0; +$tmp['phone_requested'] = ($flags & 4) !== 0; +$tmp['email_requested'] = ($flags & 8) !== 0; +$tmp['shipping_address_requested'] = ($flags & 16) !== 0; +$tmp['flexible'] = ($flags & 32) !== 0; +$tmp['phone_to_provider'] = ($flags & 64) !== 0; +$tmp['email_to_provider'] = ($flags & 128) !== 0; +$tmp['recurring'] = ($flags & 512) !== 0; +$tmp['currency'] = $this->deserialize_string($stream); +$tmp['prices'] = self::deserialize_type_array_of_LabeledPrice($stream); +if (($flags & 256) !== 0) $tmp['max_tip_amount'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 256) !== 0) $tmp['suggested_tip_amounts'] = self::deserialize_type_array_of_long($stream); +if (($flags & 1024) !== 0) $tmp['terms_url'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_Invoice(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'Z鉛' => $this->deserialize_invoice($stream), +'+r0' => $this->deserialize_type_Invoice($stream), +default => self::err($stream) +} +; + } + private static function deserialize_inputMediaInvoice(mixed $stream): mixed { +$tmp = ['_' => 'inputMediaInvoice']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['title'] = $this->deserialize_string($stream); +$tmp['description'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['photo'] = self::deserialize_type_InputWebDocument($stream); +$tmp['invoice'] = self::deserialize_type_Invoice($stream); +$tmp['payload'] = $this->deserialize_bytes($stream); +$tmp['provider'] = $this->deserialize_string($stream); +$tmp['provider_data'] = self::deserialize_type_DataJSON($stream); +if (($flags & 2) !== 0) $tmp['start_param'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['extended_media'] = $this->deserialize_type_InputMedia($stream); + +return $tmp; + } + private static function deserialize_inputMediaGeoLive(mixed $stream): mixed { +$tmp = ['_' => 'inputMediaGeoLive']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['stopped'] = ($flags & 1) !== 0; +$tmp['geo_point'] = self::deserialize_type_InputGeoPoint($stream); +if (($flags & 4) !== 0) $tmp['heading'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['period'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['proximity_notification_radius'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_inputMediaPoll(mixed $stream): mixed { +$tmp = ['_' => 'inputMediaPoll']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['poll'] = self::deserialize_type_Poll($stream); +if (($flags & 1) !== 0) $tmp['correct_answers'] = self::deserialize_type_array_of_bytes($stream); +if (($flags & 2) !== 0) $tmp['solution'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['solution_entities'] = self::deserialize_type_array_of_MessageEntity($stream); + +return $tmp; + } + private static function deserialize_inputMediaWebPage(mixed $stream): mixed { +$tmp = ['_' => 'inputMediaWebPage']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['force_large_media'] = ($flags & 1) !== 0; +$tmp['force_small_media'] = ($flags & 2) !== 0; +$tmp['optional'] = ($flags & 4) !== 0; +$tmp['url'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_InputMedia(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'髇' => [ +'_' => 'inputMediaEmpty', +], +'}(' => $this->deserialize_inputMediaUploadedPhoto($stream), +'5熙' => $this->deserialize_inputMediaPhoto($stream), +'DA蠡' => [ +'_' => 'inputMediaGeoPoint', +'geo_point' => self::deserialize_type_InputGeoPoint($stream), +], +'}拭' => [ +'_' => 'inputMediaContact', +'phone_number' => $this->deserialize_string($stream), +'first_name' => $this->deserialize_string($stream), +'last_name' => $this->deserialize_string($stream), +'vcard' => $this->deserialize_string($stream), +], +'谿8[' => $this->deserialize_inputMediaUploadedDocument($stream), +'X0G3' => $this->deserialize_inputMediaDocument($stream), +'=' => [ +'_' => 'inputMediaVenue', +'geo_point' => self::deserialize_type_InputGeoPoint($stream), +'title' => $this->deserialize_string($stream), +'address' => $this->deserialize_string($stream), +'provider' => $this->deserialize_string($stream), +'venue_id' => $this->deserialize_string($stream), +'venue_type' => $this->deserialize_string($stream), +], +'餃' => $this->deserialize_inputMediaPhotoExternal($stream), +'鄄' => $this->deserialize_inputMediaDocumentExternal($stream), +'譗?' => [ +'_' => 'inputMediaGame', +'id' => self::deserialize_type_InputGame($stream), +], +'捰' => $this->deserialize_inputMediaInvoice($stream), +'C' => $this->deserialize_inputMediaGeoLive($stream), +'鼫' => $this->deserialize_inputMediaPoll($stream), +'{穎' => [ +'_' => 'inputMediaDice', +'emoticon' => $this->deserialize_string($stream), +], +'x釹' => [ +'_' => 'inputMediaStory', +'peer' => self::deserialize_type_InputPeer($stream), +'id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'I' => $this->deserialize_inputMediaWebPage($stream), +'+r0' => $this->deserialize_type_InputMedia($stream), +default => self::err($stream) +} +; + } + private static function deserialize_draftMessage(mixed $stream): mixed { +$tmp = ['_' => 'draftMessage']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['no_webpage'] = ($flags & 2) !== 0; +$tmp['invert_media'] = ($flags & 64) !== 0; +if (($flags & 16) !== 0) $tmp['reply_to'] = self::deserialize_type_InputReplyTo($stream); +$tmp['message'] = $this->deserialize_string($stream); +if (($flags & 8) !== 0) $tmp['entities'] = self::deserialize_type_array_of_MessageEntity($stream); +if (($flags & 32) !== 0) $tmp['media'] = self::deserialize_type_InputMedia($stream); +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_DraftMessage(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' ' => $this->deserialize_draftMessageEmpty($stream), +'濷?' => $this->deserialize_draftMessage($stream), +'+r0' => $this->deserialize_type_DraftMessage($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateDraftMessage(mixed $stream): mixed { +$tmp = ['_' => 'updateDraftMessage']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['peer'] = self::deserialize_type_Peer($stream); +if (($flags & 1) !== 0) $tmp['top_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['draft'] = self::deserialize_type_DraftMessage($stream); + +return $tmp; + } + private function deserialize_type_DialogPeer(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'禦' => [ +'_' => 'dialogPeer', +'peer' => self::deserialize_type_Peer($stream), +], +'EQ' => [ +'_' => 'dialogPeerFolder', +'folder_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_DialogPeer($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateDialogPinned(mixed $stream): mixed { +$tmp = ['_' => 'updateDialogPinned']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['pinned'] = ($flags & 1) !== 0; +if (($flags & 2) !== 0) $tmp['folder_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['peer'] = self::deserialize_type_DialogPeer($stream); + +return $tmp; + } + private function deserialize_type_array_of_DialogPeer(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'禦' => [ +'_' => 'dialogPeer', +'peer' => self::deserialize_type_Peer($stream), +], +'EQ' => [ +'_' => 'dialogPeerFolder', +'folder_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => self::deserialize_type_DialogPeer($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_updatePinnedDialogs(mixed $stream): mixed { +$tmp = ['_' => 'updatePinnedDialogs']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['folder_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['order'] = self::deserialize_type_array_of_DialogPeer($stream); + +return $tmp; + } + private static function deserialize_updateBotPrecheckoutQuery(mixed $stream): mixed { +$tmp = ['_' => 'updateBotPrecheckoutQuery']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['query_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['payload'] = $this->deserialize_bytes($stream); +if (($flags & 1) !== 0) $tmp['info'] = self::deserialize_type_PaymentRequestedInfo($stream); +if (($flags & 2) !== 0) $tmp['shipping_option_id'] = $this->deserialize_string($stream); +$tmp['currency'] = $this->deserialize_string($stream); +$tmp['total_amount'] = unpack('q', stream_get_contents($stream, 8))[1]; + +return $tmp; + } + private static function deserialize_phoneCallProtocol(mixed $stream): mixed { +$tmp = ['_' => 'phoneCallProtocol']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['udp_p2p'] = ($flags & 1) !== 0; +$tmp['udp_reflector'] = ($flags & 2) !== 0; +$tmp['min_layer'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['max_layer'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['library_versions'] = self::deserialize_type_array_of_string($stream); + +return $tmp; + } + private function deserialize_type_PhoneCallProtocol(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'' => $this->deserialize_phoneCallProtocol($stream), +'+r0' => $this->deserialize_type_PhoneCallProtocol($stream), +default => self::err($stream) +} +; + } + private static function deserialize_phoneCallWaiting(mixed $stream): mixed { +$tmp = ['_' => 'phoneCallWaiting']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['video'] = ($flags & 64) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['admin_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['participant_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['protocol'] = self::deserialize_type_PhoneCallProtocol($stream); +if (($flags & 1) !== 0) $tmp['receive_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_phoneCallRequested(mixed $stream): mixed { +$tmp = ['_' => 'phoneCallRequested']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['video'] = ($flags & 64) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['admin_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['participant_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['g_a_hash'] = $this->deserialize_bytes($stream); +$tmp['protocol'] = self::deserialize_type_PhoneCallProtocol($stream); + +return $tmp; + } + private static function deserialize_phoneCallAccepted(mixed $stream): mixed { +$tmp = ['_' => 'phoneCallAccepted']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['video'] = ($flags & 64) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['admin_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['participant_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['g_b'] = $this->deserialize_bytes($stream); +$tmp['protocol'] = self::deserialize_type_PhoneCallProtocol($stream); + +return $tmp; + } + private static function deserialize_phoneConnection(mixed $stream): mixed { +$tmp = ['_' => 'phoneConnection']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['tcp'] = ($flags & 1) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['ip'] = $this->deserialize_string($stream); +$tmp['ipv6'] = $this->deserialize_string($stream); +$tmp['port'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['peer_tag'] = $this->deserialize_string($stream); + +return $tmp; + } + private static function deserialize_phoneConnectionWebrtc(mixed $stream): mixed { +$tmp = ['_' => 'phoneConnectionWebrtc']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['turn'] = ($flags & 1) !== 0; +$tmp['stun'] = ($flags & 2) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['ip'] = $this->deserialize_string($stream); +$tmp['ipv6'] = $this->deserialize_string($stream); +$tmp['port'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['username'] = $this->deserialize_string($stream); +$tmp['password'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_array_of_PhoneConnection(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'#' => $this->deserialize_phoneConnection($stream), +'u粿c' => $this->deserialize_phoneConnectionWebrtc($stream), +'+r0' => $this->deserialize_type_PhoneConnection($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_phoneCall(mixed $stream): mixed { +$tmp = ['_' => 'phoneCall']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['p2p_allowed'] = ($flags & 32) !== 0; +$tmp['video'] = ($flags & 64) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['admin_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['participant_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['g_a_or_b'] = $this->deserialize_bytes($stream); +$tmp['key_fingerprint'] = stream_get_contents($stream, 8); +$tmp['protocol'] = self::deserialize_type_PhoneCallProtocol($stream); +$tmp['connections'] = self::deserialize_type_array_of_PhoneConnection($stream); +$tmp['start_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_phoneCallDiscarded(mixed $stream): mixed { +$tmp = ['_' => 'phoneCallDiscarded']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['need_rating'] = ($flags & 4) !== 0; +$tmp['need_debug'] = ($flags & 8) !== 0; +$tmp['video'] = ($flags & 64) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['reason'] = self::deserialize_type_PhoneCallDiscardReason($stream); +if (($flags & 2) !== 0) $tmp['duration'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_PhoneCall(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'仜S' => [ +'_' => 'phoneCallEmpty', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'o"' => $this->deserialize_phoneCallWaiting($stream), +' 禨' => $this->deserialize_phoneCallRequested($stream), +'嚥6' => $this->deserialize_phoneCallAccepted($stream), +'g|' => $this->deserialize_phoneCall($stream), +'嘜襾' => $this->deserialize_phoneCallDiscarded($stream), +'+r0' => $this->deserialize_type_PhoneCall($stream), +default => self::err($stream) +} +; + } + private static function deserialize_langPackStringPluralized(mixed $stream): mixed { +$tmp = ['_' => 'langPackStringPluralized']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['key'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['zero_value'] = $this->deserialize_string($stream); +if (($flags & 2) !== 0) $tmp['one_value'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['two_value'] = $this->deserialize_string($stream); +if (($flags & 8) !== 0) $tmp['few_value'] = $this->deserialize_string($stream); +if (($flags & 16) !== 0) $tmp['many_value'] = $this->deserialize_string($stream); +$tmp['other_value'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_array_of_LangPackString(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'捗' => [ +'_' => 'langPackString', +'key' => $this->deserialize_string($stream), +'value' => $this->deserialize_string($stream), +], +'故l' => $this->deserialize_langPackStringPluralized($stream), +'船y)' => [ +'_' => 'langPackStringDeleted', +'key' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_LangPackString($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_LangPackDifference(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'鶬' => [ +'_' => 'langPackDifference', +'lang_code' => $this->deserialize_string($stream), +'from_version' => unpack('l', stream_get_contents($stream, 4))[1], +'version' => unpack('l', stream_get_contents($stream, 4))[1], +'strings' => self::deserialize_type_array_of_LangPackString($stream), +], +'+r0' => $this->deserialize_type_LangPackDifference($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateChannelReadMessagesContents(mixed $stream): mixed { +$tmp = ['_' => 'updateChannelReadMessagesContents']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['top_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['messages'] = self::deserialize_type_array_of_int($stream); + +return $tmp; + } + private static function deserialize_updateDialogUnreadMark(mixed $stream): mixed { +$tmp = ['_' => 'updateDialogUnreadMark']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['unread'] = ($flags & 1) !== 0; +$tmp['peer'] = self::deserialize_type_DialogPeer($stream); + +return $tmp; + } + private static function deserialize_updateMessagePoll(mixed $stream): mixed { +$tmp = ['_' => 'updateMessagePoll']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['poll_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['poll'] = self::deserialize_type_Poll($stream); +$tmp['results'] = self::deserialize_type_PollResults($stream); + +return $tmp; + } + private function deserialize_type_array_of_FolderPeer(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'h死' => [ +'_' => 'folderPeer', +'peer' => self::deserialize_type_Peer($stream), +'folder_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_FolderPeer($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_peerSettings(mixed $stream): mixed { +$tmp = ['_' => 'peerSettings']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['report_spam'] = ($flags & 1) !== 0; +$tmp['add_contact'] = ($flags & 2) !== 0; +$tmp['block_contact'] = ($flags & 4) !== 0; +$tmp['share_contact'] = ($flags & 8) !== 0; +$tmp['need_contacts_exception'] = ($flags & 16) !== 0; +$tmp['report_geo'] = ($flags & 32) !== 0; +$tmp['autoarchived'] = ($flags & 128) !== 0; +$tmp['invite_members'] = ($flags & 256) !== 0; +$tmp['request_chat_broadcast'] = ($flags & 1024) !== 0; +if (($flags & 64) !== 0) $tmp['geo_distance'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 512) !== 0) $tmp['request_chat_title'] = $this->deserialize_string($stream); +if (($flags & 512) !== 0) $tmp['request_chat_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_PeerSettings(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' ' => $this->deserialize_peerSettings($stream), +'+r0' => $this->deserialize_type_PeerSettings($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_PeerLocated(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +']F' => [ +'_' => 'peerLocated', +'peer' => self::deserialize_type_Peer($stream), +'expires' => unpack('l', stream_get_contents($stream, 4))[1], +'distance' => unpack('l', stream_get_contents($stream, 4))[1], +], +'K(檟' => [ +'_' => 'peerSelfLocated', +'expires' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_PeerLocated($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_array_of_ThemeSettings(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'堈X' => $this->deserialize_themeSettings($stream), +'+r0' => self::deserialize_type_ThemeSettings($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_theme(mixed $stream): mixed { +$tmp = ['_' => 'theme']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['creator'] = ($flags & 1) !== 0; +$tmp['default'] = ($flags & 2) !== 0; +$tmp['for_chat'] = ($flags & 32) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['slug'] = $this->deserialize_string($stream); +$tmp['title'] = $this->deserialize_string($stream); +if (($flags & 4) !== 0) $tmp['document'] = self::deserialize_type_Document($stream); +if (($flags & 8) !== 0) $tmp['settings'] = self::deserialize_type_array_of_ThemeSettings($stream); +if (($flags & 64) !== 0) $tmp['emoticon'] = $this->deserialize_string($stream); +if (($flags & 16) !== 0) $tmp['installs_count'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_Theme(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'狿' => $this->deserialize_theme($stream), +'+r0' => $this->deserialize_type_Theme($stream), +default => self::err($stream) +} +; + } + private function deserialize_type_array_of_InputPeer(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +';' => [ +'_' => 'inputPeerEmpty', +], +'氕}' => [ +'_' => 'inputPeerSelf', +], +'鈾\5' => [ +'_' => 'inputPeerChat', +'chat_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'L亥' => [ +'_' => 'inputPeerUser', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +'遞\'' => [ +'_' => 'inputPeerChannel', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +], +' +{' => [ +'_' => 'inputPeerUserFromMessage', +'peer' => self::deserialize_type_InputPeer($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'@*' => [ +'_' => 'inputPeerChannelFromMessage', +'peer' => self::deserialize_type_InputPeer($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'+r0' => self::deserialize_type_InputPeer($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_dialogFilter(mixed $stream): mixed { +$tmp = ['_' => 'dialogFilter']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['contacts'] = ($flags & 1) !== 0; +$tmp['non_contacts'] = ($flags & 2) !== 0; +$tmp['groups'] = ($flags & 4) !== 0; +$tmp['broadcasts'] = ($flags & 8) !== 0; +$tmp['bots'] = ($flags & 16) !== 0; +$tmp['exclude_muted'] = ($flags & 2048) !== 0; +$tmp['exclude_read'] = ($flags & 4096) !== 0; +$tmp['exclude_archived'] = ($flags & 8192) !== 0; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['title'] = $this->deserialize_string($stream); +if (($flags & 33554432) !== 0) $tmp['emoticon'] = $this->deserialize_string($stream); +if (($flags & 134217728) !== 0) $tmp['color'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['pinned_peers'] = self::deserialize_type_array_of_InputPeer($stream); +$tmp['include_peers'] = self::deserialize_type_array_of_InputPeer($stream); +$tmp['exclude_peers'] = self::deserialize_type_array_of_InputPeer($stream); + +return $tmp; + } + private static function deserialize_dialogFilterChatlist(mixed $stream): mixed { +$tmp = ['_' => 'dialogFilterChatlist']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['has_my_invites'] = ($flags & 67108864) !== 0; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['title'] = $this->deserialize_string($stream); +if (($flags & 33554432) !== 0) $tmp['emoticon'] = $this->deserialize_string($stream); +if (($flags & 134217728) !== 0) $tmp['color'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['pinned_peers'] = self::deserialize_type_array_of_InputPeer($stream); +$tmp['include_peers'] = self::deserialize_type_array_of_InputPeer($stream); + +return $tmp; + } + private function deserialize_type_DialogFilter(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +';R琯' => $this->deserialize_dialogFilter($stream), +'26' => [ +'_' => 'dialogFilterDefault', +], +'' => $this->deserialize_dialogFilterChatlist($stream), +'+r0' => $this->deserialize_type_DialogFilter($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateDialogFilter(mixed $stream): mixed { +$tmp = ['_' => 'updateDialogFilter']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['filter'] = self::deserialize_type_DialogFilter($stream); + +return $tmp; + } + private static function deserialize_updateReadChannelDiscussionInbox(mixed $stream): mixed { +$tmp = ['_' => 'updateReadChannelDiscussionInbox']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['top_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['read_max_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['broadcast_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['broadcast_post'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_updatePeerBlocked(mixed $stream): mixed { +$tmp = ['_' => 'updatePeerBlocked']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['blocked'] = ($flags & 1) !== 0; +$tmp['blocked_my_stories_from'] = ($flags & 2) !== 0; +$tmp['peer_id'] = self::deserialize_type_Peer($stream); + +return $tmp; + } + private static function deserialize_updateChannelUserTyping(mixed $stream): mixed { +$tmp = ['_' => 'updateChannelUserTyping']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['top_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['from_id'] = self::deserialize_type_Peer($stream); +$tmp['action'] = self::deserialize_type_SendMessageAction($stream); + +return $tmp; + } + private static function deserialize_updatePinnedMessages(mixed $stream): mixed { +$tmp = ['_' => 'updatePinnedMessages']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['pinned'] = ($flags & 1) !== 0; +$tmp['peer'] = self::deserialize_type_Peer($stream); +$tmp['messages'] = self::deserialize_type_array_of_int($stream); +$tmp['pts'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['pts_count'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_updatePinnedChannelMessages(mixed $stream): mixed { +$tmp = ['_' => 'updatePinnedChannelMessages']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['pinned'] = ($flags & 1) !== 0; +$tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['messages'] = self::deserialize_type_array_of_int($stream); +$tmp['pts'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['pts_count'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_array_of_GroupCallParticipantVideoSourceGroup(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'旌' => [ +'_' => 'groupCallParticipantVideoSourceGroup', +'semantics' => $this->deserialize_string($stream), +'sources' => self::deserialize_type_array_of_int($stream), +], +'+r0' => $this->deserialize_type_GroupCallParticipantVideoSourceGroup($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_groupCallParticipantVideo(mixed $stream): mixed { +$tmp = ['_' => 'groupCallParticipantVideo']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['paused'] = ($flags & 1) !== 0; +$tmp['endpoint'] = $this->deserialize_string($stream); +$tmp['source_groups'] = self::deserialize_type_array_of_GroupCallParticipantVideoSourceGroup($stream); +if (($flags & 2) !== 0) $tmp['audio_source'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_GroupCallParticipantVideo(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +':ug' => $this->deserialize_groupCallParticipantVideo($stream), +'+r0' => $this->deserialize_type_GroupCallParticipantVideo($stream), +default => self::err($stream) +} +; + } + private static function deserialize_groupCallParticipant(mixed $stream): mixed { +$tmp = ['_' => 'groupCallParticipant']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['muted'] = ($flags & 1) !== 0; +$tmp['left'] = ($flags & 2) !== 0; +$tmp['can_self_unmute'] = ($flags & 4) !== 0; +$tmp['just_joined'] = ($flags & 16) !== 0; +$tmp['versioned'] = ($flags & 32) !== 0; +$tmp['min'] = ($flags & 256) !== 0; +$tmp['muted_by_you'] = ($flags & 512) !== 0; +$tmp['volume_by_admin'] = ($flags & 1024) !== 0; +$tmp['self'] = ($flags & 4096) !== 0; +$tmp['video_joined'] = ($flags & 32768) !== 0; +$tmp['peer'] = self::deserialize_type_Peer($stream); +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['active_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['source'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 128) !== 0) $tmp['volume'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2048) !== 0) $tmp['about'] = $this->deserialize_string($stream); +if (($flags & 8192) !== 0) $tmp['raise_hand_rating'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 64) !== 0) $tmp['video'] = self::deserialize_type_GroupCallParticipantVideo($stream); +if (($flags & 16384) !== 0) $tmp['presentation'] = self::deserialize_type_GroupCallParticipantVideo($stream); + +return $tmp; + } + private function deserialize_type_array_of_GroupCallParticipant(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'6亨' => $this->deserialize_groupCallParticipant($stream), +'+r0' => $this->deserialize_type_GroupCallParticipant($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_groupCall(mixed $stream): mixed { +$tmp = ['_' => 'groupCall']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['join_muted'] = ($flags & 2) !== 0; +$tmp['can_change_join_muted'] = ($flags & 4) !== 0; +$tmp['join_date_asc'] = ($flags & 64) !== 0; +$tmp['schedule_start_subscribed'] = ($flags & 256) !== 0; +$tmp['can_start_video'] = ($flags & 512) !== 0; +$tmp['record_video_active'] = ($flags & 2048) !== 0; +$tmp['rtmp_stream'] = ($flags & 4096) !== 0; +$tmp['listeners_hidden'] = ($flags & 8192) !== 0; +$tmp['id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['access_hash'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['participants_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['title'] = $this->deserialize_string($stream); +if (($flags & 16) !== 0) $tmp['stream_dc_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 32) !== 0) $tmp['record_start_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 128) !== 0) $tmp['schedule_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1024) !== 0) $tmp['unmuted_video_count'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['unmuted_video_limit'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['version'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_GroupCall(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'智w' => [ +'_' => 'groupCallDiscarded', +'id' => unpack('q', stream_get_contents($stream, 8))[1], +'access_hash' => unpack('q', stream_get_contents($stream, 8))[1], +'duration' => unpack('l', stream_get_contents($stream, 4))[1], +], +' e' => $this->deserialize_groupCall($stream), +'+r0' => $this->deserialize_type_GroupCall($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updatePeerHistoryTTL(mixed $stream): mixed { +$tmp = ['_' => 'updatePeerHistoryTTL']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['peer'] = self::deserialize_type_Peer($stream); +if (($flags & 1) !== 0) $tmp['ttl_period'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_chatInviteExported(mixed $stream): mixed { +$tmp = ['_' => 'chatInviteExported']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['revoked'] = ($flags & 1) !== 0; +$tmp['permanent'] = ($flags & 32) !== 0; +$tmp['request_needed'] = ($flags & 64) !== 0; +$tmp['link'] = $this->deserialize_string($stream); +$tmp['admin_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 16) !== 0) $tmp['start_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['expire_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 4) !== 0) $tmp['usage_limit'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 8) !== 0) $tmp['usage'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 128) !== 0) $tmp['requested'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 256) !== 0) $tmp['title'] = $this->deserialize_string($stream); + +return $tmp; + } + private function deserialize_type_ExportedChatInvite(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'迄 +' => $this->deserialize_chatInviteExported($stream), +'暘' => [ +'_' => 'chatInvitePublicJoinRequests', +], +'+r0' => $this->deserialize_type_ExportedChatInvite($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateChatParticipant(mixed $stream): mixed { +$tmp = ['_' => 'updateChatParticipant']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['chat_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['actor_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['prev_participant'] = self::deserialize_type_ChatParticipant($stream); +if (($flags & 2) !== 0) $tmp['new_participant'] = self::deserialize_type_ChatParticipant($stream); +if (($flags & 4) !== 0) $tmp['invite'] = self::deserialize_type_ExportedChatInvite($stream); +$tmp['qts'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_channelParticipantSelf(mixed $stream): mixed { +$tmp = ['_' => 'channelParticipantSelf']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['via_request'] = ($flags & 1) !== 0; +$tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['inviter_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_channelParticipantCreator(mixed $stream): mixed { +$tmp = ['_' => 'channelParticipantCreator']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['admin_rights'] = self::deserialize_type_ChatAdminRights($stream); +if (($flags & 1) !== 0) $tmp['rank'] = $this->deserialize_string($stream); + +return $tmp; + } + private static function deserialize_channelParticipantAdmin(mixed $stream): mixed { +$tmp = ['_' => 'channelParticipantAdmin']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['can_edit'] = ($flags & 1) !== 0; +$tmp['self'] = ($flags & 2) !== 0; +$tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 2) !== 0) $tmp['inviter_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['promoted_by'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['admin_rights'] = self::deserialize_type_ChatAdminRights($stream); +if (($flags & 4) !== 0) $tmp['rank'] = $this->deserialize_string($stream); + +return $tmp; + } + private static function deserialize_channelParticipantBanned(mixed $stream): mixed { +$tmp = ['_' => 'channelParticipantBanned']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['left'] = ($flags & 1) !== 0; +$tmp['peer'] = self::deserialize_type_Peer($stream); +$tmp['kicked_by'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['banned_rights'] = self::deserialize_type_ChatBannedRights($stream); + +return $tmp; + } + private function deserialize_type_ChannelParticipant(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' ' => [ +'_' => 'channelParticipant', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +], +'尿5' => $this->deserialize_channelParticipantSelf($stream), +'/' => $this->deserialize_channelParticipantCreator($stream), +'S酵4' => $this->deserialize_channelParticipantAdmin($stream), +'N鷰' => $this->deserialize_channelParticipantBanned($stream), +'' => [ +'_' => 'channelParticipantLeft', +'peer' => self::deserialize_type_Peer($stream), +], +'+r0' => $this->deserialize_type_ChannelParticipant($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateChannelParticipant(mixed $stream): mixed { +$tmp = ['_' => 'updateChannelParticipant']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['via_chatlist'] = ($flags & 8) !== 0; +$tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['actor_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['prev_participant'] = self::deserialize_type_ChannelParticipant($stream); +if (($flags & 2) !== 0) $tmp['new_participant'] = self::deserialize_type_ChannelParticipant($stream); +if (($flags & 4) !== 0) $tmp['invite'] = self::deserialize_type_ExportedChatInvite($stream); +$tmp['qts'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_updateGroupCallConnection(mixed $stream): mixed { +$tmp = ['_' => 'updateGroupCallConnection']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['presentation'] = ($flags & 1) !== 0; +$tmp['params'] = self::deserialize_type_DataJSON($stream); + +return $tmp; + } + private function deserialize_type_array_of_BotCommand(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'аz' => [ +'_' => 'botCommand', +'command' => $this->deserialize_string($stream), +'description' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_BotCommand($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_updateMessageReactions(mixed $stream): mixed { +$tmp = ['_' => 'updateMessageReactions']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['peer'] = self::deserialize_type_Peer($stream); +$tmp['msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['top_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['reactions'] = self::deserialize_type_MessageReactions($stream); + +return $tmp; + } + private function deserialize_type_BotMenuButton(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'3u' => [ +'_' => 'botMenuButtonDefault', +], +'擴B' => [ +'_' => 'botMenuButtonCommands', +], +'獡腎' => [ +'_' => 'botMenuButton', +'text' => $this->deserialize_string($stream), +'url' => $this->deserialize_string($stream), +], +'+r0' => $this->deserialize_type_BotMenuButton($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updateTranscribedAudio(mixed $stream): mixed { +$tmp = ['_' => 'updateTranscribedAudio']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['pending'] = ($flags & 1) !== 0; +$tmp['peer'] = self::deserialize_type_Peer($stream); +$tmp['msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['transcription_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['text'] = $this->deserialize_string($stream); + +return $tmp; + } + private static function deserialize_updateMoveStickerSetToTop(mixed $stream): mixed { +$tmp = ['_' => 'updateMoveStickerSetToTop']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['masks'] = ($flags & 1) !== 0; +$tmp['emojis'] = ($flags & 2) !== 0; +$tmp['stickerset'] = unpack('q', stream_get_contents($stream, 8))[1]; + +return $tmp; + } + private static function deserialize_updateChannelPinnedTopic(mixed $stream): mixed { +$tmp = ['_' => 'updateChannelPinnedTopic']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['pinned'] = ($flags & 1) !== 0; +$tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['topic_id'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private static function deserialize_updateChannelPinnedTopics(mixed $stream): mixed { +$tmp = ['_' => 'updateChannelPinnedTopics']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['channel_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 1) !== 0) $tmp['order'] = self::deserialize_type_array_of_int($stream); + +return $tmp; + } + private static function deserialize_storiesStealthMode(mixed $stream): mixed { +$tmp = ['_' => 'storiesStealthMode']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['active_until_date'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 2) !== 0) $tmp['cooldown_until_date'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_StoriesStealthMode(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'\'.q' => $this->deserialize_storiesStealthMode($stream), +'+r0' => $this->deserialize_type_StoriesStealthMode($stream), +default => self::err($stream) +} +; + } + private static function deserialize_boost(mixed $stream): mixed { +$tmp = ['_' => 'boost']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['gift'] = ($flags & 2) !== 0; +$tmp['giveaway'] = ($flags & 4) !== 0; +$tmp['unclaimed'] = ($flags & 8) !== 0; +$tmp['id'] = $this->deserialize_string($stream); +if (($flags & 1) !== 0) $tmp['user_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +if (($flags & 4) !== 0) $tmp['giveaway_msg_id'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['date'] = unpack('l', stream_get_contents($stream, 4))[1]; +$tmp['expires'] = unpack('l', stream_get_contents($stream, 4))[1]; +if (($flags & 16) !== 0) $tmp['used_gift_slug'] = $this->deserialize_string($stream); +if (($flags & 32) !== 0) $tmp['multiplier'] = unpack('l', stream_get_contents($stream, 4))[1]; + +return $tmp; + } + private function deserialize_type_Boost(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'q*' => $this->deserialize_boost($stream), +'+r0' => $this->deserialize_type_Boost($stream), +default => self::err($stream) +} +; + } + private static function deserialize_updatePeerWallpaper(mixed $stream): mixed { +$tmp = ['_' => 'updatePeerWallpaper']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['wallpaper_overridden'] = ($flags & 2) !== 0; +$tmp['peer'] = self::deserialize_type_Peer($stream); +if (($flags & 1) !== 0) $tmp['wallpaper'] = self::deserialize_type_WallPaper($stream); + +return $tmp; + } + private function deserialize_type_array_of_Reaction(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'崋y' => [ +'_' => 'reactionEmpty', +], +'"' => [ +'_' => 'reactionEmoji', +'emoticon' => $this->deserialize_string($stream), +], +'s5' => [ +'_' => 'reactionCustomEmoji', +'document_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'+r0' => self::deserialize_type_Reaction($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private static function deserialize_updateSavedDialogPinned(mixed $stream): mixed { +$tmp = ['_' => 'updateSavedDialogPinned']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +$tmp['pinned'] = ($flags & 1) !== 0; +$tmp['peer'] = self::deserialize_type_DialogPeer($stream); + +return $tmp; + } + private static function deserialize_updatePinnedSavedDialogs(mixed $stream): mixed { +$tmp = ['_' => 'updatePinnedSavedDialogs']; +$flags = unpack('V', stream_get_contents($stream, 4))[1]; +if (($flags & 1) !== 0) $tmp['order'] = self::deserialize_type_array_of_DialogPeer($stream); + +return $tmp; + } + private function deserialize_type_array_of_QuickReply(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= match (stream_get_contents($stream, 4)) { +'+' => [ +'_' => 'quickReply', +'shortcut_id' => unpack('l', stream_get_contents($stream, 4))[1], +'shortcut' => $this->deserialize_string($stream), +'top_message' => unpack('l', stream_get_contents($stream, 4))[1], +'count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_QuickReply($stream), +default => self::err($stream) +} +; + } + return $result; + + } + private function deserialize_type_QuickReply(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'+' => [ +'_' => 'quickReply', +'shortcut_id' => unpack('l', stream_get_contents($stream, 4))[1], +'shortcut' => $this->deserialize_string($stream), +'top_message' => unpack('l', stream_get_contents($stream, 4))[1], +'count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize_type_QuickReply($stream), +default => self::err($stream) +} +; + } + private static function deserialize_rpc_result(mixed $stream): mixed { +$tmp = ['_' => 'rpc_result']; +$tmp['req_msg_id'] = unpack('q', stream_get_contents($stream, 8))[1]; +$tmp['result'] = $this->deserialize_type_Object($stream); + +return $tmp; + } + private function deserialize_type_array_of_future_salt(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= [ +'_' => 'future_salt', +'valid_since' => unpack('l', stream_get_contents($stream, 4))[1], +'valid_until' => unpack('l', stream_get_contents($stream, 4))[1], +'salt' => unpack('q', stream_get_contents($stream, 8))[1], +]; + } + return $result; + + } + private function deserialize_type_array_of_MTmessage(mixed $stream): array { + + $stream = match(stream_get_contents($stream, 4)) { + '警' => $stream, + '+r0' => self::gzdecode_vector($stream) + }; + $result = []; + for ($x = unpack("V", stream_get_contents($stream, 4))[1]; $x > 0; --$x) { + $result []= [ +'_' => 'MTmessage', +'msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'seqno' => unpack('l', stream_get_contents($stream, 4))[1], +'bytes' => unpack('l', stream_get_contents($stream, 4))[1], +'body' => $this->deserialize_type_Object($stream), +]; + } + return $result; + + } + private function deserialize_type_MTMessage(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +'撣[' => [ +'_' => 'MTmessage', +'msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'seqno' => unpack('l', stream_get_contents($stream, 4))[1], +'bytes' => unpack('l', stream_get_contents($stream, 4))[1], +'body' => $this->deserialize_type_Object($stream), +], +'+r0' => $this->deserialize_type_MTMessage($stream), +default => self::err($stream) +} +; + } + public function deserialize(mixed $stream): mixed { +return match (stream_get_contents($stream, 4)) { +' ++' => [ +'_' => 'updateNewMessage', +'message' => self::deserialize_type_Message($stream), +'pts' => unpack('l', stream_get_contents($stream, 4))[1], +'pts_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'祪N' => [ +'_' => 'updateMessageID', +'id' => unpack('l', stream_get_contents($stream, 4))[1], +'random_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'撠 ' => [ +'_' => 'updateDeleteMessages', +'messages' => self::deserialize_type_array_of_int($stream), +'pts' => unpack('l', stream_get_contents($stream, 4))[1], +'pts_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'' => [ +'_' => 'updateUserTyping', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'action' => self::deserialize_type_SendMessageAction($stream), +], +'翷H' => [ +'_' => 'updateChatUserTyping', +'chat_id' => unpack('q', stream_get_contents($stream, 8))[1], +'from_id' => self::deserialize_type_Peer($stream), +'action' => self::deserialize_type_SendMessageAction($stream), +], +'v' => [ +'_' => 'updateChatParticipants', +'participants' => self::deserialize_type_ChatParticipants($stream), +], +'稘賢' => [ +'_' => 'updateUserStatus', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'status' => self::deserialize_type_UserStatus($stream), +], +'$' => [ +'_' => 'updateUserName', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'first_name' => $this->deserialize_string($stream), +'last_name' => $this->deserialize_string($stream), +'usernames' => self::deserialize_type_array_of_Username($stream), +], +'麉Q' => $this->deserialize_updateNewAuthorization($stream), +'蝦' => [ +'_' => 'updateNewEncryptedMessage', +'message' => self::deserialize_type_EncryptedMessage($stream), +'qts' => unpack('l', stream_get_contents($stream, 4))[1], +], +'V' => [ +'_' => 'updateEncryptedChatTyping', +'chat_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'鋡' => [ +'_' => 'updateEncryption', +'chat' => self::deserialize_type_EncryptedChat($stream), +'date' => unpack('l', stream_get_contents($stream, 4))[1], +], +'%8' => [ +'_' => 'updateEncryptedMessagesRead', +'chat_id' => unpack('l', stream_get_contents($stream, 4))[1], +'max_date' => unpack('l', stream_get_contents($stream, 4))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +], +'QT=' => [ +'_' => 'updateChatParticipantAdd', +'chat_id' => unpack('q', stream_get_contents($stream, 8))[1], +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'inviter_id' => unpack('q', stream_get_contents($stream, 8))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'version' => unpack('l', stream_get_contents($stream, 4))[1], +], +'w=/' => [ +'_' => 'updateChatParticipantDelete', +'chat_id' => unpack('q', stream_get_contents($stream, 8))[1], +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'version' => unpack('l', stream_get_contents($stream, 4))[1], +], +'s^' => [ +'_' => 'updateDcOptions', +'dc_options' => self::deserialize_type_array_of_DcOption($stream), +], +'髼職' => [ +'_' => 'updateNotifySettings', +'peer' => self::deserialize_type_NotifyPeer($stream), +'notify_settings' => self::deserialize_type_PeerNotifySettings($stream), +], +'h儇' => $this->deserialize_updateServiceNotification($stream), +'*\';' => [ +'_' => 'updatePrivacy', +'key' => self::deserialize_type_PrivacyKey($stream), +'rules' => self::deserialize_type_array_of_PrivacyRule($stream), +], +'*I' => [ +'_' => 'updateUserPhone', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'phone' => $this->deserialize_string($stream), +], +'筰' => $this->deserialize_updateReadHistoryInbox($stream), +'!//' => [ +'_' => 'updateReadHistoryOutbox', +'peer' => self::deserialize_type_Peer($stream), +'max_id' => unpack('l', stream_get_contents($stream, 4))[1], +'pts' => unpack('l', stream_get_contents($stream, 4))[1], +'pts_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'' => [ +'_' => 'updateWebPage', +'webpage' => self::deserialize_type_WebPage($stream), +'pts' => unpack('l', stream_get_contents($stream, 4))[1], +'pts_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'q"' => $this->deserialize_updateReadMessagesContents($stream), +'' => $this->deserialize_updateChannelTooLong($stream), +' L[c' => [ +'_' => 'updateChannel', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'槓' => [ +'_' => 'updateNewChannelMessage', +'message' => self::deserialize_type_Message($stream), +'pts' => unpack('l', stream_get_contents($stream, 4))[1], +'pts_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'n.' => $this->deserialize_updateReadChannelInbox($stream), +'[-' => [ +'_' => 'updateDeleteChannelMessages', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'messages' => self::deserialize_type_array_of_int($stream), +'pts' => unpack('l', stream_get_contents($stream, 4))[1], +'pts_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'&' => [ +'_' => 'updateChannelMessageViews', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'id' => unpack('l', stream_get_contents($stream, 4))[1], +'views' => unpack('l', stream_get_contents($stream, 4))[1], +], +'糎忑' => [ +'_' => 'updateChatParticipantAdmin', +'chat_id' => unpack('q', stream_get_contents($stream, 8))[1], +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'is_admin' => match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }, +'version' => unpack('l', stream_get_contents($stream, 4))[1], +], +'0h' => [ +'_' => 'updateNewStickerSet', +'stickerset' => self::deserialize_type_messages___StickerSet($stream), +], +'珩 ' => $this->deserialize_updateStickerSetsOrder($stream), +'H1' => $this->deserialize_updateStickerSets($stream), +'4u' => [ +'_' => 'updateSavedGifs', +], +'7oI' => $this->deserialize_updateBotInlineQuery($stream), +'*' => $this->deserialize_updateBotInlineSend($stream), +'蠬?' => [ +'_' => 'updateEditChannelMessage', +'message' => self::deserialize_type_Message($stream), +'pts' => unpack('l', stream_get_contents($stream, 4))[1], +'pts_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'鰍' => $this->deserialize_updateBotCallbackQuery($stream), +'φ' => [ +'_' => 'updateEditMessage', +'message' => self::deserialize_type_Message($stream), +'pts' => unpack('l', stream_get_contents($stream, 4))[1], +'pts_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'Ri' => $this->deserialize_updateInlineBotCallbackQuery($stream), +'_' => [ +'_' => 'updateReadChannelOutbox', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'max_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'m閹' => $this->deserialize_updateDraftMessage($stream), +'B\'W' => [ +'_' => 'updateReadFeaturedStickers', +], +' ,B' => [ +'_' => 'updateRecentStickers', +], +')' => [ +'_' => 'updateConfig', +], +'gT3' => [ +'_' => 'updatePtsChanged', +], +'+/' => [ +'_' => 'updateChannelWebPage', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'webpage' => self::deserialize_type_WebPage($stream), +'pts' => unpack('l', stream_get_contents($stream, 4))[1], +'pts_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'幝n' => $this->deserialize_updateDialogPinned($stream), +'<' => $this->deserialize_updatePinnedDialogs($stream), +'藝' => [ +'_' => 'updateBotWebhookJSON', +'data' => self::deserialize_type_DataJSON($stream), +], +'共' => [ +'_' => 'updateBotWebhookJSONQuery', +'query_id' => unpack('q', stream_get_contents($stream, 8))[1], +'data' => self::deserialize_type_DataJSON($stream), +'timeout' => unpack('l', stream_get_contents($stream, 4))[1], +], +'}挾' => [ +'_' => 'updateBotShippingQuery', +'query_id' => unpack('q', stream_get_contents($stream, 8))[1], +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'payload' => $this->deserialize_bytes($stream), +'shipping_address' => self::deserialize_type_PostAddress($stream), +], +'' => $this->deserialize_updateBotPrecheckoutQuery($stream), +'k' => [ +'_' => 'updatePhoneCall', +'phone_call' => self::deserialize_type_PhoneCall($stream), +], +'dVF' => [ +'_' => 'updateLangPackTooLong', +'lang_code' => $this->deserialize_string($stream), +], +'M/V' => [ +'_' => 'updateLangPack', +'difference' => self::deserialize_type_LangPackDifference($stream), +], +'m' => [ +'_' => 'updateFavedStickers', +], +'])' => $this->deserialize_updateChannelReadMessagesContents($stream), +'儒p' => [ +'_' => 'updateContactsReset', +], +'?' => [ +'_' => 'updateChannelAvailableMessages', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'available_min_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'鵑d' => $this->deserialize_updateDialogUnreadMark($stream), +'{e′' => $this->deserialize_updateMessagePoll($stream), +'P鞘' => [ +'_' => 'updateChatDefaultBannedRights', +'peer' => self::deserialize_type_Peer($stream), +'default_banned_rights' => self::deserialize_type_ChatBannedRights($stream), +'version' => unpack('l', stream_get_contents($stream, 4))[1], +], +' 6' => [ +'_' => 'updateFolderPeers', +'folder_peers' => self::deserialize_type_array_of_FolderPeer($stream), +'pts' => unpack('l', stream_get_contents($stream, 4))[1], +'pts_count' => unpack('l', stream_get_contents($stream, 4))[1], +], +'fs~j' => [ +'_' => 'updatePeerSettings', +'peer' => self::deserialize_type_Peer($stream), +'settings' => self::deserialize_type_PeerSettings($stream), +], +'區秩' => [ +'_' => 'updatePeerLocated', +'peers' => self::deserialize_type_array_of_PeerLocated($stream), +], +'9' => [ +'_' => 'updateNewScheduledMessage', +'message' => self::deserialize_type_Message($stream), +], +'螿' => [ +'_' => 'updateDeleteScheduledMessages', +'peer' => self::deserialize_type_Peer($stream), +'messages' => self::deserialize_type_array_of_int($stream), +], +'' => [ +'_' => 'updateTheme', +'theme' => self::deserialize_type_Theme($stream), +], +'9' => [ +'_' => 'updateGeoLiveViewed', +'peer' => self::deserialize_type_Peer($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'潗V' => [ +'_' => 'updateLoginToken', +], +'w$' => [ +'_' => 'updateMessagePollVote', +'poll_id' => unpack('q', stream_get_contents($stream, 8))[1], +'peer' => self::deserialize_type_Peer($stream), +'options' => self::deserialize_type_array_of_bytes($stream), +'qts' => unpack('l', stream_get_contents($stream, 4))[1], +], +'}&' => $this->deserialize_updateDialogFilter($stream), +'!蚰' => [ +'_' => 'updateDialogFilterOrder', +'order' => self::deserialize_type_array_of_int($stream), +], +'O5' => [ +'_' => 'updateDialogFilters', +], +' 瘸&' => [ +'_' => 'updatePhoneCallSignalingData', +'phone_call_id' => unpack('q', stream_get_contents($stream, 8))[1], +'data' => $this->deserialize_bytes($stream), +], +'瀵'' => [ +'_' => 'updateChannelMessageForwards', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'id' => unpack('l', stream_get_contents($stream, 4))[1], +'forwards' => unpack('l', stream_get_contents($stream, 4))[1], +], +'F敔' => $this->deserialize_updateReadChannelDiscussionInbox($stream), +'|\\i' => [ +'_' => 'updateReadChannelDiscussionOutbox', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'top_msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'read_max_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'Rw鳪' => $this->deserialize_updatePeerBlocked($stream), +'#' => $this->deserialize_updateChannelUserTyping($stream), +'虛' => $this->deserialize_updatePinnedMessages($stream), +'鉀' => $this->deserialize_updatePinnedChannelMessages($stream), +'Nj' => [ +'_' => 'updateChat', +'chat_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'N貹' => [ +'_' => 'updateGroupCallParticipants', +'call' => self::deserialize_type_InputGroupCall($stream), +'participants' => self::deserialize_type_array_of_GroupCallParticipant($stream), +'version' => unpack('l', stream_get_contents($stream, 4))[1], +], +'' . "\0" . 'E' => [ +'_' => 'updateGroupCall', +'chat_id' => unpack('q', stream_get_contents($stream, 8))[1], +'call' => self::deserialize_type_GroupCall($stream), +], +'旦' => $this->deserialize_updatePeerHistoryTTL($stream), +':f' => $this->deserialize_updateChatParticipant($stream), +':]' => $this->deserialize_updateChannelParticipant($stream), +'I +' => [ +'_' => 'updateBotStopped', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'stopped' => match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }, +'qts' => unpack('l', stream_get_contents($stream, 4))[1], +], +'9x ' => $this->deserialize_updateGroupCallConnection($stream), +'./qM' => [ +'_' => 'updateBotCommands', +'peer' => self::deserialize_type_Peer($stream), +'bot_id' => unpack('q', stream_get_contents($stream, 8))[1], +'commands' => self::deserialize_type_array_of_BotCommand($stream), +], +'袺cp' => [ +'_' => 'updatePendingJoinRequests', +'peer' => self::deserialize_type_Peer($stream), +'requests_pending' => unpack('l', stream_get_contents($stream, 4))[1], +'recent_requesters' => self::deserialize_type_array_of_long($stream), +], +'拋' => [ +'_' => 'updateBotChatInviteRequester', +'peer' => self::deserialize_type_Peer($stream), +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'about' => $this->deserialize_string($stream), +'invite' => self::deserialize_type_ExportedChatInvite($stream), +'qts' => unpack('l', stream_get_contents($stream, 4))[1], +], +'<^' => $this->deserialize_updateMessageReactions($stream), +' 8' => [ +'_' => 'updateAttachMenuBots', +], +'' => [ +'_' => 'updateWebViewResultSent', +'query_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'X' => [ +'_' => 'updateBotMenuButton', +'bot_id' => unpack('q', stream_get_contents($stream, 8))[1], +'button' => self::deserialize_type_BotMenuButton($stream), +], +'撻t' => [ +'_' => 'updateSavedRingtones', +], +'Z' . "\0" . '' => $this->deserialize_updateTranscribedAudio($stream), +'lIL' => [ +'_' => 'updateReadFeaturedEmojiStickers', +], +'57(' => [ +'_' => 'updateUserEmojiStatus', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +'emoji_status' => self::deserialize_type_EmojiStatus($stream), +], +'羡0' => [ +'_' => 'updateRecentEmojiStatuses', +], +'瀿xo' => [ +'_' => 'updateRecentReactions', +], +'秖' => $this->deserialize_updateMoveStickerSetToTop($stream), +'孟Z' => [ +'_' => 'updateMessageExtendedMedia', +'peer' => self::deserialize_type_Peer($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'extended_media' => self::deserialize_type_MessageExtendedMedia($stream), +], +'裮.' => $this->deserialize_updateChannelPinnedTopic($stream), +'' => $this->deserialize_updateChannelPinnedTopics($stream), +'8R ' => [ +'_' => 'updateUser', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'' => [ +'_' => 'updateAutoSaveSettings', +], +'蟗' => [ +'_' => 'updateGroupInvitePrivacyForbidden', +'user_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'歲u' => [ +'_' => 'updateStory', +'peer' => self::deserialize_type_Peer($stream), +'story' => self::deserialize_type_StoryItem($stream), +], +'+N' => [ +'_' => 'updateReadStories', +'peer' => self::deserialize_type_Peer($stream), +'max_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +'5' => [ +'_' => 'updateStoryID', +'id' => unpack('l', stream_get_contents($stream, 4))[1], +'random_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'簍,' => [ +'_' => 'updateStoriesStealthMode', +'stealth_mode' => self::deserialize_type_StoriesStealthMode($stream), +], +'vb}' => [ +'_' => 'updateSentStoryReaction', +'peer' => self::deserialize_type_Peer($stream), +'story_id' => unpack('l', stream_get_contents($stream, 4))[1], +'reaction' => self::deserialize_type_Reaction($stream), +], +'偪' => [ +'_' => 'updateBotChatBoost', +'peer' => self::deserialize_type_Peer($stream), +'boost' => self::deserialize_type_Boost($stream), +'qts' => unpack('l', stream_get_contents($stream, 4))[1], +], +' ' => [ +'_' => 'updateChannelViewForumAsMessages', +'channel_id' => unpack('q', stream_get_contents($stream, 8))[1], +'enabled' => match (stream_get_contents($stream, 4)) {'短r' => true,'7y' => false, default => $this->err($stream) }, +], +'?' => $this->deserialize_updatePeerWallpaper($stream), +'扃!' => [ +'_' => 'updateBotMessageReaction', +'peer' => self::deserialize_type_Peer($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'actor' => self::deserialize_type_Peer($stream), +'old_reactions' => self::deserialize_type_array_of_Reaction($stream), +'new_reactions' => self::deserialize_type_array_of_Reaction($stream), +'qts' => unpack('l', stream_get_contents($stream, 4))[1], +], +'Yw ' => [ +'_' => 'updateBotMessageReactions', +'peer' => self::deserialize_type_Peer($stream), +'msg_id' => unpack('l', stream_get_contents($stream, 4))[1], +'date' => unpack('l', stream_get_contents($stream, 4))[1], +'reactions' => self::deserialize_type_array_of_ReactionCount($stream), +'qts' => unpack('l', stream_get_contents($stream, 4))[1], +], +'t祚' => $this->deserialize_updateSavedDialogPinned($stream), +'lh' => $this->deserialize_updatePinnedSavedDialogs($stream), +'2t9' => [ +'_' => 'updateSavedReactionTags', +], +'剫b' => [ +'_' => 'updateSmsJob', +'job_id' => $this->deserialize_string($stream), +], +' +G' => [ +'_' => 'updateQuickReplies', +'quick_replies' => self::deserialize_type_array_of_QuickReply($stream), +], +'=' => [ +'_' => 'updateNewQuickReply', +'quick_reply' => self::deserialize_type_QuickReply($stream), +], +'旚漀' => [ +'_' => 'updateDeleteQuickReply', +'shortcut_id' => unpack('l', stream_get_contents($stream, 4))[1], +], +' >' => [ +'_' => 'updateQuickReplyMessage', +'message' => self::deserialize_type_Message($stream), +], +'侻oV' => [ +'_' => 'updateDeleteQuickReplyMessages', +'shortcut_id' => unpack('l', stream_get_contents($stream, 4))[1], +'messages' => self::deserialize_type_array_of_int($stream), +], +'c$' => [ +'_' => 'resPQ', +'nonce' => stream_get_contents($stream, 16), +'server_nonce' => stream_get_contents($stream, 16), +'pq' => $this->deserialize_string($stream), +'server_public_key_fingerprints' => self::deserialize_type_array_of_strlong($stream), +], +'警' => [ +'_' => 'vector', +], +'_鶨' => [ +'_' => 'p_q_inner_data_dc', +'pq' => $this->deserialize_string($stream), +'p' => $this->deserialize_string($stream), +'q' => $this->deserialize_string($stream), +'nonce' => stream_get_contents($stream, 16), +'server_nonce' => stream_get_contents($stream, 16), +'new_nonce' => stream_get_contents($stream, 32), +'dc' => unpack('l', stream_get_contents($stream, 4))[1], +], +'觥V' => [ +'_' => 'p_q_inner_data_temp_dc', +'pq' => $this->deserialize_string($stream), +'p' => $this->deserialize_string($stream), +'q' => $this->deserialize_string($stream), +'nonce' => stream_get_contents($stream, 16), +'server_nonce' => stream_get_contents($stream, 16), +'new_nonce' => stream_get_contents($stream, 32), +'dc' => unpack('l', stream_get_contents($stream, 4))[1], +'expires_in' => unpack('l', stream_get_contents($stream, 4))[1], +], +']芐' => [ +'_' => 'server_DH_params_fail', +'nonce' => stream_get_contents($stream, 16), +'server_nonce' => stream_get_contents($stream, 16), +'new_nonce_hash' => stream_get_contents($stream, 16), +], +'\\駗' => [ +'_' => 'server_DH_params_ok', +'nonce' => stream_get_contents($stream, 16), +'server_nonce' => stream_get_contents($stream, 16), +'encrypted_answer' => $this->deserialize_string($stream), +], +' ' => [ +'_' => 'server_DH_inner_data', +'nonce' => stream_get_contents($stream, 16), +'server_nonce' => stream_get_contents($stream, 16), +'g' => unpack('l', stream_get_contents($stream, 4))[1], +'dh_prime' => $this->deserialize_string($stream), +'g_a' => $this->deserialize_string($stream), +'server_time' => unpack('l', stream_get_contents($stream, 4))[1], +], +'T詆f' => [ +'_' => 'client_DH_inner_data', +'nonce' => stream_get_contents($stream, 16), +'server_nonce' => stream_get_contents($stream, 16), +'retry_id' => unpack('q', stream_get_contents($stream, 8))[1], +'g_b' => $this->deserialize_string($stream), +], +'4鼲;' => [ +'_' => 'dh_gen_ok', +'nonce' => stream_get_contents($stream, 16), +'server_nonce' => stream_get_contents($stream, 16), +'new_nonce_hash1' => stream_get_contents($stream, 16), +], +'軨' => [ +'_' => 'dh_gen_retry', +'nonce' => stream_get_contents($stream, 16), +'server_nonce' => stream_get_contents($stream, 16), +'new_nonce_hash2' => stream_get_contents($stream, 16), +], +'' => [ +'_' => 'dh_gen_fail', +'nonce' => stream_get_contents($stream, 16), +'server_nonce' => stream_get_contents($stream, 16), +'new_nonce_hash3' => stream_get_contents($stream, 16), +], +'e驐u' => [ +'_' => 'bind_auth_key_inner', +'nonce' => unpack('q', stream_get_contents($stream, 8))[1], +'temp_auth_key_id' => unpack('q', stream_get_contents($stream, 8))[1], +'perm_auth_key_id' => unpack('q', stream_get_contents($stream, 8))[1], +'temp_session_id' => unpack('q', stream_get_contents($stream, 8))[1], +'expires_at' => unpack('l', stream_get_contents($stream, 4))[1], +], +'m\\' => $this->deserialize_rpc_result($stream), +'n*^' => [ +'_' => 'rpc_answer_unknown', +], +'憋' => [ +'_' => 'rpc_answer_dropped_running', +], +'煥:' => [ +'_' => 'rpc_answer_dropped', +'msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'seq_no' => unpack('l', stream_get_contents($stream, 4))[1], +'bytes' => unpack('l', stream_get_contents($stream, 4))[1], +], +'嗕I ' => [ +'_' => 'future_salt', +'valid_since' => unpack('l', stream_get_contents($stream, 4))[1], +'valid_until' => unpack('l', stream_get_contents($stream, 4))[1], +'salt' => unpack('q', stream_get_contents($stream, 8))[1], +], +'P' => [ +'_' => 'future_salts', +'req_msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'now' => unpack('l', stream_get_contents($stream, 4))[1], +'salts' => self::deserialize_type_array_of_future_salt($stream), +], +'彎w4' => [ +'_' => 'pong', +'msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'ping_id' => stream_get_contents($stream, 8), +], +'E ' => [ +'_' => 'destroy_session_ok', +'session_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +'丮羒' => [ +'_' => 'destroy_session_none', +'session_id' => unpack('q', stream_get_contents($stream, 8))[1], +], +' ' => [ +'_' => 'new_session_created', +'first_msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'unique_id' => unpack('q', stream_get_contents($stream, 8))[1], +'server_salt' => stream_get_contents($stream, 8), +], +'媱雟' => [ +'_' => 'msg_container', +'messages' => self::deserialize_type_array_of_MTmessage($stream), +], +'撣[' => [ +'_' => 'MTmessage', +'msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'seqno' => unpack('l', stream_get_contents($stream, 4))[1], +'bytes' => unpack('l', stream_get_contents($stream, 4))[1], +'body' => $this->deserialize_type_Object($stream), +], +'淙`' => [ +'_' => 'msg_copy', +'orig_message' => self::deserialize_type_MTMessage($stream), +], +'Y棉b' => [ +'_' => 'msgs_ack', +'msg_ids' => self::deserialize_type_array_of_long($stream), +], +'攮' => [ +'_' => 'bad_msg_notification', +'bad_msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'bad_msg_seqno' => unpack('l', stream_get_contents($stream, 4))[1], +'error_code' => unpack('l', stream_get_contents($stream, 4))[1], +], +'{D恆' => [ +'_' => 'bad_server_salt', +'bad_msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'bad_msg_seqno' => unpack('l', stream_get_contents($stream, 4))[1], +'error_code' => unpack('l', stream_get_contents($stream, 4))[1], +'new_server_salt' => stream_get_contents($stream, 8), +], +'赮' => [ +'_' => 'msg_resend_ans_req', +'msg_ids' => self::deserialize_type_array_of_long($stream), +], +'}' => [ +'_' => 'msg_resend_req', +'msg_ids' => self::deserialize_type_array_of_long($stream), +], +'Ri' => [ +'_' => 'msgs_state_req', +'msg_ids' => self::deserialize_type_array_of_long($stream), +], +'}萌' => [ +'_' => 'msgs_state_info', +'req_msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'info' => $this->deserialize_string($stream), +], +'1挴' => [ +'_' => 'msgs_all_info', +'msg_ids' => self::deserialize_type_array_of_long($stream), +'info' => $this->deserialize_string($stream), +], +'>m\'' => [ +'_' => 'msg_detailed_info', +'msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'answer_msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'bytes' => unpack('l', stream_get_contents($stream, 4))[1], +'status' => unpack('l', stream_get_contents($stream, 4))[1], +], +'葍' => [ +'_' => 'msg_new_detailed_info', +'answer_msg_id' => unpack('q', stream_get_contents($stream, 8))[1], +'bytes' => unpack('l', stream_get_contents($stream, 4))[1], +'status' => unpack('l', stream_get_contents($stream, 4))[1], +], +'vz' => [ +'_' => 'rsa_public_key', +'n' => $this->deserialize_string($stream), +'e' => $this->deserialize_string($stream), +], +'5' => [ +'_' => 'http_wait', +'max_delay' => unpack('l', stream_get_contents($stream, 4))[1], +'wait_after' => unpack('l', stream_get_contents($stream, 4))[1], +'max_wait' => unpack('l', stream_get_contents($stream, 4))[1], +], +'+r0' => $this->deserialize($stream), +default => self::err($stream) +} +; } } diff --git a/tools/TL/Builder.php b/tools/TL/Builder.php index d35395850..86af7fb04 100644 --- a/tools/TL/Builder.php +++ b/tools/TL/Builder.php @@ -410,10 +410,12 @@ final class Builder || $arr['predicate'] === 'rpc_result' || !$arr['encrypted'] ) && ( - $arr['predicate'] === 'rpc_error' + $arr['predicate'] !== 'rpc_error' ) ); + $this->m("deserialize", "return {$this->buildTypes($initial_constructors)};", 'mixed', true, static: false); + $this->m("deserialize_type_Object", "return {$this->buildTypes($initial_constructors)};", 'mixed', true, static: false); $this->w("}\n");