Алексей С
Алексей С

Reputation: 11

How to get all photos from a message using $MadelineProto->messages->getHistory()?

I get the latest channel message from the history and try to get all the photos of this message.But I only get one last photo. Please tell me how to get all the photos from the message?

foreach($channels as $channel){
  $messs[$channel] = $this->MadelineProto->messages->getHistory(['peer' => $channel, 'limit' => 1]);
}
foreach ($messs as $key => $messages) {

  foreach ($messages['messages'] as $message) {
    $text = $message['message'];
    $files = null;

    if (isset($message['media']) && $text['media']['_'] === 'messageMediaPhoto') {
         $file = $this->MadelineProto->downloadToDir($message['media'], '../../img');
         $files[] = $file;
    }
     
    if($text !== ''){
        $posts[] = ['media' => [$key => $files] ];
    }
  }
}

Upvotes: 1

Views: 32

Answers (0)

Related Questions