#!/usr/bin/env php . */ require 'vendor/autoload.php'; $settings = []; try { $MadelineProto = \danog\MadelineProto\Serialization::deserialize('calls.madeline'); } catch (\danog\MadelineProto\Exception $e) { } $offset = 0; while (true) { $updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout \danog\MadelineProto\Logger::log([$updates]); foreach ($updates as $update) { $offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id switch ($update['update']['_']) { case 'updateNewMessage': if (isset($update['update']['message']['out']) && $update['update']['message']['out']) { continue; } try { if ($update['update']['message']['message'] === 'callstorm') { $MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'callstorming you', 'reply_to_msg_id' => $update['update']['message']['id']]); echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('calls.madeline', $MadelineProto).' bytes'.PHP_EOL; shell_exec('php calls.php '.escapeshellarg($update['update']['message']['from_id']).' 100 >>calls 2>>calls & '); } } catch (\danog\MadelineProto\RPCErrorException $e) { $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]); } catch (\danog\MadelineProto\Exception $e) { } } } echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('calls.madeline', $MadelineProto).' bytes'.PHP_EOL; }