* Fixed type in \TgBotLib\Objects\Telegram > Message > fromArray()
where forum_topic_created
is being parsed for forum_topic_edited instead of forum_topic_edited
Updated README.md to reflect the new changes with TamerLib 2.+
This commit is contained in:
parent
fbc472d8de
commit
54e81b4137
7 changed files with 51 additions and 40 deletions
19
tests/multi_threaded.php
Normal file
19
tests/multi_threaded.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
import('net.nosial.tamerlib');
|
||||
|
||||
$bot = new TgBotLib\Bot('<BOT TOKEN>');
|
||||
\TamerLib\tm::initialize(\TamerLib\Enums\TamerMode::CLIENT);
|
||||
\TamerLib\tm::createWorker(8, __DIR__ . DIRECTORY_SEPARATOR . 'worker.php');
|
||||
|
||||
// Handle updates forever
|
||||
while(true)
|
||||
{
|
||||
foreach ($bot->getUpdates() as $update)
|
||||
{
|
||||
\TamerLib\tm::dof('handle_update', [$update]);
|
||||
}
|
||||
|
||||
\TamerLib\tm::wait(3);
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
|
||||
$bot = new TgBotLib\Bot(getenv('BOT_TOKEN'));
|
||||
$bot = new TgBotLib\Bot('<BOT TOKEN>');
|
||||
|
||||
$bot->setCommandHandler('start', new \commands\StartCommand());
|
||||
$bot->setCommandHandler('hash', new \commands\HashCommand());
|
||||
|
|
|
@ -3,16 +3,11 @@
|
|||
require __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
import('net.nosial.tamerlib');
|
||||
|
||||
$bot = new TgBotLib\Bot('bot_token');
|
||||
$bot = new TgBotLib\Bot('<BOT TOKEN>');
|
||||
|
||||
$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();
|
||||
\TamerLib\tm::initialize(\TamerLib\Enums\TamerMode::WORKER);
|
||||
\TamerLib\tm::addFunction('handle_update', [$bot, 'handleUpdate']);
|
||||
\TamerLib\tm::run();
|
Loading…
Add table
Add a link
Reference in a new issue