usmonaliyev/laravel-telegram-notifier

This package send errors and messages to your telegram group or chat.

v1.4.0 2025-01-12 06:54 UTC

This package is auto-updated.

Last update: 2025-01-19 14:42:09 UTC


README

This package send bugs and messages to your telegram group or chat.

Packagist Dependency Version Total Downloads Latest Version on Packagist Packagist License

Screenshots

App Screenshot

Installation

Install this project with composer

composer require usmonaliyev/laravel-telegram-notifier

To control it, create config file

php artisan vendor:publish --provider="Usmonaliyev\LaravelTelegramNotifier\LaravelTelegramNotifierServiceProvider"

Add your bot token and receiver chat id to .env file.

TELEGRAM_NOTIFIER_BOT_TOKEN=
CHAT_ID=
TELEGRAM_NOTIFIER_RESPONSIBLE=@someone

I recommend that you only use it on production. To do this, change the value of TELEGRAM_NOTIFIER_ENABLED in .env to production.

TELEGRAM_NOTIFIER_ENABLED=false

Custom usage

If you want to send custom message, there is notify function:

<?php

use Usmonaliyev\LaravelTelegramNotifier\Facades\TelegramNotifier;

TelegramNotifier::notify("There is your text")

Also, there is error function to send handled error:

<?php

use Usmonaliyev\LaravelTelegramNotifier\Facades\TelegramNotifier;

try {
    ...
} catch (Exception $exception) {

    TelegramNotifier::error($exception);
}

Configuration

There are laravel-telegram-notifier.php in your config folder. If you want to send bag to two or three chat ids you add chat id to chat_ids array of laravel-telegram-notifier.php file.

"chat_ids" => [env("CHAT_ONE_ID"), env("CHAT_TWO_ID"), env("CHAT_THREE_ID")],

Running Tests

To verify that the package is fully installed and working. You can run the command below which will help you create a new dummy error.

php artisan notify:check

In production mode you can load configurations from .env with php artisan config:clear command.