Add bot logs
All checks were successful
Deploy App / deploy (push) Successful in 11s

This commit is contained in:
2025-08-31 21:54:18 +02:00
parent 77ebc6bce1
commit 378355ad5b
16 changed files with 355 additions and 20 deletions

46
app/Bots/BashScript.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
namespace App\Bots;
use Illuminate\Support\Facades\Log;
class BashScript implements BotContract
{
protected array $config;
public function __construct(array $config = [])
{
$this->config = $config;
}
public function run(): void
{
if (!empty($this->config['script'])) {
// Execute the bash script
$script = $this->config['script'];
$output = [];
$returnVar = null;
exec($script, $output, $returnVar);
if ($returnVar !== 0) {
// Log error if the script failed
\Illuminate\Support\Facades\Log::error("Bash script execution failed: " . implode("\n", $output));
} else {
Log::info("Bash script executed successfully: " . implode("\n", $output));
}
}
}
public static function configSchema(): array
{
return [
'script' => [
'type' => 'textarea',
'label' => 'Bash Script',
'rules' => [
'required',
]
],
];
}
}