setName('talk:bot:remove') ->setDescription('Remove a bot from a conversation') ->addArgument( 'bot-id', InputArgument::REQUIRED, 'The ID of the bot to remove in a conversation' ) ->addArgument( 'token', InputArgument::IS_ARRAY, 'Conversation tokens to remove bot up for' ) ; } protected function execute(InputInterface $input, OutputInterface $output): int { $botId = (int)$input->getArgument('bot-id'); $tokens = $input->getArgument('token'); try { $botServer = $this->botServerMapper->findById($botId); } catch (DoesNotExistException) { $output->writeln('Bot could not be found by id: ' . $botId . ''); return 1; } $this->botConversationMapper->deleteByBotIdAndTokens($botId, $tokens); $output->writeln('Remove bot from given conversations'); foreach ($tokens as $token) { try { $room = $this->roomManager->getRoomByToken($token); } catch (RoomNotFoundException) { continue; } $event = new BotDisabledEvent($room, $botServer); $this->dispatcher->dispatchTyped($event); } return 0; } }