/** * 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(); }
/** * @test */ public function cancelConversation() { $info = TestHelpers::startFakeConversation('command'); $conversation = new Conversation($info['user_id'], $info['chat_id'], 'command'); $this->assertTrue($conversation->exists()); $conversation->cancel(); $conversation2 = new Conversation($info['user_id'], $info['chat_id']); $this->assertFalse($conversation2->exists()); }