|
|
@@ -6,16 +6,24 @@ use Symfony\Component\Notifier\Bridge\Telegram\TelegramTransport;
|
|
6
|
6
|
use Symfony\Component\Notifier\Chatter;
|
|
7
|
7
|
use Symfony\Component\Notifier\Bridge\Telegram\TelegramOptions;
|
|
8
|
8
|
use Symfony\Component\Notifier\Message\ChatMessage;
|
|
|
9
|
+use Symfony\Contracts\HttpClient\HttpClientInterface;
|
|
9
|
10
|
|
|
10
|
11
|
readonly class TelegramNotifier
|
|
11
|
12
|
{
|
|
12
|
|
- public function __construct(private string $telegramBotToken, private string $telegramChatId)
|
|
13
|
|
- {
|
|
|
13
|
+ public function __construct(
|
|
|
14
|
+ private string $telegramBotToken,
|
|
|
15
|
+ private string $telegramChatId,
|
|
|
16
|
+ private HttpClientInterface $httpClient,
|
|
|
17
|
+ ) {
|
|
14
|
18
|
}
|
|
15
|
19
|
|
|
16
|
20
|
public function notify(string $message, ?string $filename = null): void
|
|
17
|
21
|
{
|
|
18
|
|
- $telegramTransport = new TelegramTransport($this->telegramBotToken, $this->telegramChatId);
|
|
|
22
|
+ $telegramTransport = new TelegramTransport(
|
|
|
23
|
+ $this->telegramBotToken,
|
|
|
24
|
+ $this->telegramChatId,
|
|
|
25
|
+ $this->httpClient,
|
|
|
26
|
+ );
|
|
19
|
27
|
$chatter = new Chatter($telegramTransport);
|
|
20
|
28
|
$chatMessage = new ChatMessage($message);
|
|
21
|
29
|
|