https://github.com/madmagestelegram/laravel-client
Telegram + Laravel integration
https://github.com/madmagestelegram/laravel-client
laravel telegram
Last synced: 6 months ago
JSON representation
Telegram + Laravel integration
- Host: GitHub
- URL: https://github.com/madmagestelegram/laravel-client
- Owner: madmagestelegram
- Created: 2020-08-18T16:48:37.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-10T22:58:49.000Z (about 3 years ago)
- Last Synced: 2025-07-24T21:54:21.308Z (11 months ago)
- Topics: laravel, telegram
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Telegram + Laravel
Laravel + telegram integration. Based on [telegram bot types](https://github.com/madmagestelegram/Types)
# Install
`composer require madmagestelegram/laravel`
# Concepts
### Main concept
The main concept is creating handlers for incoming updates from telegram.
It should implement [abstract handler](https://github.com/madmagestelegram/laravel-client/blob/master/src/Handler/AbstractHandler.php)
### Examples of handlers
There is one build in [handler for telegram commands](https://github.com/madmagestelegram/laravel-client/blob/master/src/Handler/Command/CommandHandler.php)
### Service provider
To define custom handlers or telegram-command-handler, it necessary to create and register own service provider and extend it from `\MadmagesTelegram\Laravel\HandlerServiceProvider`
```php
telegramCommands working
\MadmagesTelegram\Laravel\Handler\Command\CommandHandler::class
];
protected array $editMessageHandlers = [];
protected array $channelPostHandlers = [];
protected array $editedChannelPostHandlers = [];
protected array $inlineQueryHandlers = [];
protected array $chosenInlineResultHandlers = [];
protected array $callbackQueryHandlers = [];
protected array $preCheckoutQueryHandlers = [];
protected array $shippingQueryHandlers = [];
protected array $pollAnswerHandlers = [];
protected array $pollHandlers = [];
}
```
### Command handler
The command handler built for handling telegram commands i.e. **/start** for example.
All commands should implement [AbstractCommand](https://github.com/madmagestelegram/laravel-client/blob/master/src/Handler/Command/AbstractCommand.php)
and should be defined in `\MadmagesTelegram\Laravel\HandlerServiceProvider::$telegramCommands` of own service provider
```php
client = $client;
}
public function getName(): string
{
return 'start';
}
public function execute(Message $message, bool $isPrivate): ?JsonResponse
{
return $this->client->sendMessage($message->getChat()->getId(), 'Hello there !');
}
}
```
and register it
```php