E
E
EVG822020-10-11 06:46:58
PHP
EVG82, 2020-10-11 06:46:58

What kind of yield does not work?

So it was possible to establish that through this MadelineProto it is possible to upload to the TG server as part of a video of more than 50 mb.
This code was executed:

<?php

if (!file_exists('madeline.php')) {
    copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';

$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->async(true);
$MadelineProto->loop(function () use ($MadelineProto) {
    yield $MadelineProto->start();

    $me = yield $MadelineProto->getSelf();

    $MadelineProto->logger($me);

    if (!$me['bot']) {
        yield $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
        yield $MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);

        try {
            yield $MadelineProto->messages->importChatInvite(['hash' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg']);
        } catch (\danog\MadelineProto\RPCErrorException $e) {
            $MadelineProto->logger($e);
        }

        yield $MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
    }
    yield $MadelineProto->echo('OK, done!');
});


Then I went to the section on uploading files
and trying to execute this code:
$sentMessage = yield $MadelineProto->messages->sendMedia([
    'peer' => '@danogentili',
    'media' => [
        '_' => 'inputMediaUploadedDocument',
        'file' => 'video.mp4',
        'attributes' => [
            ['_' => 'documentAttributeVideo', 'round_message' => false, 'supports_streaming' => true]
        ]
    ],
    'message' => '[This is the caption](https://t.me/MadelineProto)',
    'parse_mode' => 'Markdown'
]);

There are questions:
1 Do I understand correctly that this is PHP code and not Python?
2 Do I understand correctly that this code needs to be placed in a separate index.php file and executed by switching to this file in the browser?
But when executing the code, it writes to me

"The expression "yield" can only be used inside the function"

And here I don’t catch up with what to do!

3 What needs to be added to the code?
4 The code needs to be embedded in the first code, what did you give above?

5 Somewhere it is simply written how to upload a file of more than 50 mb to the TG server. I compressed my file from 180 mb to 35, but the TG bot does not accept a direct link.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hofspace, 2022-03-12
@hofspace

use yield inside a function.
For example,
function test($MadelineProto){
yield ...
}
I haven't figured it out yet, but if you use yield inside a function, it works

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question