diff --git a/README.md b/README.md index 9ba3d9a..077869b 100644 --- a/README.md +++ b/README.md @@ -132,10 +132,19 @@ To implement a single-threaded bot, it's very self-explanatory, you just need to ```php setCommandHandler('start', new \commands\StartCommand()); $bot->setCommandHandler('hash', new \commands\HashCommand()); + // Initialize the worker & register the handle_update function TamerLib\Tamer::initWorker(); - TamerLib\Tamer::addFunction('handle_update', function (\TamerLib\Objects\Job $job) use ($bot) { $bot->handleUpdate(\TgBotLib\Objects\Telegram\Update::fromArray(json_decode($job->getData(), true))); }); + // Work forever TamerLib\Tamer::work(); ``` @@ -184,20 +204,36 @@ Then create a master process that will send the updates to the worker: ```php getUpdates() as $update) { - TamerLib\Tamer::sendJob('handle_update', json_encode($update->toArray())); + TamerLib\Tamer::do('handle_update', json_encode($update->toArray())); } } ``` @@ -215,11 +251,10 @@ the `/start` command, you can use the `setCommandHandler` method: ```php setCommandHandler('start', new \commands\StartCommand()); ```