Removed old tests
This commit is contained in:
parent
5e6cc4c827
commit
286df9b684
8 changed files with 0 additions and 112 deletions
|
@ -20,7 +20,6 @@ class BotTest extends TestCase
|
||||||
public function getMeTest(): void
|
public function getMeTest(): void
|
||||||
{
|
{
|
||||||
$result = $this->bot->getMe();
|
$result = $this->bot->getMe();
|
||||||
|
|
||||||
$this->assertIsArray($result);
|
$this->assertIsArray($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// Import ncc
|
|
||||||
require 'ncc';
|
|
||||||
|
|
||||||
import('net.nosial.tgbotlib');
|
|
||||||
|
|
||||||
// Require commands & event handlers
|
|
||||||
require 'commands' . DIRECTORY_SEPARATOR . 'StartCommand.php';
|
|
||||||
require 'commands' . DIRECTORY_SEPARATOR . 'HashCommand.php';
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace commands;
|
|
||||||
|
|
||||||
use TgBotLib\BotOld;
|
|
||||||
use TgBotLib\Exceptions\TelegramException;
|
|
||||||
use TgBotLib\Interfaces\CommandInterface;
|
|
||||||
use TgBotLib\Objects\Update;
|
|
||||||
|
|
||||||
class HashCommand implements CommandInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param BotOld $bot
|
|
||||||
* @param Update $update
|
|
||||||
* @return void
|
|
||||||
* @throws TelegramException
|
|
||||||
*/
|
|
||||||
public function handle(BotOld $bot, Update $update): void
|
|
||||||
{
|
|
||||||
// Usage: /hash <text>
|
|
||||||
$data = str_replace('/hash ', '', $update->getMessage()?->getText());
|
|
||||||
$bot->sendMessage(
|
|
||||||
$update->getMessage()?->getChat()?->getId(), md5($data)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace commands;
|
|
||||||
|
|
||||||
use TgBotLib\BotOld;
|
|
||||||
use TgBotLib\Exceptions\TelegramException;
|
|
||||||
use TgBotLib\Interfaces\CommandInterface;
|
|
||||||
use TgBotLib\Objects\Update;
|
|
||||||
|
|
||||||
class StartCommand implements CommandInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param BotOld $bot
|
|
||||||
* @param Update $update
|
|
||||||
* @return void
|
|
||||||
* @throws TelegramException
|
|
||||||
*/
|
|
||||||
public function handle(BotOld $bot, Update $update): void
|
|
||||||
{
|
|
||||||
// reply to the incoming message
|
|
||||||
$bot->sendMessage(
|
|
||||||
$update->getMessage()?->getChat()?->getId(), 'Hello, ' . $update->getMessage()?->getFrom()?->getFirstName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
require 'autoload.php';
|
|
||||||
|
|
||||||
var_dump(\TgBotLib\Classes\Utilities::getCurrency('EUR'));
|
|
||||||
var_dump(\TgBotLib\Classes\Utilities::getCurrency('CAD'));
|
|
||||||
var_dump(\TgBotLib\Classes\Utilities::getCurrency('USD'));
|
|
|
@ -1,19 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
|
|
||||||
import('net.nosial.tamerlib');
|
|
||||||
|
|
||||||
$bot = new TgBotLib\BotOld('<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);
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
|
|
||||||
|
|
||||||
$bot = new TgBotLib\BotOld('<BOT TOKEN>');
|
|
||||||
|
|
||||||
$bot->setCommandHandler('start', new \commands\StartCommand());
|
|
||||||
$bot->setCommandHandler('hash', new \commands\HashCommand());
|
|
||||||
|
|
||||||
$bot->handleGetUpdates(true);
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
|
|
||||||
import('net.nosial.tamerlib');
|
|
||||||
|
|
||||||
$bot = new TgBotLib\BotOld('<BOT TOKEN>');
|
|
||||||
|
|
||||||
$bot->setCommandHandler('start', new \commands\StartCommand());
|
|
||||||
$bot->setCommandHandler('hash', new \commands\HashCommand());
|
|
||||||
|
|
||||||
\TamerLib\tm::initialize(\TamerLib\Enums\TamerMode::WORKER);
|
|
||||||
\TamerLib\tm::addFunction('handle_update', [$bot, 'handleUpdate']);
|
|
||||||
\TamerLib\tm::run();
|
|
Loading…
Add table
Reference in a new issue