From d172f1d01256703d77fb10ca42b93f46ab482e85 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sun, 2 Nov 2025 16:53:35 +0100 Subject: [PATCH] Replace old scrape script with proper console command --- app/Console/Commands/IrcScraperCommand.php | 59 ++++++++++++++++++++++ app/Services/Tmux/TmuxMonitorService.php | 1 - app/Services/Tmux/TmuxTaskRunner.php | 9 +--- composer.lock | 47 +++++++++-------- misc/IRCScraper/.gitignore | 1 - misc/IRCScraper/README.txt | 3 -- misc/IRCScraper/scrape.php | 32 ------------ 7 files changed, 84 insertions(+), 68 deletions(-) create mode 100644 app/Console/Commands/IrcScraperCommand.php delete mode 100644 misc/IRCScraper/.gitignore delete mode 100644 misc/IRCScraper/README.txt delete mode 100644 misc/IRCScraper/scrape.php diff --git a/app/Console/Commands/IrcScraperCommand.php b/app/Console/Commands/IrcScraperCommand.php new file mode 100644 index 000000000..4f1cadb8e --- /dev/null +++ b/app/Console/Commands/IrcScraperCommand.php @@ -0,0 +1,59 @@ +error('ERROR! You must put a username in config/irc_settings.php'); + + return self::FAILURE; + } + + // Use Laravel's built-in quiet mode for silent operation + $silent = $this->option('quiet'); + $debug = $this->option('debug'); + + if (! $silent) { + $this->info('Starting IRC Scraper...'); + if ($debug) { + $this->warn('Debug mode enabled'); + } + } + + try { + new IRCScraper($silent, $debug); + + return self::SUCCESS; + } catch (\Exception $e) { + if (! $silent) { + $this->error($e->getMessage()); + } + + return self::FAILURE; + } + } +} diff --git a/app/Services/Tmux/TmuxMonitorService.php b/app/Services/Tmux/TmuxMonitorService.php index d6b5ed742..a7b2ec3a2 100644 --- a/app/Services/Tmux/TmuxMonitorService.php +++ b/app/Services/Tmux/TmuxMonitorService.php @@ -34,7 +34,6 @@ class TmuxMonitorService { $this->runVar['paths']['misc'] = base_path().'/misc/'; $this->runVar['paths']['cli'] = base_path().'/cli/'; - $this->runVar['paths']['scraper'] = base_path().'/misc/IRCScraper/scrape.php'; $this->runVar['constants'] = $this->tmux->getConstantSettings(); $this->runVar['settings'] = $this->tmux->getMonitorSettings(); diff --git a/app/Services/Tmux/TmuxTaskRunner.php b/app/Services/Tmux/TmuxTaskRunner.php index 1812e7dee..9f302ed7f 100644 --- a/app/Services/Tmux/TmuxTaskRunner.php +++ b/app/Services/Tmux/TmuxTaskRunner.php @@ -164,14 +164,9 @@ class TmuxTaskRunner return $this->disablePane($pane, 'IRC Scraper', 'disabled in settings'); } - $scraperScript = base_path('misc/IRCScraper/scrape.php'); - - if (! file_exists($scraperScript)) { - return $this->disablePane($pane, 'IRC Scraper', 'script not found'); - } - $niceness = Settings::settingValue('niceness') ?? 2; - $command = "nice -n{$niceness} php {$scraperScript} true"; + $artisan = base_path('artisan'); + $command = "nice -n{$niceness} php {$artisan} irc:scrape --quiet"; $command = $this->buildCommand($command, ['log_pane' => 'scraper']); return $this->paneManager->respawnPane($pane, $command); diff --git a/composer.lock b/composer.lock index 4a7db2e1e..376bf0e7b 100644 --- a/composer.lock +++ b/composer.lock @@ -1419,29 +1419,28 @@ }, { "name": "dragonmantank/cron-expression", - "version": "v3.4.0", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/dragonmantank/cron-expression.git", - "reference": "8c784d071debd117328803d86b2097615b457500" + "reference": "d61a8a9604ec1f8c3d150d09db6ce98b32675013" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/8c784d071debd117328803d86b2097615b457500", - "reference": "8c784d071debd117328803d86b2097615b457500", + "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/d61a8a9604ec1f8c3d150d09db6ce98b32675013", + "reference": "d61a8a9604ec1f8c3d150d09db6ce98b32675013", "shasum": "" }, "require": { - "php": "^7.2|^8.0", - "webmozart/assert": "^1.0" + "php": "^8.2|^8.3|^8.4|^8.5" }, "replace": { "mtdowling/cron-expression": "^1.0" }, "require-dev": { - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.0", - "phpunit/phpunit": "^7.0|^8.0|^9.0" + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^1.12.32|^2.1.31", + "phpunit/phpunit": "^8.5.48|^9.0" }, "type": "library", "extra": { @@ -1472,7 +1471,7 @@ ], "support": { "issues": "https://github.com/dragonmantank/cron-expression/issues", - "source": "https://github.com/dragonmantank/cron-expression/tree/v3.4.0" + "source": "https://github.com/dragonmantank/cron-expression/tree/v3.6.0" }, "funding": [ { @@ -1480,7 +1479,7 @@ "type": "github" } ], - "time": "2024-10-09T13:47:03+00:00" + "time": "2025-10-31T18:51:33+00:00" }, { "name": "egulias/email-validator", @@ -7637,16 +7636,16 @@ }, { "name": "propaganistas/laravel-disposable-email", - "version": "2.4.19", + "version": "2.4.20", "source": { "type": "git", "url": "https://github.com/Propaganistas/Laravel-Disposable-Email.git", - "reference": "5347882b8576d809073300936d787e3405702c66" + "reference": "d36848172878f6f42c7dbee98e5061bdcda04e3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Propaganistas/Laravel-Disposable-Email/zipball/5347882b8576d809073300936d787e3405702c66", - "reference": "5347882b8576d809073300936d787e3405702c66", + "url": "https://api.github.com/repos/Propaganistas/Laravel-Disposable-Email/zipball/d36848172878f6f42c7dbee98e5061bdcda04e3f", + "reference": "d36848172878f6f42c7dbee98e5061bdcda04e3f", "shasum": "" }, "require": { @@ -7701,7 +7700,7 @@ ], "support": { "issues": "https://github.com/Propaganistas/Laravel-Disposable-Email/issues", - "source": "https://github.com/Propaganistas/Laravel-Disposable-Email/tree/2.4.19" + "source": "https://github.com/Propaganistas/Laravel-Disposable-Email/tree/2.4.20" }, "funding": [ { @@ -7709,7 +7708,7 @@ "type": "github" } ], - "time": "2025-10-01T00:55:01+00:00" + "time": "2025-11-01T00:54:08+00:00" }, { "name": "psr/cache", @@ -14669,21 +14668,21 @@ }, { "name": "driftingly/rector-laravel", - "version": "2.1.1", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/driftingly/rector-laravel.git", - "reference": "abc336cbf06f53d90ab74cecfd319379fc55d408" + "reference": "d7cd932cff9e398a43393f1a1a63b27d574e35ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/abc336cbf06f53d90ab74cecfd319379fc55d408", - "reference": "abc336cbf06f53d90ab74cecfd319379fc55d408", + "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/d7cd932cff9e398a43393f1a1a63b27d574e35ef", + "reference": "d7cd932cff9e398a43393f1a1a63b27d574e35ef", "shasum": "" }, "require": { "php": "^7.4 || ^8.0", - "rector/rector": "^2.0" + "rector/rector": "^2.2.7" }, "type": "rector-extension", "autoload": { @@ -14698,9 +14697,9 @@ "description": "Rector upgrades rules for Laravel Framework", "support": { "issues": "https://github.com/driftingly/rector-laravel/issues", - "source": "https://github.com/driftingly/rector-laravel/tree/2.1.1" + "source": "https://github.com/driftingly/rector-laravel/tree/2.1.2" }, - "time": "2025-10-23T13:53:44+00:00" + "time": "2025-10-31T21:56:58+00:00" }, { "name": "ergebnis/composer-normalize", diff --git a/misc/IRCScraper/.gitignore b/misc/IRCScraper/.gitignore deleted file mode 100644 index 9f37e3549..000000000 --- a/misc/IRCScraper/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/settings.php diff --git a/misc/IRCScraper/README.txt b/misc/IRCScraper/README.txt deleted file mode 100644 index 03ce48011..000000000 --- a/misc/IRCScraper/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -These scripts run IRC bots to get PRE information. - -Next you can run scrape.php, it will tell you all the options. diff --git a/misc/IRCScraper/scrape.php b/misc/IRCScraper/scrape.php deleted file mode 100644 index f83a995e4..000000000 --- a/misc/IRCScraper/scrape.php +++ /dev/null @@ -1,32 +0,0 @@ - /dev/null 2>&1 ; (unix) Scrapes PRE with no text output, in the background (you can close your terminal window).'.PHP_EOL. - 'php '.$argv[0].' true false true ; Scrapes PRE with text output and debug output.'.PHP_EOL. - 'php '.$argv[0].' true true true ; Scrapes PRE with debug but no text output.'.PHP_EOL - ); -} - -if (config('irc_settings.scrape_irc_username') === '') { - exit('ERROR! You must put a username in config/irc_settings.php'.PHP_EOL); -} - -$silent = (isset($argv[2]) && $argv[2] === 'true'); -$debug = (isset($argv[3]) && $argv[3] === 'true'); - -// Start scraping. -try { - new IRCScraper($silent, $debug); -} catch (Exception $e) { - echo $e->getMessage(); -}