removeKeyboard('Nothing to cancel.'); } /** * Main command execution * * @return ServerResponse * @throws TelegramException */ public function execute(): ServerResponse { $text = 'No active conversation!'; // Cancel current conversation if any $conversation = new Conversation( $this->getMessage()->getFrom()->getId(), $this->getMessage()->getChat()->getId() ); if ($conversation_command = $conversation->getCommand()) { $conversation->cancel(); $text = 'Conversation "' . $conversation_command . '" cancelled!'; } return $this->removeKeyboard($text); } /** * Remove the keyboard and output a text. * * @param string $text * * @return ServerResponse * @throws TelegramException */ private function removeKeyboard(string $text): ServerResponse { return $this->replyToChat($text, [ 'reply_markup' => Keyboard::remove(['selective' => true]), ]); } }