PHP code example of tueen / telegram

1. Go to this page and download the library: Download tueen/telegram 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/ */

    

tueen / telegram example snippets




use Tueen\Telegram\Telegram;
use Tueen\Telegram\Types\User;

User, Chat, Message, and Telegram are injected automatically
$bot->onCommand('start', function (User $user, Telegram $bot) {
    $bot->reply("Welcome to Tueen, {$user->firstName}! 👑");
});

// Route groups with middlewares and parameter constraints
$bot->group(['prefix' => 'order_'], function (Telegram $bot) {
    $bot->onText('{id}', function (int $id, Telegram $bot) {
        $bot->reply("Order #{$id} confirmed!");
    })->where('id', '[0-9]+');
});

// Run continuous long-polling
$bot->run();



use Tueen\Telegram\App;

ok in HTTP and Polling in CLI
App::run(__DIR__);