Add getPropicInfo method and fix some bugs

This commit is contained in:
Daniil Gentili 2019-06-23 12:32:23 +02:00
parent 09fc49459f
commit 2672728fe3
4 changed files with 18 additions and 3 deletions

2
docs

@ -1 +1 @@
Subproject commit 47fa1f01763372bab5bc64332bced8fcdc8b7100 Subproject commit 3b2fb46659932f3a812279b64f31b8933474978c

View File

@ -100,7 +100,7 @@ class FeedLoop extends ResumableSignalLoop
continue; continue;
} }
if (isset($update['pts'])) { if (isset($update['pts'], $update['pts_count'])) {
$logger = function ($msg) use ($update) { $logger = function ($msg) use ($update) {
$pts_count = $update['pts_count']; $pts_count = $update['pts_count'];
$double = isset($update['message']['id']) ? $update['message']['id'] * 2 : '-'; $double = isset($update['message']['id']) ? $update['message']['id'] * 2 : '-';

View File

@ -257,7 +257,10 @@ trait Files
return yield $this->gen_all_file_async($constructor, $regenerate); 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) public function get_download_info_async($message_media)
{ {
if (is_string($message_media)) { if (is_string($message_media)) {

View File

@ -63,6 +63,9 @@ class BufferedRawStream implements \danog\MadelineProto\Stream\BufferedStreamInt
*/ */
public function read(): Promise public function read(): Promise
{ {
if (!$this->stream) {
throw new ClosedException("MadelineProto stream was disconnected");
}
return $this->stream->read(); return $this->stream->read();
} }
@ -75,6 +78,9 @@ class BufferedRawStream implements \danog\MadelineProto\Stream\BufferedStreamInt
*/ */
public function write(string $data): Promise public function write(string $data): Promise
{ {
if (!$this->stream) {
throw new ClosedException("MadelineProto stream was disconnected");
}
return $this->stream->write($data); return $this->stream->write($data);
} }
@ -104,6 +110,9 @@ class BufferedRawStream implements \danog\MadelineProto\Stream\BufferedStreamInt
*/ */
public function getReadBuffer(&$length): Promise public function getReadBuffer(&$length): Promise
{ {
if (!$this->stream) {
throw new ClosedException("MadelineProto stream was disconnected");
}
$size = fstat($this->memory_stream)['size']; $size = fstat($this->memory_stream)['size'];
$offset = ftell($this->memory_stream); $offset = ftell($this->memory_stream);
$length = $size - $offset; $length = $size - $offset;
@ -146,6 +155,9 @@ class BufferedRawStream implements \danog\MadelineProto\Stream\BufferedStreamInt
*/ */
public function bufferRead(int $length): Promise public function bufferRead(int $length): Promise
{ {
if (!$this->stream) {
throw new ClosedException("MadelineProto stream was disconnected");
}
$size = fstat($this->memory_stream)['size']; $size = fstat($this->memory_stream)['size'];
$offset = ftell($this->memory_stream); $offset = ftell($this->memory_stream);
$buffer_length = $size - $offset; $buffer_length = $size - $offset;