Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetching message view not working #969

Closed
suadikhasen opened this issue May 30, 2021 · 3 comments
Closed

fetching message view not working #969

suadikhasen opened this issue May 30, 2021 · 3 comments

Comments

@suadikhasen
Copy link

suadikhasen commented May 30, 2021

i get this error

Got exception while receiving in IPC client: Amp\Ipc\Sync\ChannelException: The channel closed unexpectedly. Did the context die? in /home/super/Downloads/dagu/vendor/danog/ipc/lib/Sync/ChannelledStream.php:72
Stack trace:
#0 [internal function]: Amp\Ipc\Sync\ChannelledStream->Amp\Ipc\Sync\{closure}()
#1 /home/super/Downloads/dagu/vendor/amphp/amp/lib/Coroutine.php(118): Generator->send()
#2 /home/super/Downloads/dagu/vendor/amphp/amp/lib/Internal/Placeholder.php(149): Amp\Coroutine->Amp\{closure}()
#3 /home/super/Downloads/dagu/vendor/amphp/amp/lib/Deferred.php(52): Amp\Promise@anonymous->resolve()
#4 /home/super/Downloads/dagu/vendor/amphp/byte-stream/lib/ResourceInputStream.php(198): Amp\Deferred->resolve()
#5 /home/super/Downloads/dagu/vendor/amphp/byte-stream/lib/ResourceInputStream.php(259): Amp\ByteStream\ResourceInputStream->free()
#6 [internal function]: Amp\ByteStream\ResourceInputStream->__destruct()
#7 {main}

and next request this error

An error occurred while disconnecting the client: Amp\ByteStream\ClosedException: The stream is not writable in /home/super/Downloads/dagu/vendor/amphp/byte-stream/lib/ResourceOutputStream.php:177
Stack trace:
#0 /home/super/Downloads/dagu/vendor/amphp/byte-stream/lib/ResourceOutputStream.php(157): Amp\ByteStream\ResourceOutputStream->send()
#1 /home/super/Downloads/dagu/vendor/danog/ipc/lib/Sync/ChannelledStream.php(51): Amp\ByteStream\ResourceOutputStream->write()
#2 [internal function]: Amp\Ipc\Sync\ChannelledStream->Amp\Ipc\Sync\{closure}()
#3 /home/super/Downloads/dagu/vendor/amphp/amp/lib/Coroutine.php(67): Generator->current()
#4 /home/super/Downloads/dagu/vendor/amphp/amp/lib/functions.php(96): Amp\Coroutine->__construct()
#5 /home/super/Downloads/dagu/vendor/danog/ipc/lib/Sync/ChannelledStream.php(55): Amp\call()
#6 /home/super/Downloads/dagu/vendor/danog/ipc/lib/Sync/ChannelledSocket.php(101): Amp\Ipc\Sync\ChannelledStream->send()
#7 [internal function]: Amp\Ipc\Sync\ChannelledSocket->Amp\Ipc\Sync\{closure}()
#8 /home/super/Downloads/dagu/vendor/amphp/amp/lib/Coroutine.php(67): Generator->current()
#9 /home/super/Downloads/dagu/vendor/amphp/amp/lib/functions.php(96): Amp\Coroutine->__construct()
#10 /home/super/Downloads/dagu/vendor/danog/ipc/lib/Sync/ChannelledSocket.php(118): Amp\call()
#11 /home/super/Downloads/dagu/vendor/danog/madelineproto/src/danog/MadelineProto/Ipc/ClientAbstract.php(138): Amp\Ipc\Sync\ChannelledSocket->disconnect()
#12 [internal function]: danog\MadelineProto\Ipc\ClientAbstract->disconnect()
#13 /home/super/Downloads/dagu/vendor/danog/madelineproto/src/danog/MadelineProto/Coroutine.php(71): Generator->current()
#14 /home/super/Downloads/dagu/vendor/danog/madelineproto/src/danog/MadelineProto/Tools.php(298): danog\MadelineProto\Coroutine->__construct()
#15 /home/super/Downloads/dagu/vendor/danog/madelineproto/src/danog/MadelineProto/Ipc/Client.php(100): danog\MadelineProto\Tools::wait()
#16 /home/super/Downloads/dagu/vendor/danog/madelineproto/src/danog/MadelineProto/API.php(354): danog\MadelineProto\Ipc\Client->unreference()
#17 [internal function]: danog\MadelineProto\API->__destruct()
#18 {main}

my code is

$telegram_bot = new API('session.madeline', $settings);
        $telegram_bot->async(true);
        foreach ($closing_posts as $post) {
            $telegram_bot->loop(function () use ($telegram_bot,$post) {
                $message = yield $telegram_bot->messages->getMessagesViews([
                    'peer'         =>    $post->channel->username,
                    'id'           =>    [$post->message_id],
                    'increment'    =>    false,
                ]);
                $post->update([
                    'number_of_view' => $message->views,
                ]);
            });

any one please ?
thnk you

@Nguyentran83
Copy link

$telegram_bot = new API('session.madeline', $settings);
$telegram_bot->async(true);
foreach ($closing_posts as $post) {
$telegram_bot->loop(function () use ($telegram_bot,$post) {
$message = yield $telegram_bot->messages->getMessagesViews([
'peer' => $post->channel->username,
'id' => [$post->message_id],
'increment' => false,
]);
$post->update([
'number_of_view' => $message->views,
]);
});

@konstantin-vysitsky
Copy link

Same problem

  ClientAbstract: Got exception while receiving in IPC client: Amp\Ipc\Sync\ChannelException: The channel closed unexpectedly. Did the context die? in /home/t/totkto2i/tg.public-trader.ru/public_html/parser/mp/vendor/danog/ipc/lib/Sync/ChannelledStream.php:72
  Stack trace:
  #0 [internal function]: Amp\Ipc\Sync\ChannelledStream->Amp\Ipc\Sync{closure}()
  #1 /home/t/totkto2i/tg.public-trader.ru/public_html/parser/mp/vendor/amphp/amp/lib/Coroutine.php(118): Generator->send(NULL)
  #2 /home/t/totkto2i/tg.public-trader.ru/public_html/parser/mp/vendor/amphp/amp/lib/Internal/Placeholder.php(149): Amp\Coroutine->Amp{closure}(NULL, NULL)
  #3 /home/t/totkto2i/tg.public-trader.ru/public_html/parser/mp/vendor/amphp/amp/lib/Deferred.php(53): Amp\Promise@anonymous->resolve(NULL)
  #4 /home/t/totkto2i/tg.public-trader.ru/public_html/parser/mp/vendor/amphp/byte-stream/lib/ResourceInputStream.php(198): Amp\Deferred->resolve()
  #5 /home/t/totkto2i/tg.public-trader.ru/public_html/parser/mp/vendor/amphp/byte-stream/lib/ResourceInputStream.php(259): Amp\ByteStream\ResourceInputStream->free()
  #6 [internal function]: Amp\ByteStream\ResourceInputStream->__destruct()
  #7 {main}

CODE:

$MadelineProto = new \danog\MadelineProto\API('session.madeline', $settings);
$me = $MadelineProto->start();
$val["peer"] = "antonchehovanalitk";
$data = array(
'peer' => '@'.$val['peer'],
'offset_id' => $val['offset_id']?:0,
'offset_date' => $val['offset_date']?:0,
'add_offset' => $val['add_offset']?:0,
'limit' => $val['limit']?:10,
'max_id' => $val['max_id']?:0,
'min_id' => $val['min_id']?:0,
'hash' => 0
);

$response = $MadelineProto->messages->getHistory($data);
print_r($response);

@danog
Copy link
Owner

danog commented Dec 17, 2021

This is fixed in the latest version of MadelineProto 7.

@danog danog closed this as completed Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants