setName('talk:bot:list') ->setDescription('List all installed bots of the server or a conversation') ->addArgument( 'token', InputArgument::OPTIONAL, 'Conversation token to limit the bot list for' ) ; } protected function execute(InputInterface $input, OutputInterface $output): int { $bots = $this->botServerMapper->getAllBots(); $token = $input->getArgument('token'); if ($token) { $botIds = array_map(static function (BotConversation $bot): int { return $bot->getBotId(); }, $this->botConversationMapper->findForToken($token)); } $data = []; foreach ($bots as $bot) { if ($token && !in_array($bot->getId(), $botIds, true)) { continue; } $botData = $bot->jsonSerialize(); $botData['features'] = Bot::featureFlagsToLabels($botData['features']); if (!$output->isVerbose()) { unset($botData['url']); unset($botData['url_hash']); unset($botData['secret']); unset($botData['last_error_date']); unset($botData['last_error_message']); } $data[] = $botData; } $this->writeTableInOutputFormat($input, $output, $data); return 0; } }