From dfc7d17f2d065594f644cbb988fd2ffcf0629e5d Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 19 May 2017 16:36:05 +0200 Subject: [PATCH 1/2] Possible fix for PERSISTENT_TIMESTAMP_OUTDATED --- src/danog/MadelineProto/MTProtoTools/ResponseHandler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php b/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php index f5ad60bd..cfa70ec1 100644 --- a/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php @@ -323,6 +323,10 @@ trait ResponseHandler public function handle_rpc_error($server_answer, &$aargs) { + if ($server_answer['error_message'] === 'PERSISTENT_TIMESTAMP_OUTDATED') { + $this->got_state = false; + throw new \danog\MadelineProto\Exception('Update the timestamp pls'); + } switch ($server_answer['error_code']) { case 303: $this->datacenter->curdc = $aargs['datacenter'] = (int) preg_replace('/[^0-9]+/', '', $server_answer['error_message']); From 4b561510e703102c24f93b7b32cbfbcee81d4f4d Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 19 May 2017 16:35:09 +0100 Subject: [PATCH 2/2] Added support for video notes (round videos) --- src/danog/MadelineProto/MTProto.php | 2 +- src/danog/MadelineProto/TL/Conversion/BotAPI.php | 2 +- src/danog/MadelineProto/TL/Conversion/BotAPIFiles.php | 10 +++++++++- src/danog/MadelineProto/TL_botAPI.tl | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 833a73ba..c956a62d 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -617,7 +617,7 @@ class MTProto extends \Volatile public function getV() { - return 30; + return 31; } public function get_self() diff --git a/src/danog/MadelineProto/TL/Conversion/BotAPI.php b/src/danog/MadelineProto/TL/Conversion/BotAPI.php index 8191cf98..4c0d9f76 100644 --- a/src/danog/MadelineProto/TL/Conversion/BotAPI.php +++ b/src/danog/MadelineProto/TL/Conversion/BotAPI.php @@ -275,7 +275,7 @@ trait BotAPI break; case 'documentAttributeVideo': - $type_name = 'video'; + $type_name = $attribute['round_message'] ? 'video_note' : 'video'; $res['width'] = $attribute['w']; $res['height'] = $attribute['h']; $res['duration'] = $attribute['duration']; diff --git a/src/danog/MadelineProto/TL/Conversion/BotAPIFiles.php b/src/danog/MadelineProto/TL/Conversion/BotAPIFiles.php index ab4055bc..11ebcb28 100644 --- a/src/danog/MadelineProto/TL/Conversion/BotAPIFiles.php +++ b/src/danog/MadelineProto/TL/Conversion/BotAPIFiles.php @@ -116,7 +116,15 @@ trait BotAPIFiles case 'bot_video': unset($deserialized['_']); - $constructor = array_merge($deserialized, ['_' => 'document', 'mime_type' => '', 'attributes' => [['_' => 'documentAttributeVideo']]]); + $constructor = array_merge($deserialized, ['_' => 'document', 'mime_type' => '', 'attributes' => [['_' => 'documentAttributeVideo', 'round_message' => false]]]); + + $res['MessageMedia'] = ['_' => 'messageMediaDocument', 'document' => $constructor, 'caption' => '']; + + return $res; + + case 'bot_video_note': + unset($deserialized['_']); + $constructor = array_merge($deserialized, ['_' => 'document', 'mime_type' => '', 'attributes' => [['_' => 'documentAttributeVideo', 'round_message' => true]]]); $res['MessageMedia'] = ['_' => 'messageMediaDocument', 'document' => $constructor, 'caption' => '']; diff --git a/src/danog/MadelineProto/TL_botAPI.tl b/src/danog/MadelineProto/TL_botAPI.tl index 6d940faa..0dc9f6c6 100644 --- a/src/danog/MadelineProto/TL_botAPI.tl +++ b/src/danog/MadelineProto/TL_botAPI.tl @@ -6,4 +6,4 @@ bot_document#5 dc_id:int id:long access_hash:long = File; bot_sticker#8 dc_id:int id:long access_hash:long = File; bot_audio#9 dc_id:int id:long access_hash:long = File; bot_gif#A dc_id:int id:long access_hash:long = File; -bot_roundvideo#D dc_id:int id:long access_hash:long = File; +bot_video_note#D dc_id:int id:long access_hash:long = File;