Show error
All checks were successful
Deploy App / deploy (push) Successful in 11s

This commit is contained in:
2025-08-31 22:41:48 +02:00
parent 7764af432a
commit 6a72b7150b
7 changed files with 49 additions and 39 deletions

View File

@@ -14,27 +14,30 @@ class RunBot implements ShouldQueue
/**
* Create a new job instance.
*/
public function __construct(private Bot $bot, private BotLog $log) {}
public function __construct(private int $bot_id, private int $log_id) {}
/**
* Execute the job.
*/
public function handle(): void
{
$class = new $this->bot->class($this->bot->config ?? []);
$bot = Bot::findOrFail($this->bot_id);
$log = BotLog::findOrFail($this->log_id);
try {
$class = new $bot->class($bot->config ?? []);
$class->run();
// Update the log entry on success
$this->log->update([
$log->update([
'finished_at' => now(),
'status' => 'success',
// 'output' => is_string($result) ? $result : json_encode($result, JSON_PRETTY_PRINT),
]);
} catch (\Throwable $e) {
// Log the error in the bot log
$this->log->update([
$log->update([
'finished_at' => now(),
'status' => 'failed',
'error' => $e->getMessage(),