mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
44 lines
984 B
PHP
44 lines
984 B
PHP
<?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');
|
|
}
|
|
}
|