PHP code example of pulpa / laravel-telegram-bot

1. Go to this page and download the library: Download pulpa/laravel-telegram-bot library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pulpa / laravel-telegram-bot example snippets


use Pulpa\Telegram\Bot\Update;
use Pulpa\Telegram\Bot\Http\Controllers\Controller;

class BotController extends Controller
{
    public function catchAll(Update $update)
    {
        // Log the text message
        \Log::info($update->message->text);
    }
}

use App\Chat;
use Pulpa\Telegram\Bot\Update;
use Pulpa\Telegram\Bot\Http\Controllers\Controller;

class BotController extends Controller
{
    public function catchAll(Update $update)
    {
        // ...
    }

    public function start(Update $update)
    {
        // Register a new chat when command "start" is received.
        Chat::register($update->message->chat->id);
    }
}

php artisan vendor:publish --provider="Pulpa\Telegram\Bot\Providers\ServiceProvider"