diff --git a/app/Browser/Jobs/HellcaseBattles/HellcaseBattlesJob.php b/app/Browser/Jobs/HellcaseBattles/HellcaseBattlesJob.php index c79e7e0..ab90d2b 100644 --- a/app/Browser/Jobs/HellcaseBattles/HellcaseBattlesJob.php +++ b/app/Browser/Jobs/HellcaseBattles/HellcaseBattlesJob.php @@ -152,7 +152,14 @@ class HellcaseBattlesJob extends HellcaseJob implements ShouldBeUniqueUntilProce AllNotification::send(new JobDebugNotification($this->jobId, "Failed to screenshot battle")); } $this->battlesSent[$battle->getUrl()] = $battle->value; - AllNotification::send(new HellcaseBattlesNofication($this->jobId, $battle)); + + $options = []; + + if ($this->jobInfos->get("hellcase_battles_discord_webhook_url") !== null) { // Custom discord webhook + $options["discord_webhook_url"] = $this->jobInfos->get("hellcase_battles_discord_webhook_url"); + } + + AllNotification::send(new HellcaseBattlesNofication($this->jobId, $battle), $options); } private function createNewBattles() { diff --git a/app/Notification/NotificationProvider.php b/app/Notification/NotificationProvider.php index 6ccbdd0..17d1b04 100644 --- a/app/Notification/NotificationProvider.php +++ b/app/Notification/NotificationProvider.php @@ -3,5 +3,5 @@ namespace App\Notification; abstract class NotificationProvider { - abstract public static function send(Notification $notification): void; + abstract public static function send(Notification $notification, array $options): void; } diff --git a/app/Notification/Providers/AllNotification.php b/app/Notification/Providers/AllNotification.php index 05bb225..eaea47e 100644 --- a/app/Notification/Providers/AllNotification.php +++ b/app/Notification/Providers/AllNotification.php @@ -12,9 +12,9 @@ class AllNotification extends NotificationProvider { /** * @inheritDoc */ - public static function send(\App\Notification\Notification $notification): void { + public static function send(\App\Notification\Notification $notification, array $options = []): void { foreach (self::NOTIFICATIONS_PROVIDERS as $provider) { - $provider::send($notification); + $provider::send($notification, $options); } } } diff --git a/app/Notification/Providers/DiscordWebHookNotification.php b/app/Notification/Providers/DiscordWebHookNotification.php index d03015e..02d9fa7 100644 --- a/app/Notification/Providers/DiscordWebHookNotification.php +++ b/app/Notification/Providers/DiscordWebHookNotification.php @@ -13,7 +13,7 @@ class DiscordWebHookNotification extends NotificationProvider { /** * @inheritDoc */ - public static function send(\App\Notification\Notification $notification): void { + public static function send(\App\Notification\Notification $notification, array $options): void { /* Test Json for a complete embed : { @@ -44,7 +44,7 @@ class DiscordWebHookNotification extends NotificationProvider { "avatar_url": "https://www.fairytailrp.com/t40344-here-come-dat-boi" } */ - $webHookUrl = static::getDiscordWebHookUrl($notification->isError); + $webHookUrl = static::getDiscordWebHookUrl($notification->isError, $options); $body = [ "content"=> "", "tts"=> false, @@ -86,7 +86,11 @@ class DiscordWebHookNotification extends NotificationProvider { curl_close($ch); } - private static function getDiscordWebHookUrl(bool $isError): string { + private static function getDiscordWebHookUrl(bool $isError, array $options): string { + if ($options["discord_webhook_url"] !== null) { + return $options["discord_webhook_url"]; + } + $generalWebHookUrlKey = 'discord_webhook_url'; $generalWebHookUrl = Cache::rememberForever($generalWebHookUrlKey, function () use ($generalWebHookUrlKey) { return JobInfo::where('key', $generalWebHookUrlKey)->first()->value;