PHP Classes

File: examples/hello.php

Recommend this page to a friend!
  Classes of Mateo   PHP Telegram Bot Handler   examples/hello.php   Download  
File: examples/hello.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: 575 bytes
 

Contents

Class file image Download
<?php

use Mateodioev\Bots\Telegram\Methods;
use
Mateodioev\TgHandler\Commands;

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

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

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

// Register new message command
$cmd->CmdMessage('start', 'sendHello', [$bot]);

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

runBot($cmd);