Download the PHP package webpajooh/telebot without Composer

On this page you can find all versions of the php package webpajooh/telebot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package telebot

Latest Stable Version Total Downloads PHP Version Require License

TeleBot

A minimal library to develop your new Telegram bot

Installation

composer require webpajooh/telebot

How to use

Start point

We start by creating an instance of TeleBot class:

Get the update object

There are short ways to access the update object and some important fields. I recommend you to read the official documentation to understand these objects well.

You also can use the hasCallbackQuery() method, when you want to check if the update object has a callback_query field.

Methods

Thanks to magic methods, we can use API methods without implementing them, and just call them by name and pass an array as parameter:

Router

You may define some routes to your bot features; define them by the listen() method:

The third parameter that is true by default, makes you able to terminate the script after running a command. In the previous example we passed false so script continues.

You can also get parameters and use them as variables:

TeleBot translates them to regex, so it will be good to take a look at this table to know how to use them properly:

Type TeleBot Regex
Digits %d (\d+)
String (Anything but a whitespace) %s (\S+)
Character %c (\S)
Everything including an empty string %p (.*)

Logger

You may need to log something into a log.txt file:

Keyboard

TeleBot includes two classes for making keyboards; InlineKeyboard and ReplyKeyboard. Here you see an example:

Then you can use it as bellow:

Consider that the chunk() method supports more complex orders, just pass an array like [1, 3, 2] to build such a keyboard:

[        1        ]  
[ 2 ]  [ 3️ ]  [ 4 ]  
[   5   ] [   6   ]  

Default parameters

Sometimes you do not want to repeat yourself by passing a parameter everywhere, so you can define default parameters for each method. Here are three example that makes it clear how to use it:

Extend it!

You may want to add some methods to TeleBot class to improve your code readability and avoid duplication. Look at this simple example as an inspiration:

Have you seen a problem?

Create an issue and explain your problem!

Made with TeleBot


All versions of telebot with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webpajooh/telebot contains the following files

Loading the files please wait ....