|
@@ 25-37 (lines=13) @@
|
| 22 |
|
* @param Template|null $template |
| 23 |
|
* @param int $delay |
| 24 |
|
*/ |
| 25 |
|
protected function sendMessage(string $text, Template $template = null, int $delay = 0): void |
| 26 |
|
{ |
| 27 |
|
/** @var Queue $queue */ |
| 28 |
|
$queue = resolve(Queue::class); |
| 29 |
|
|
| 30 |
|
$command = new SendMessage($this->getChat(), $this->getUser(), $text, $template); |
| 31 |
|
|
| 32 |
|
if ($delay > 0) { |
| 33 |
|
$queue->later(kernel()->getChannel(), kernel()->getDriver(), $command, $delay); |
| 34 |
|
} else { |
| 35 |
|
$queue->push(kernel()->getChannel(), kernel()->getDriver(), $command); |
| 36 |
|
} |
| 37 |
|
} |
| 38 |
|
|
| 39 |
|
/** |
| 40 |
|
* Send attachment to user. |
|
@@ 47-59 (lines=13) @@
|
| 44 |
|
* |
| 45 |
|
* @throws \Psr\Container\ContainerExceptionInterface |
| 46 |
|
*/ |
| 47 |
|
protected function sendAttachment(Attachment $attachment, int $delay = 0): void |
| 48 |
|
{ |
| 49 |
|
/** @var Queue $queue */ |
| 50 |
|
$queue = resolve(Queue::class); |
| 51 |
|
|
| 52 |
|
$command = new SendAttachment($this->getChat(), $this->getUser(), $attachment); |
| 53 |
|
|
| 54 |
|
if ($delay === 0) { |
| 55 |
|
$queue->push(kernel()->getChannel(), kernel()->getDriver(), $command); |
| 56 |
|
} else { |
| 57 |
|
$queue->later(kernel()->getChannel(), kernel()->getDriver(), $command, $delay); |
| 58 |
|
} |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
/** |
| 62 |
|
* Send request to the messaging service. |