Split out areafix command processing, implemented start of filefix

This commit is contained in:
2024-11-26 12:23:07 +11:00
parent 521a9b0679
commit b67ae28b98
8 changed files with 273 additions and 45 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Classes\FTN\Process\Netmail\Robot\Filefix;
use App\Classes\FTN\Process\Netmail\Robot\Areafix\Base;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification;
use App\Classes\FTN\Process\Netmail\Robot\Filefix;
use App\Notifications\Netmails\Filefix\Help as HelpNotification;
// A Help Index Command
class Help extends Base
{
private const LOGKEY = 'FFH';
private const filefix_classes = 'app/Classes/FTN/Process/Netmail/Robot/Filefix';
private const command = '%HELP';
public static function help(): array
{
return [
self::command,
' This message!',
];
}
public function process(): string
{
Log::debug(sprintf('%s:- Processing [%s] for [%s]',self::LOGKEY,self::command,$this->mo->fftn->ftn));
$result = collect();
foreach (preg_grep('/^([^.])/',scandir(self::filefix_classes)) as $file) {
if (($file === 'Base.php') || (! str_ends_with(strtolower($file),'.php')))
continue;
$class = Filefix::commands.preg_replace('/\.php$/','',$file);
if ($result->count())
$result->push('');
$result = $result
->merge($class::help());
}
Notification::route('netmail',$this->mo->fftn)->notify(new HelpNotification($this->mo,$result));
return sprintf('%-25s <-- COMMAND PROCESSED',self::command);
}
}