PHP code example of eseytgbot / telegram-api

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

    

eseytgbot / telegram-api example snippets


# Database Configuration
const DB_HOST = 'localhost';
const DB_NAME = 'bot';
const DB_USER = 'root';
const DB_PASS = '';

# Telegram Configuration
const TELEGRAM_TOKEN = 'YOUR_BOT_TOKEN';
const TELEGRAM_API_URL = 'https://api.telegram.org/bot';
const TELEGRAM_WEBHOOK_URL = 'https://your-domain.com/bot.php';

use App\Database\Schema;

// Select data
Schema::table('users')
    ->select(['id', 'username'])
    ->where('active', '=', 1)
    ->get();

// Insert data
Schema::table('users')->insert([
    'username' => 'john',
    'email' => '[email protected]'
]);

// Update data
Schema::table('users')
    ->where('id', '=', 1)
    ->update(['status' => 'active']);

// Delete data
Schema::table('users')
    ->where('id', '=', 1)
    ->delete();

// Count records
$count = Schema::table('users')
    ->where('status', '=', 'active')
    ->count();

use App\Database\CreateTable;

class Users extends CreateTable
{
    public static function up(): void
    {
        self::table('users')
            ->int('id')->primaryKey()->autoIncrement()
            ->varchar('username', 100)->notNull()->unique()
            ->varchar('email', 255)->nullable()
            ->text('bio')
            ->datetime('last_login')->nullable()
            ->int('status')->default(1)
            ->create();
    }

    public static function down(): void
    {
        self::drop('users');
    }
}

BotStractuer/
├── App/
│   └── Commands/
│       ├── BotCommands/    # Bot command App
│       └── Kernal.php      # Core initialization
├── bot.php                 # Main bot file
├── autoload.php            # Class autoloader
├── config.php              # Configuration file
└── error.log               # Error logging