Skip to content

Commit 44aed2c

Browse files
authored
Merge pull request #27 from nguyentranchung/master
Allow custom sendMessage parameter
2 parents 94e1635 + b496222 commit 44aed2c

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

config/telegram-logger.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,12 @@
88
'chat_id' => env('TELEGRAM_LOGGER_CHAT_ID'),
99

1010
// Blade Template to use formatting logs
11-
'template' => env('TELEGRAM_LOGGER_TEMPLATE', 'laravel-telegram-logging::standard')
12-
];
11+
'template' => env('TELEGRAM_LOGGER_TEMPLATE', 'laravel-telegram-logging::standard'),
12+
13+
// Telegram sendMessage options: https://core.telegram.org/bots/api#sendmessage
14+
'options' => [
15+
// 'parse_mode' => 'html',
16+
// 'disable_web_page_preview' => true,
17+
// 'disable_notification' => false
18+
]
19+
];

src/TelegramHandler.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,14 @@ private function formatText(array $record): string
120120
*/
121121
private function sendMessage(string $text): void
122122
{
123-
$httpQuery = http_build_query([
124-
'text' => $text,
125-
'chat_id' => $this->chatId,
126-
'parse_mode' => 'html',
127-
]);
123+
$httpQuery = http_build_query(array_merge(
124+
[
125+
'text' => $text,
126+
'chat_id' => $this->chatId,
127+
'parse_mode' => 'html',
128+
],
129+
config('telegram-logger.options', [])
130+
));
128131

129132
file_get_contents('https://api.telegram.org/bot'.$this->botToken.'/sendMessage?' . $httpQuery);
130133
}

0 commit comments

Comments
 (0)