Add StartCommand and update HashCommand to use BotOld

This commit is contained in:
netkas 2024-09-30 02:35:01 -04:00
parent ee5f204fc1
commit 1231e7d387
2 changed files with 28 additions and 3 deletions

View file

@ -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());

View 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()
);
}
}