PHP Classes
elePHPant
Icontem

PHP Telegram Bot: Send and receive messages to Telegram users

Recommend this page to a friend!
  Info   View files Documentation   View files View files (21)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-03-21 (6 days ago) RSS 2.0 feedNot enough user ratingsTotal: 127 This week: 22All time: 8,460 This week: 43Up
Version License PHP version Categories
telegram-php 1.0.4GNU General Publi...5PHP 5, Web services, Chat
Description Author

This package can send and receive messages to Telegram users.

It can connect to Telegram as a given user and send messages to a given user.

It can also register callback functions when the user receives a message matching some incoming message text pattern.

  Performance   Level  
Name: David Girón <contact>
Classes: 2 packages by
Country: Spain Spain
Age: 21
All time rank: 3901102 in Spain Spain
Week rank: 34 Up4 in Spain Spain Up

Details

Telegram-PHP

Another library to use Telegram bots with PHP.

  • Include the src/Autoloader.php file.
  • Create a Telegram\Bot object.
  • Create a Telegram\Receiver object using the $bot.
$bot = new Telegram\Bot("11111111:AAAAAAAAAAzzzzzzzzzzzzzzzzzzz", "MyUserBot", "The Name of Bot");
$tg = new Telegram\Receiver($bot);

You can create as many Bots and Receivers or Senders as you want. Using Receiver includes a Sender.

Usage

Once the page is loaded (manually or via webhook), you can send or reply the requests.

To send a message to a user or group chat:

$tg->send
  ->chat("123456")
  ->text("Hello world!")
->send();

To reply a user command:

if($tg->text_command("start")){
  $tg->send
    ->text("Hi!")
  ->send();
}

To reply a user message:

if($tg->text_has("are you alive")){
  $tg->send
    ->text("Yes!")
  ->send();
}

Examples

  Files folder image Files  
File Role Description
Files folder imagesrc (7 files, 2 directories)
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageElements (10 files)
Files folder imageKeyboards (2 files)
  Accessible without login Plain text file Autoloader.php Aux. Auxiliary script
  Plain text file Bot.php Class Class source
  Plain text file Chat.php Class Class source
  Plain text file Message.php Class Class source
  Plain text file Receiver.php Class Class source
  Plain text file Sender.php Class Class source
  Plain text file User.php Class Class source

  Files folder image Files  /  src  /  Elements  
File Role Description
  Plain text file Audio.php Class Class source
  Plain text file Base.php Class Class source
  Plain text file Document.php Class Class source
  Plain text file Location.php Class Class source
  Plain text file MessageEntity.php Class Class source
  Plain text file PhotoSize.php Class Class source
  Plain text file Sticker.php Class Class source
  Plain text file Venue.php Class Class source
  Plain text file Video.php Class Class source
  Plain text file Voice.php Class Class source

  Files folder image Files  /  src  /  Keyboards  
File Role Description
  Plain text file InlineKeyboard.php Class Class source
  Plain text file Keyboard.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:127
This week:22
All time:8,460
This week:43Up