Retrieve the command to execute from the conversation
public getCommand ( ) : string | null | ||
return | string | null |
public function testNewConversationThatWillExistWithCommand() { $info = TestHelpers::startFakeConversation(); $conversation = new Conversation($info['user_id'], $info['chat_id'], 'command'); $this->assertTrue($conversation->exists()); $this->assertEquals('command', $conversation->getCommand()); }
/** * Execute command * * @return \Longman\TelegramBot\Entities\ServerResponse * @throws \Longman\TelegramBot\Exception\TelegramException */ public function execute() { //If a conversation is busy, execute the conversation command after handling the message $conversation = new Conversation($this->getMessage()->getFrom()->getId(), $this->getMessage()->getChat()->getId()); //Fetch conversation command if it exists and execute it if ($conversation->exists() && ($command = $conversation->getCommand())) { return $this->telegram->executeCommand($command); } return Request::emptyResponse(); }
/** * {@inheritdoc} */ public function execute() { $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->hideKeyboard($text); }