You can install the package via composer:
composer require itpekov/telegram-messageAdd in .env file variables:
TELEGRAM_CHAT_ID=your_chat_id
TELEGRAM_BOT_TOKEN=your_bot_tokenScenario 1: send message from any place with:
Telegram::sendMessage('Your message');Scenario 2: send exception messages with
Telegram::sendExceptionMessage($e);Scenario 3: send all unhandled exceptions from your app
by adding/updating report method in Handler.php class
use Itpekov\TelegramMessage\Facades\Telegram;
public function report(Throwable $e)
{
$e = $this->mapException($e);
if ($this->shouldntReport($e)) {
return;
}
Telegram::sendExceptionMessage($e);
$this->reportThrowable($e);
}Optionally, You can publish the config file with:
php artisan vendor:publish --provider="Itpekov\TelegramMessage\TelegramMessageServiceProvider" --tag="config"This is the contents of the published config file:
return [
'chat_id' => env('TELEGRAM_CHAT_ID'),
'bot_token' => env('TELEGRAM_BOT_TOKEN'),
];Optionally, you can publish the views using
php artisan vendor:publish --provider="Itpekov\TelegramMessage\TelegramMessageServiceProvider" --tag="views"composer testPlease see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.