1. Go to this page and download the library: Download appto-team/telegram-bot library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
appto-team / telegram-bot example snippets
// app/GreetBot/GreetBot.php
final class GreetBot extends Bot
{
protected function boot(): void
{
$this->onCommand('start', StartCommand::class);
}
}
// app/GreetBot/Commands/StartCommand.php
final class StartCommand implements CommandHandler
{
public function handle(UpdateContext $context): void
{
$context->reply('Привет! Я на связи 👋');
}
}
// app/GreetBot/GreetBot.php
final class GreetBot extends Bot
{
protected function boot(): void
{
$this->onCommand('start', StartCommand::class);
}
}
// app/GreetBot/Commands/StartCommand.php
final class StartCommand implements CommandHandler
{
public function handle(UpdateContext $context): void
{
$context->reply('Hi! I\'m here 👋');
}
}