v2board/app/Jobs/SendTelegramJob.php

44 lines
985 B
PHP
Raw Normal View History

2020-05-25 15:48:12 +08:00
<?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;
2023-04-04 17:58:25 +08:00
public $timeout = 10;
2020-05-25 15:48:12 +08:00
/**
* 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');
}
}