Add StartCommand and update HashCommand to use BotOld
This commit is contained in:
parent
ee5f204fc1
commit
1231e7d387
2 changed files with 28 additions and 3 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace commands;
|
||||
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\BotOld;
|
||||
use TgBotLib\Exceptions\TelegramException;
|
||||
use TgBotLib\Interfaces\CommandInterface;
|
||||
use TgBotLib\Objects\Telegram\Update;
|
||||
|
@ -10,12 +10,12 @@
|
|||
class HashCommand implements CommandInterface
|
||||
{
|
||||
/**
|
||||
* @param Bot $bot
|
||||
* @param BotOld $bot
|
||||
* @param Update $update
|
||||
* @return void
|
||||
* @throws TelegramException
|
||||
*/
|
||||
public function handle(Bot $bot, Update $update): void
|
||||
public function handle(BotOld $bot, Update $update): void
|
||||
{
|
||||
// Usage: /hash <text>
|
||||
$data = str_replace('/hash ', '', $update->getMessage()?->getText());
|
||||
|
|
25
tests/commands/StartCommand.php
Normal file
25
tests/commands/StartCommand.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace commands;
|
||||
|
||||
use TgBotLib\BotOld;
|
||||
use TgBotLib\Exceptions\TelegramException;
|
||||
use TgBotLib\Interfaces\CommandInterface;
|
||||
use TgBotLib\Objects\Telegram\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()
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue