Add progress for renaming
This commit is contained in:
parent
e2fb6dbfe6
commit
f64efb021c
@ -88,8 +88,9 @@ class EventHandler extends \danog\MadelineProto\EventHandler
|
|||||||
}
|
}
|
||||||
if (isset($this->states[$peerId])) {
|
if (isset($this->states[$peerId])) {
|
||||||
$name = $update['message']['message'];
|
$name = $update['message']['message'];
|
||||||
list($file, $id) = $this->states[$peerId];
|
list($url, $id) = $this->states[$peerId];
|
||||||
unset($this->states[$peerId]);
|
unset($this->states[$peerId]);
|
||||||
|
$method = 'uploadFromTgFile';
|
||||||
} else {
|
} else {
|
||||||
$url = \explode(' ', $update['message']['message'], 2);
|
$url = \explode(' ', $update['message']['message'], 2);
|
||||||
$name = \trim($url[1] ?? \basename($update['message']['message']));
|
$name = \trim($url[1] ?? \basename($update['message']['message']));
|
||||||
@ -100,9 +101,10 @@ class EventHandler extends \danog\MadelineProto\EventHandler
|
|||||||
if (\strpos($url, 'http') !== 0) {
|
if (\strpos($url, 'http') !== 0) {
|
||||||
$url = "http://$url";
|
$url = "http://$url";
|
||||||
}
|
}
|
||||||
|
$method = 'uploadFromUrl';
|
||||||
|
}
|
||||||
$id = yield $this->messages->sendMessage(['peer' => $peerId, 'message' => 'Preparing...', 'reply_to_msg_id' => $messageId])['id'];
|
$id = yield $this->messages->sendMessage(['peer' => $peerId, 'message' => 'Preparing...', 'reply_to_msg_id' => $messageId])['id'];
|
||||||
$file = yield $this->uploadFromUrl(new \danog\MadelineProto\FileCallback(
|
$file = yield $this->$method(new \danog\MadelineProto\FileCallback(
|
||||||
$url,
|
$url,
|
||||||
function ($progress) use ($peerId, $id) {
|
function ($progress) use ($peerId, $id) {
|
||||||
static $prev = 0;
|
static $prev = 0;
|
||||||
@ -117,7 +119,6 @@ class EventHandler extends \danog\MadelineProto\EventHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
|
||||||
yield $this->messages->sendMedia(
|
yield $this->messages->sendMedia(
|
||||||
[
|
[
|
||||||
'peer' => $peerId,
|
'peer' => $peerId,
|
||||||
|
Loading…
Reference in New Issue
Block a user