12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Jobs;
- use App\Services\TelegramService;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
- class SendTelegramJob implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- protected $telegramId;
- protected $text;
- public $tries = 3;
- public $timeout = 5;
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(int $telegramId, string $text)
- {
- $this->onQueue('send_telegram');
- $this->telegramId = $telegramId;
- $this->text = $text;
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- $telegramService = new TelegramService();
- $telegramService->sendMessage($this->telegramId, $this->text, 'markdown');
- }
- }
|