mirror of
https://github.com/Cybrarist/Discount-Bandit.git
synced 2026-11-24 19:49:54 +01:00
- fix type when filtering product by price met target. - fix the lowest price was overridden if price wasn't crawled. - fix store tabs not working - fix some european amazon using "." as thousands separator. - keep last 3 days of logs only. - added volume to .env to fix 2FA not working after restarting container - added volume for database - New Stores: - best buy New Features: - add other users to the system and manage their tokens. - add telegram notification. - add percentage drop. - robot detection for amazon ( if the system was detected as robot, it will stop executing and try the next product, the same product that was blocked will be crawled again in the next batch) Took 6 hours 50 minutes
87 lines
2.4 KiB
PHP
87 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\NotificationsChannels\NtfyChannel;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
use Illuminate\Support\Str;
|
|
use NotificationChannels\Telegram\TelegramFile;
|
|
|
|
class ProductDiscounted extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*/
|
|
public function __construct(public $product_name,
|
|
public $store_name ,
|
|
public $price,
|
|
public $highest_price,
|
|
public $lowest_price,
|
|
public $product_url,
|
|
public $image,
|
|
public $currency,
|
|
public $tags
|
|
) {}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @return array<int, string>
|
|
*/
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return [NtfyChannel::class , 'telegram'];
|
|
}
|
|
|
|
public function toNtfy(object $notifiable): array {
|
|
|
|
|
|
$extra_headers=[
|
|
'Title'=>"For Just $this->price - Discount For " . Str::words($this->product_name , 5),
|
|
"Actions"=> "view, Open in $this->store_name, $this->product_url",
|
|
"Attach"=>$this->image,
|
|
"X-Tags"=>"money_with_wings" . $this->tags
|
|
];
|
|
|
|
$content="$this->product_name, is at $this->currency $this->price. <br>" .
|
|
"**Highest Price**: $this->highest_price \n" .
|
|
"**Lowest Price**: $this->lowest_price \n"
|
|
;
|
|
|
|
return ["content" => $content ,"headers"=> $extra_headers ];
|
|
}
|
|
|
|
public function toTelegram($notifiable){
|
|
|
|
try {
|
|
return TelegramFile::create()
|
|
->photo($this->image)
|
|
->token(env("TELEGRAM_BOT_TOKEN"))
|
|
->to(env('TELEGRAM_CHANNEL_ID'))
|
|
->content(
|
|
"$this->product_name, is at $this->currency $this->price \n " .
|
|
"--------------------------\n" .
|
|
"Highest Price: $this->highest_price \n" .
|
|
"Lowest Price: $this->lowest_price \n".
|
|
"--------------------------\n" .
|
|
$this->tags
|
|
|
|
)
|
|
->button('View Product', $this->product_url);
|
|
|
|
}catch (\Throwable $throwable){
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|