| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace App\Jobs;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
- use Telegram\Bot\Api;
- use Illuminate\Support\Facades\Log;
- use App\Services\BaseService;
- use DragonCode\PrettyArray\Services\Formatters\Base;
- use Telegram\Bot\Exceptions\TelegramResponseException;
- class SendTelegramGroupMessageJob implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- public $chatId;
- public $text;
- public $buttons;
- public $image;
- public $isTop;
- public $separator;
- /**
- * @param string $chatId
- * @param string $text
- * @param array $buttons
- * @param string|null $image
- * @param string $separator 分隔符
- */
- public function __construct($text, $buttons = [], $image = null, $isTop = false, $separator = "\n")
- {
- $this->text = $text;
- $this->buttons = $buttons;
- $this->image = $image;
- $this->isTop = $isTop;
- $this->separator = $separator;
- }
- public function handle()
- {
- try {
- BaseService::bettingGroupNotice($this->text, $this->buttons, $this->image, $this->isTop, $this->separator);
- } catch (TelegramResponseException $e) {
- try {
- BaseService::bettingGroupNotice($this->text, $this->buttons, $this->image, $this->isTop, $this->separator);
- } catch (TelegramResponseException $e) {
- try {
- BaseService::bettingGroupNotice($this->text, $this->buttons, $this->image, $this->isTop, $this->separator);
- } catch (TelegramResponseException $e) {
- Log::error('Telegram 消息发送失败: ' . $e->getMessage());
- Log::error("失败消息: \n" . $this->text);
- }
- }
- }
- }
- }
|