Download the PHP package codewiser/telegram-channel without Composer

On this page you can find all versions of the php package codewiser/telegram-channel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package telegram-channel

Laravel Telegram Channel

This package provides a way to send notifications via Telegram.

Installation and setup

Package uses irazasyed/telegram-bot-sdk. So above all follow Telegram Bot SDK instructions and set up your first Telegram Bot. Most likely you need to run:

php artisan vendor:publish --tag="telegram-config"

In config/telegram.php configuration file add bot name parameter and register DeeplinkCommand. You may not define webhook_url as it will be reconfigured on a fly.

Next, implement \Codewiser\Telegram\Contracts\TelegramNotifiable to a User model. You might need to write a migration...

Now, create service to implement \Codewiser\Telegram\Contracts\TelegramNotifiableProvider. This is an example of implementation, your may implement it however you like.

At last, register this service in AppServiceProvider of your application

We are ready to go.

Getting updates

Register webhook

If you are properly configure bot in config/telegram.php this is enough to use telegram:webhook command provided by Telegram Bot SDK package. We recommend to read help:

php artisan help telegram:webhook

This package provides webhook controller to deal with incoming messages.

For example DeeplinkCommand, that was mentioned above, used to handle /start command with deeplink token.

You are free to add any other command handlers to config/telegram.php.

Read more about Bot Commands.

Long polling

This package brings telegram:poll command to get updates without registering webhook. Just call a command.

Usage

Subscribe user

First, we need to issue a deeplink for a user.

User follows deeplink, opens telegram client and presses Start button.

Codewiser\Telegram\Commands\DeeplinkCommand handles incoming update, resolves deeplink token and update User with chat_id.

For now, this user has telegram route and may be notified via Telegram.

Notify user

To notify user via Telegram, add toTelegram method to a notification. Do not forget to add telegram to via method.

Telegram notification message may be as string, as array.

Array keys fits Telegram sendMessage method.

String interprets as html and will be sent with ['parse_mode' => 'HTML'].

Failed notifications

When notification is failed to deliver to a user, \Illuminate\Notifications\Events\NotificationFailed event is propagated.

Some fails are catchable. For example, if user locks a bot, we will get a 403 response status. In that case we should unsubscribe user from future notifications. 400 means that chat was not found.

If you wish to automatically unsubscribe such users, register an event listener within the boot method of your application's AppServiceProvider:


All versions of telegram-channel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
irazasyed/telegram-bot-sdk Version ^3.0
laravel/framework Version ^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package codewiser/telegram-channel contains the following files

Loading the files please wait ....