From 2672728fe3b7ddbc03c59299e2483e6708919896 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 23 Jun 2019 12:32:23 +0200 Subject: [PATCH] Add getPropicInfo method and fix some bugs --- docs | 2 +- src/danog/MadelineProto/Loop/Update/FeedLoop.php | 2 +- src/danog/MadelineProto/MTProtoTools/Files.php | 5 ++++- .../Stream/Common/BufferedRawStream.php | 12 ++++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs b/docs index 47fa1f01..3b2fb466 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 47fa1f01763372bab5bc64332bced8fcdc8b7100 +Subproject commit 3b2fb46659932f3a812279b64f31b8933474978c diff --git a/src/danog/MadelineProto/Loop/Update/FeedLoop.php b/src/danog/MadelineProto/Loop/Update/FeedLoop.php index 1daafe82..c60c84f3 100644 --- a/src/danog/MadelineProto/Loop/Update/FeedLoop.php +++ b/src/danog/MadelineProto/Loop/Update/FeedLoop.php @@ -100,7 +100,7 @@ class FeedLoop extends ResumableSignalLoop continue; } - if (isset($update['pts'])) { + if (isset($update['pts'], $update['pts_count'])) { $logger = function ($msg) use ($update) { $pts_count = $update['pts_count']; $double = isset($update['message']['id']) ? $update['message']['id'] * 2 : '-'; diff --git a/src/danog/MadelineProto/MTProtoTools/Files.php b/src/danog/MadelineProto/MTProtoTools/Files.php index 159caec7..d5191b57 100644 --- a/src/danog/MadelineProto/MTProtoTools/Files.php +++ b/src/danog/MadelineProto/MTProtoTools/Files.php @@ -257,7 +257,10 @@ trait Files return yield $this->gen_all_file_async($constructor, $regenerate); } - + public function get_propic_info_async($data) + { + return yield $this->get_download_info_async($this->chats[(yield $this->get_info_async($data))['bot_api_id']]); + } public function get_download_info_async($message_media) { if (is_string($message_media)) { diff --git a/src/danog/MadelineProto/Stream/Common/BufferedRawStream.php b/src/danog/MadelineProto/Stream/Common/BufferedRawStream.php index 04ad2f4c..129380e9 100644 --- a/src/danog/MadelineProto/Stream/Common/BufferedRawStream.php +++ b/src/danog/MadelineProto/Stream/Common/BufferedRawStream.php @@ -63,6 +63,9 @@ class BufferedRawStream implements \danog\MadelineProto\Stream\BufferedStreamInt */ public function read(): Promise { + if (!$this->stream) { + throw new ClosedException("MadelineProto stream was disconnected"); + } return $this->stream->read(); } @@ -75,6 +78,9 @@ class BufferedRawStream implements \danog\MadelineProto\Stream\BufferedStreamInt */ public function write(string $data): Promise { + if (!$this->stream) { + throw new ClosedException("MadelineProto stream was disconnected"); + } return $this->stream->write($data); } @@ -104,6 +110,9 @@ class BufferedRawStream implements \danog\MadelineProto\Stream\BufferedStreamInt */ public function getReadBuffer(&$length): Promise { + if (!$this->stream) { + throw new ClosedException("MadelineProto stream was disconnected"); + } $size = fstat($this->memory_stream)['size']; $offset = ftell($this->memory_stream); $length = $size - $offset; @@ -146,6 +155,9 @@ class BufferedRawStream implements \danog\MadelineProto\Stream\BufferedStreamInt */ public function bufferRead(int $length): Promise { + if (!$this->stream) { + throw new ClosedException("MadelineProto stream was disconnected"); + } $size = fstat($this->memory_stream)['size']; $offset = ftell($this->memory_stream); $buffer_length = $size - $offset;