Download and save all picture from channel automatically
Need tuning
I tried to take advantage of this advice, but this has no effect((
Please, help(((
hook.php
// Set custom Upload and Download path
$telegram->setDownloadPath(BASE_PATH . '/var/www/html/download');
$telegram->setUploadPath(BASE_PATH . '/var/www/html/upload');
I tried in different ways, but has no effect
Adding something like this to GenericmessageCommand should keep saving all files sent to the bot:
$message = $this->getMessage();
if (in_array(strtolower($message->getType()), ['audio', 'document', 'photo', 'video', 'voice'])) {
$doc = call_user_method('get' . $message->getType(), $message);
(strtolower($message->getType()) === 'photo') && $doc = $doc[0];
$file = Request::getFile(['file_id' => $doc->getFileId()]);
if ($file->isOk()) {
Request::downloadFile($file->getResult());
}
}
(corrected)
(literally cut code from https://github.com/akalongman/php-telegram-bot/issues/221#issuecomment-224727595)
Hangs on this instruction: $file_id = $doc->getFileId();
((
Define hangs? Script does nothing? Not even an error? Thats weird.
Check out #221 again, as it's all there.
@jacklul Since 0.35, ->getType() returns the type in lowercase!
Here the corrected code:
...
if (in_array($message->getType(), ['audio', 'document', 'photo', 'video', 'voice'], true)) {
$doc = call_user_func([$message, 'get' . ucfirst($message->getType())]);
($message->getType() === 'photo') && $doc = $doc[0];
...
Its worked!!!! Thanks!!!
But very little size
How take full size pic?
The variable $doc is an array of images, starting from smallest to biggest.
So for the biggest version you could just get the last item like so: $doc = end($doc);
(that's also described in the other issue 鈽猴笍)
Thank you very match!!! Its work!!!
Most helpful comment
Check out #221 again, as it's all there.
@jacklul Since 0.35,
->getType()returns the type in lowercase!Here the corrected code: