1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-26 23:14:38 +01:00

Fix sendDocument/sendPhoto through IPC API

This commit is contained in:
Daniil Gentili 2023-09-07 19:00:14 +02:00
parent 0d11019f2b
commit 634d2c8f82
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
3 changed files with 9 additions and 4 deletions

View File

@ -57,7 +57,6 @@ use function Amp\Future\awaitFirst;
trait Files
{
use FilesLogic;
use FilesAbstraction;
use FileServer;
/**
* Upload file from URL.

View File

@ -70,6 +70,7 @@ use function Amp\File\openFile;
*/
trait FilesLogic
{
use FilesAbstraction;
/**
* Download file to browser.
*

View File

@ -18,11 +18,13 @@ If not, see <http://www.gnu.org/licenses/>.
use Amp\ByteStream\ReadableBuffer;
use danog\MadelineProto\API;
use danog\MadelineProto\FileCallback;
use danog\MadelineProto\LocalFile;
use danog\MadelineProto\Logger;
use danog\MadelineProto\Settings;
use danog\MadelineProto\VoIP;
use Webmozart\Assert\Assert;
use function Amp\File\openFile;
use function Amp\File\read;
$loader = false;
@ -300,13 +302,16 @@ function sendMedia(API $MadelineProto, array $media, string $message, string $me
'base' => $media
];
if (isset($media['file']) && is_string($media['file'])) {
$MadelineProto->sendDocument(
peer: $peer,
file: new ReadableBuffer(read($media['file'])),
callback: fn ($v) => $MadelineProto->logger($v),
fileName: basename($media['file'])
);
$medias['callback'] = array_merge(
$media,
['file' => new FileCallback($media['file'], fn ($v) => $MadelineProto->logger(...))]
);
if (is_array($media['file'])) {
var_dump($media['file']);
}
$medias['stream'] = array_merge(
$media,
['file' => new ReadableBuffer(read($media['file']))]