Skip to content

Instantly share code, notes, and snippets.

@esin
Created September 1, 2022 19:50
Show Gist options
  • Save esin/6df96e5d350470e0f0ffc5df769a8274 to your computer and use it in GitHub Desktop.
Save esin/6df96e5d350470e0f0ffc5df769a8274 to your computer and use it in GitHub Desktop.
<?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->start();
$channel = '@ivanteevka_tv';
$offset_id = 0;
$limit = 5;
do {
$messages_Messages = $MadelineProto->messages->getHistory(['peer' => $channel, 'offset_id' => $offset_id, 'offset_date' => 0, 'add_offset' => 0, 'limit' => $limit, 'max_id' => 0, 'min_id' => 0, 'hash' => 0]);
if (count($messages_Messages['messages']) == 0) break;
foreach ($messages_Messages['messages'] as $message) {
$messages_MessageViews = $MadelineProto->messages->getMessagesViews(['peer' => $channel, 'id' => [$message['id']], 'increment' => false]);
if (count($messages_MessageViews['views']) > 0) {
echo "id: " . $message['id'] . " views: " . $messages_MessageViews['views'][0]['views'];
$ExportedMessageLink = $MadelineProto->channels->exportMessageLink(['grouped' => false, 'thread' => false, 'channel' => $channel, 'id' => $message['id']]);
echo " url: ". $ExportedMessageLink['link'];
$Updates = $MadelineProto->messages->getMessagesReactions(['peer' => $channel, 'id' => [$message['id']]]);
$reactionCount = 0;
foreach($Updates['updates'][0]['reactions']['results'] as $reaction){
// echo $reaction
$reactionCount = $reactionCount + $reaction['count'];
}
echo " reactions: ". $reactionCount;
echo "\n\n\n";
}
}
$offset_id = end($messages_Messages['messages'])['id'];
sleep(2);
} while (true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment