Added single-threaded and multi-threaded example
This commit is contained in:
parent
da6abceed2
commit
040426a63c
9 changed files with 110 additions and 15 deletions
18
tests/worker.php
Normal file
18
tests/worker.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
import('net.nosial.tamerlib');
|
||||
|
||||
$bot = new TgBotLib\Bot('865804194:AAHTo9aIFP5X47dMYLJ6eoldHJnM6sc3LBc');
|
||||
|
||||
$bot->setCommandHandler('start', new \commands\StartCommand());
|
||||
$bot->setCommandHandler('hash', new \commands\HashCommand());
|
||||
|
||||
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)));
|
||||
});
|
||||
|
||||
TamerLib\Tamer::work();
|
Loading…
Add table
Add a link
Reference in a new issue