Skip to content

Commit

Permalink
Merge pull request #27 from nguyentranchung/master
Browse files Browse the repository at this point in the history
Allow custom sendMessage parameter
  • Loading branch information
grkamil authored Nov 2, 2021
2 parents 94e1635 + b496222 commit 44aed2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
11 changes: 9 additions & 2 deletions config/telegram-logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
];
'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
]
];
13 changes: 8 additions & 5 deletions src/TelegramHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.options', [])
));

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

0 comments on commit 44aed2c

Please sign in to comment.