krot

telegram read channel

Sep 16th, 2020
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. try{
  2. do {
  3.     $messages_Messages = $MadelineProto->messages->getHistory(['peer' => $channel, 'offset_id' => $offset_id, 'offset_date' => 0, 'add_offset' => 0, 'limit' => $limit, 'max_id' => 0, 'min_id' => $min_id, 'hash' => 0 ]);
  4.     if (count($messages_Messages['messages']) == 0) break;
  5.     foreach ($messages_Messages['messages'] as $message) {
  6.         //print_r($message);
  7.         // echo "id: " . $message['id'] . "\n";//. " message: " . @$message['message'] . "\n";
  8.         //https://core.telegram.org/type/MessageMedia
  9.          /*  if(!empty($message['media']) && ($message['media']['_']=='messageMediaPhoto'||$message['media']['_']=='messageMediaDocument')){
  10.              try{
  11.              $info =$MadelineProto->getDownloadInfo($message['media']);
  12.       //  $info['ext'] - The file extension  //  $info['name'] - The file name, without the extension
  13.        // $info['mime'] - The file mime type // $info['size'] - The file size   echo $info['name'];
  14.             $tmpfile = tempnam("/tmp", "tl");
  15.             if($info['size']>0){
  16.                 $MadelineProto->downloadToFile($message['media'], $tmpfile);
  17.                 $file_url=uploadS3($sender,$info['name'].$info['ext'],$tmpfile);
  18.                 unlink($tmpfile);
  19.             }
  20.             }catch(Exception $e){
  21.                 //$info =$MadelineProto->getDownloadInfo($message['media']);
  22.                 //   [_] => messageMediaWebPage
  23.             }
  24.          } */
  25.          if(isset($message['message'])){
  26.               echo "id: " . $message['id'];//.':'.$file_url['url'] . "\n";
  27.                echo "\n";
  28.             $q->push([
  29.                     'id'=>$message['id'],
  30.                     //'media_url'=>@$file_url['url'],
  31.                     'msg'=>@$message['message'],
  32.                     ]);
  33.          }
  34.     }
  35.     $offset_id = end($messages_Messages['messages'])['id'];
  36. } while (true);
  37. }catch(Exception $e){}
Add Comment
Please, Sign In to add comment