-
|
inputMediaPhoto allows you to attach media files using $max = 10;
$photos = $galleryPhotos->when($galleryPhotos->count() > $max, function ($collection) use ($max) {
return $collection->random($max);
})->map(function ($photo) {
return [
'type' => 'photo',
'media' => 'attach://' . $photo->hash,
];
});
$this->chat->mediaGroup($photos->toArray())->???->send();I guess I need to pass every photo hash into Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Was able to achieve this by overriding proivder // AppServiceProvider
public function register(): void
{
$this->app->bind('telegraph', fn () => new CustomTelegraph);
}// CustomTelegraph
<?php
declare(strict_types=1);
namespace App\Services\Telegram;
use DefStudio\Telegraph\DTO\Attachment;
use DefStudio\Telegraph\Telegraph;
class CustomTelegraph extends Telegraph
{
public function withFile(string $key, string $path)
{
$telegraph = clone $this;
$this->files->put($key, new Attachment($path));
return $telegraph;
}
}// handler
$max = 10;
$photos = $galleryPhotos->when($galleryPhotos->count() > $max, function ($collection) use ($max) {
return $collection->random($max);
});
$request = $this->chat->mediaGroup($photos->map(function ($photo) {
return [
'type' => 'photo',
'media' => 'attach://'.$photo->hash,
];
})->toArray());
foreach ($photos as $photo) {
$request->withFile($photo->hash, Storage::path($photo->physicalPath()));
}
$request->send(); |
Beta Was this translation helpful? Give feedback.
Was able to achieve this by overriding proivder