Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Longman\TelegramBot\Commands\UserCommands;
- use Longman\TelegramBot\Commands\AdminCommands\PanelCommand;
- use Longman\TelegramBot\Commands\UserCommand;
- use Longman\TelegramBot\Conversation;
- use Longman\TelegramBot\DB;
- use Longman\TelegramBot\Entities\CallbackQuery;
- use Longman\TelegramBot\Entities\InlineKeyboard;
- use Longman\TelegramBot\Entities\InlineKeyboardButton;
- use Longman\TelegramBot\Entities\Keyboard;
- use Longman\TelegramBot\Entities\Update;
- use Longman\TelegramBot\Request;
- class TestCommand extends UserCommand
- {
- protected $name = 'test';
- protected $description = 'Nur für den Test';
- protected $usage = '/test';
- protected $version = '1.0.0';
- protected $need_mysql = true;
- protected $conversation;
- /**
- * Обработчик кнопки Refresh
- *
- * @param CallbackQuery $query
- * @return \Longman\TelegramBot\Entities\ServerResponse
- * @throws \Longman\TelegramBot\Exception\TelegramException
- */
- public static function refreshHandler(CallbackQuery $query) {
- $callback_data = $query->getData();
- if ($callback_data !== 'refresh') {
- return Request::emptyResponse();
- }
- $keyboard = new InlineKeyboard([
- ['text' => 'FAQ', 'callback_data' => 'faq'],
- ['text' => 'Отзывы', 'callback_data' => 'reviews'],
- ]);
- return Request::editMessageText([
- 'chat_id' => $query->getMessage()->getChat()->getId(),
- 'message_id' => $query->getMessage()->getMessageId(),
- 'text' => 'Текст сообщения',
- 'parse_mode' => 'Markdown',
- 'reply_markup' => $keyboard,
- ]);
- }
- /**
- * @return \Longman\TelegramBot\Entities\ServerResponse
- * @throws InlineKeyboardPaginationException
- * @throws \Longman\TelegramBot\Exception\TelegramException
- */
- public function execute()
- {
- $message = $this->getMessage();
- $chat = $message->getChat();
- $chat_id = $chat->getId();
- $user_id = $message->getFrom()->getId();
- $text = trim($message->getText(true));
- $pdo = DB::getPdo();
- ...
- if ($text === '') {
- $data['text'] = 'Тыкните на кнопку, чтобы обновить текст сообщения и кнопки.';
- $data['reply_markup'] = new InlineKeyboard([['text' => 'Обновить сообщение', 'callback_data' => 'refresh']]);
- return Request::sendMessage($data);
- }
- $result = Request::emptyResponse();
- ...
- return $result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement