From 69287d62c934f3507a4ea8a481ca2793381319b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Tr=E1=BA=A7n=20Chung?= Date: Tue, 2 Nov 2021 08:47:07 +0900 Subject: [PATCH 1/2] telegram sendmessage options --- config/telegram-logger.php | 11 +++++++++-- src/TelegramHandler.php | 13 ++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/config/telegram-logger.php b/config/telegram-logger.php index 0ae7a23..4248ada 100644 --- a/config/telegram-logger.php +++ b/config/telegram-logger.php @@ -8,5 +8,12 @@ 'chat_id' => env('TELEGRAM_LOGGER_CHAT_ID'), // Blade Template to use formatting logs - 'template' => env('TELEGRAM_LOGGER_TEMPLATE', 'laravel-telegram-logging::standard') -]; \ No newline at end of file + 'template' => env('TELEGRAM_LOGGER_TEMPLATE', 'laravel-telegram-logging::standard'), + + // Telegram sendMessage options: https://core.telegram.org/bots/api#sendmessage + 'options' => [ + // 'parse_mode' => 'html', + // 'disable_web_page_preview' => true, + // 'disable_notification' => false + ] +]; diff --git a/src/TelegramHandler.php b/src/TelegramHandler.php index 9c67599..a538afc 100644 --- a/src/TelegramHandler.php +++ b/src/TelegramHandler.php @@ -120,11 +120,14 @@ private function formatText(array $record): string */ private function sendMessage(string $text): void { - $httpQuery = http_build_query([ - 'text' => $text, - 'chat_id' => $this->chatId, - 'parse_mode' => 'html', - ]); + $httpQuery = http_build_query(array_merge( + [ + 'text' => $text, + 'chat_id' => $this->chatId, + 'parse_mode' => 'html', + ], + config('telegram-logger.template', []) + )); file_get_contents('https://api.telegram.org/bot'.$this->botToken.'/sendMessage?' . $httpQuery); } From b496222a42d71e7cc2a02ea4814e67b0d1ae09e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Tr=E1=BA=A7n=20Chung?= Date: Tue, 2 Nov 2021 08:48:15 +0900 Subject: [PATCH 2/2] update config key --- src/TelegramHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TelegramHandler.php b/src/TelegramHandler.php index a538afc..198deac 100644 --- a/src/TelegramHandler.php +++ b/src/TelegramHandler.php @@ -126,7 +126,7 @@ private function sendMessage(string $text): void 'chat_id' => $this->chatId, 'parse_mode' => 'html', ], - config('telegram-logger.template', []) + config('telegram-logger.options', []) )); file_get_contents('https://api.telegram.org/bot'.$this->botToken.'/sendMessage?' . $httpQuery);