Files
2026-08-27 11:09:59 -07:00

40 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\EducAI\Command;
use OC\Core\Command\Base;
use OCA\EducAI\Service\TalkBotRegistrationService;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class SyncTalkBot extends Base {
public function __construct(
private TalkBotRegistrationService $talkBotRegistrationService,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('educai:talk:bot:sync')
->setDescription('Register or repair the NuQloud-AI Talk bot');
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$result = $this->talkBotRegistrationService->syncRegistration(null, true, true);
$status = (string)($result['status'] ?? 'error');
$message = trim((string)($result['message'] ?? 'NuQloud-AI Talk bot synchronization did not return a result.'));
if ($status === 'error') {
$output->writeln('<error>' . $message . '</error>');
return 1;
}
$output->writeln($message);
return 0;
}
}