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:
parent
0d11019f2b
commit
634d2c8f82
@ -57,7 +57,6 @@ use function Amp\Future\awaitFirst;
|
||||
trait Files
|
||||
{
|
||||
use FilesLogic;
|
||||
use FilesAbstraction;
|
||||
use FileServer;
|
||||
/**
|
||||
* Upload file from URL.
|
||||
|
@ -70,6 +70,7 @@ use function Amp\File\openFile;
|
||||
*/
|
||||
trait FilesLogic
|
||||
{
|
||||
use FilesAbstraction;
|
||||
/**
|
||||
* Download file to browser.
|
||||
*
|
||||
|
@ -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']))]
|
||||
|
Loading…
Reference in New Issue
Block a user