Notification Eldorado
All checks were successful
Push image to registry / build-image (push) Successful in 4m2s
All checks were successful
Push image to registry / build-image (push) Successful in 4m2s
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Browser\Jobs\EldoradoRobuxPriceSentry;
|
||||
|
||||
use App\Browser\Jobs\HellcaseBattles\EldoradoRobuxPriceNotificationBody;
|
||||
use App\Models\Job;
|
||||
use App\Notification\Notification;
|
||||
use App\Notification\Stringifiable;
|
||||
use App\Notification\Stringifiable\StringifiableSimpleText;
|
||||
|
||||
class EldoradoRobuxPriceNotification extends Notification {
|
||||
|
||||
private float $price;
|
||||
private float $threshold;
|
||||
private string $link;
|
||||
|
||||
public function __construct(int $jobId, int $price, string $link) {
|
||||
parent::__construct($jobId);
|
||||
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Browser\Jobs\HellcaseBattles;
|
||||
|
||||
use App\Notification\NotificationBody;
|
||||
|
||||
class EldoradoRobuxPriceNotificationBody extends NotificationBody {
|
||||
|
||||
private float $price;
|
||||
private float $threshold;
|
||||
private string $link;
|
||||
|
||||
public function __construct(float $price, float $threshold, string $link) {
|
||||
parent::__construct();
|
||||
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user