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 );