PHP Classes

File: examples/send_button.php

Recommend this page to a friend!
  Classes of Mateo   PHP Telegram Bot Handler   examples/send_button.php   Download  
File: examples/send_button.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Telegram Bot Handler
Create a Telegram bot to respond to certain events
Author: By
Last change:
Date: 1 year ago
Size: 582 bytes
 

Contents

Class file image Download
<?php

use Mateodioev\Bots\Telegram\{Methods, Buttons};
use
Mateodioev\TgHandler\Commands;

require
__DIR__ . '/../vendor/autoload.php';
require
__DIR__ . '/functions.php';

// Support for /start, !start, .start
$cmd = new Commands(cmd_prefix: ['/', '!', '.']);
$cmd->setBotUsername('your bot username');

// https://telegram.me/botfather
$bot = new Methods('your telegram bot token');

// Middleware on message
$cmd->on('message', 'sendHelloWithButton', [$bot]);

$update = json_decode(file_get_contents('php://input')) or die('No update');
$cmd->setUpdate($update);

runBot($cmd);