#!/usr/bin/env php . */ require '../vendor/autoload.php'; $settings = []; $Lua = false; try { $Lua = \danog\MadelineProto\Serialization::deserialize('bot.madeline'); } catch (\danog\MadelineProto\Exception $e) { } if (file_exists('token.php') && !is_object($Lua)) { include_once 'token.php'; $MadelineProto = new \danog\MadelineProto\API($settings); $authorization = $MadelineProto->bot_login($token); \danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE); $Lua = new \danog\MadelineProto\Lua('madeline.lua', $MadelineProto); } $offset = 0; while (true) { $updates = $Lua->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 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 $Lua->madeline_update_callback($update['update']); } echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('bot.madeline', $Lua).' bytes'.PHP_EOL; }