From ea22c19d2bcd2aa617a1acc94d79977a0a6d255b Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Sun, 2 Nov 2025 19:17:05 +0100 Subject: [PATCH] Notification Eldorado --- .../EldoradoRobuxPriceNotification.php | 48 +++++++++++++++++++ .../EldoradoRobuxPriceNotificationBody.php | 34 +++++++++++++ .../EldoradoRobuxPriceSentryJob.php | 8 ++-- 3 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotification.php create mode 100644 app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotificationBody.php diff --git a/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotification.php b/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotification.php new file mode 100644 index 0000000..1b3c14d --- /dev/null +++ b/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotification.php @@ -0,0 +1,48 @@ +price = $price; + $this->threshold = Job::find($jobId)->jobInfosTable()->get('eldorado_robux_price_threshold'); + $this->link = $link; + + $this->setBody($this->generateBody()); + } + + private function generateBody() { + return new EldoradoRobuxPriceNotificationBody($this->price, $this->threshold, $this->link); + } + + public function getTitle(): Stringifiable { + return new StringifiableSimpleText("Alerte Robux Eldorado 🤑"); + } + + /** + * @inheritDoc + */ + public function getImageProjectPath(): string|null { + return null; + } + + /** + * @inheritDoc + */ + public function getLinkURL(): string|null { + return $this->link; + } +} diff --git a/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotificationBody.php b/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotificationBody.php new file mode 100644 index 0000000..97741b2 --- /dev/null +++ b/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotificationBody.php @@ -0,0 +1,34 @@ +price = $price; + $this->threshold = $threshold; + $this->link = $link; + } + + /** + * @inheritDoc + */ + public function toMarkdownString(): string { + return "Le prix des Robux sur Eldorado est actuellement de **" . number_format($this->price, 7, ",", " ") . " €**/Robux, ce qui est inférieur ou égal au seuil de **" . number_format($this->threshold, 5, ",", " ") . " €**.\n\n[Voir l'offre sur Eldorado]( " . $this->link . " )"; + } + + /** + * @inheritDoc + */ + public function toString(): string { + return "Le prix des Robux sur Eldorado est actuellement de " . number_format($this->price, 7, ",", " ") . " €/Robux, ce qui est inférieur ou égal au seuil de " . number_format($this->threshold, 5, ",", " ") . " €.\n\nVoir l'offre sur Eldorado : " . $this->link; + } +} diff --git a/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceSentryJob.php b/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceSentryJob.php index f88c828..d5a97d7 100644 --- a/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceSentryJob.php +++ b/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceSentryJob.php @@ -107,18 +107,16 @@ class EldoradoRobuxPriceSentryJob extends BrowserJob implements ShouldBeUniqueUn ])); if ($lowestPrice <= $threshold) { - $message = "Le prix des Robux sur Eldorado est actuellement de **" . number_format($lowestPrice, 5, ",", " ") . " €**/Robux, ce qui est inférieur ou égal au seuil de **" . number_format($threshold, 5, ",", " ") . " €**.\n\n[Voir l'offre sur Eldorado]( " . self::LINK . " )"; $options = []; - if ($this->jobInfos->get("eldorado_robux_price_discord_webhook") !== null) { // Custom discord webhook $options["discord_webhook_url"] = $this->jobInfos->get("eldorado_robux_price_discord_webhook"); } AllNotification::send( - new SimpleNotification( + new EldoradoRobuxPriceNotification( $this->jobId, - "Alerte Robux Eldorado 🤑", - $message + $lowestPrice, + self::LINK ), $options );