Files
max-bot-test/src/Scenario/HelpScenario.php
pkirillw 9385fbdd6e
Some checks failed
Deploy Max Bot Test / deploy (push) Failing after 3s
feat: max-bot-test initial — full surface coverage
- Slim 4 PSR-15 webhook, PHP-DI 7, Symfony Console 8
- 13 update handlers, 30+ command scenarios, all 7 button types
- Composer pulls pkirillw/max-bot-api-php from GitHub vcs
- Multi-stage Dockerfile (php-fpm 8.4-alpine) + nginx
- docker-compose.yml targets server (npm_default external)
- docker-compose.override.yml for local dev (gitignored)
- .gitea/workflows/deploy.yml mirrors ghost-blog-bot pattern

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 00:01:06 +03:00

102 lines
3.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace App\Scenario;
use App\Util\ParsedCommand;
use Pkirillw\MaxBotApi\Builder\Keyboard;
use Pkirillw\MaxBotApi\Builder\Message as MessageBuilder;
use Pkirillw\MaxBotApi\Scheme\Enum\Format;
use Pkirillw\MaxBotApi\Scheme\Enum\Intent;
use Pkirillw\MaxBotApi\Scheme\Update\MessageCreatedUpdate;
final class HelpScenario extends AbstractScenario
{
public function handle(MessageCreatedUpdate $update, ParsedCommand $command): void
{
$keyboard = new Keyboard();
$keyboard->addRow()
->addCallback('Клавиатуры', 'demo_keyboard', Intent::Positive)
->addCallback('Загрузки', 'demo_uploads');
$keyboard->addRow()->addLink('Документация MAX', 'https://dev.max.ru');
$text = <<<'MD'
*max-bot-test* — тестовый бот для [`max-bot-api-php`]
Доступные команды:
*Bot*
/bot — getBot()
/bot_patch <name> — patchBot()
*Chats*
/chats [count] — getChats()
/chat <id> — getChat() + getChatMembership()
/members <id> — getChatMembers() + getChatAdmins()
/action <chatId> <typing_on|typing_off|mark_seen|sending_photo|sending_video|sending_audio> — sendAction()
/pin <chatId> <messageId> — pinMessage()
/edit_chat <chatId> <title> — editChat()
/add_member <chatId> <userId> — addMember()
/remove_member <chatId> <userId> — removeMember()
/leave <chatId> — leaveChat()
*Messages*
/send_text <text> — send() plain
/send_markdown <text> — Format::Markdown
/send_html <text> — Format::Html
/reply <messageId> <text> — setReply()
/forward <messageId> — setForward()
/edit <messageId> <text> — editMessage()
/delete <messageId> — deleteMessage()
/messages <chatId> [count] — getMessages()
/message <messageId> — getMessage()
/markup <userId> — addMarkUp() (mention)
/notify <text> — setNotify(false) (silent)
/disable_preview <url> — setDisableLinkPreview(true)
/keyboard — inline keyboard со всеми 8 типами кнопок
*Uploads*
/upload_photo_file [path] — uploadPhotoFromFile()
/upload_photo_url <url> — uploadPhotoFromUrl()
/upload_photo_bytes — uploadPhotoFromBytes()
/upload_photo_base64 — uploadPhotoFromBase64()
/upload_audio [path] — uploadMediaFromFile(Audio)
/upload_video [path] — uploadMediaFromFile(Video)
/upload_file [path] — uploadMediaFromFile(File)
/upload_url <audio|video|file> <url> — uploadMediaFromUrl()
*Attachments*
/attach_location <lat> <lng> — addLocation()
/attach_contact <name> <userId> — addContact()
/attach_sticker <code> — addSticker()
*Phone (notify)*
/phone_check <phone> — check()
/phone_list <phone1,phone2> — listExist()
*Subscriptions (CLI)*
`make subscribe`, `make unsubscribe`, `bin/console subs:list`
*Debug*
/debug <on|off|raw|err> — переключение Debugs + Options::withDebug
MD;
$this->api->messages->send(
MessageBuilder::new()
->setChat($update->getChatId())
->setText($text)
->setFormat(Format::Markdown)
->addKeyboard($keyboard),
);
}
public function handleUnknown(MessageCreatedUpdate $update, ParsedCommand $command): void
{
$this->replyMarkdown(
$update,
sprintf('Не знаю команду `%s`. Набери `/help`.', $command->name),
);
}
}