Update file callback interfaces
This commit is contained in:
parent
203d86cb28
commit
8ba10b047e
2
docs
2
docs
|
@ -1 +1 @@
|
|||
Subproject commit 135f3110232f3a486b83438fdc0f15db165f7494
|
||||
Subproject commit 4ed3a8447cf21c69322bcdaf149eb3ce0befe8c0
|
|
@ -104,15 +104,17 @@ class EventHandler extends \danog\MadelineProto\EventHandler
|
|||
$id = yield $this->messages->sendMessage(['peer' => $peerId, 'message' => 'Preparing...', 'reply_to_msg_id' => $messageId])['id'];
|
||||
$url = new \danog\MadelineProto\FileCallback(
|
||||
$url,
|
||||
function ($progress) use ($peerId, $id) {
|
||||
static $prev = 0;
|
||||
function ($progress, $speed, $time) use ($peerId, $id) {
|
||||
$this->logger("Upload progress: $progress%");
|
||||
|
||||
static $prev = -1;
|
||||
$progressR = (int) ($progress / 10);
|
||||
if ($progressR === $prev) {
|
||||
return;
|
||||
}
|
||||
$prev = $progressR;
|
||||
try {
|
||||
yield $this->messages->editMessage(['peer' => $peerId, 'id' => $id, 'message' => 'Upload progress: '.$progress.'%']);
|
||||
yield $this->messages->editMessage(['peer' => $peerId, 'id' => $id, 'message' => "Upload progress: $progress%\nSpeed: $speed mbps\nTime elapsed since start: $time"]);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,10 +35,10 @@ class FileCallback implements FileCallbackInterface
|
|||
return $this->file;
|
||||
}
|
||||
|
||||
public function __invoke($percent)
|
||||
public function __invoke($percent, $speed, $time)
|
||||
{
|
||||
$callback = $this->callback;
|
||||
|
||||
return $callback($percent);
|
||||
return $callback($percent, $speed, $time);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,5 +23,5 @@ interface FileCallbackInterface
|
|||
{
|
||||
public function getFile();
|
||||
|
||||
public function __invoke($percent);
|
||||
public function __invoke($percent, $speed, $time);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user