Download the PHP package shamanhead/telbot without Composer

On this page you can find all versions of the php package shamanhead/telbot. 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 telbot

telbot

Contents

Introducion

If you want to create your bot, for the first you need to register him.You can do it with @BotFather. Open the dialog with him and write /newbot , like as in this image:

Снимок

Снимок6

After that you need to set webhook on your bot.Webhook its a system, who sending queries to your server, if telegram gets one.

Before start creating a webhook you need bot api token and server.If you dont have a server, you can use heroku to create one.

You can find your bot api token by writing /mybots, then select your bot, and then select button "API Token".Example:

Снимок2

Снимок 3PNG

Снимок3

When you finish all this actions, you can set webhook to your bot.For this you need to use bot api method setWebhook:

Снимок8

Then, if you done all right, you will see this answer:

Снимок4

After that you can start working with your bot.But how I can work?You can ask me.Lets see, how.

Creating you bot

How to create bot?Very easy!Just create a new bot class:

So, lets create a script, who will send a text message as test.But how?The Inquiry class will help us with it:

Снимок

Utils

Supporting class for ease of work with telegram bot api types.

Creating keyboard

You can create keyboards easy using this way:

Examples:

Снимок3

Encoding files

If you want to send video or photo to user, you need to encode them to CURl format.For this use this method:

Parameter $filePath need to indicate path to file you want to send.

Building inline query result

If you want to send an answer to inline query, you need to build answer object.For this use this method:

You can check example here

Mysql features

To start work with mysql, first you need to do is enable sql connection in your bot object:

You can also disable sql by using similar method:

Warning: if your sql connection doesnt exist, you can not use this modules:User, Chat. In this case Context instead of writing context values ​​to the database would be create new file with context(one to user).

Later you need to specify sql credentials:

Or you can indicate your external pdo connection as sql credentials:

After all this actions, you can start to work with database.

Context

Using class Context you can create context dependence:

Снимок2

Working with chats in database

All the same, but a bit different:

To add chats to database, you need to use this function:

To delete chats:

To get chats:

This function returns array with row information of this chat(row id, chat id, bot token)

To get all chats:

Inquiry

Its the main class in this library.This paragraph shows all capabilities of this class.

This class has only one method - Inquiry::send().With this class you can send both simple text messages and complex answers.

Supported methods

All method supported during version of API 4.7

Sending simple answer

Sending callback query answer

Sending Inline query answer

You can send any of telegram methods with this method send.All of this supported.

Sending files

To send files from your server, you need to encode file to CURl format.For this, you need to use method Utils::encodeFile.

Input Handle

This class needs for comfortable work with telegram answer query.

Creating a new InputHandle object

Working with data

Privelege

You can give a user a specific privilege in the chat(or all chats). This can be used to give access to certain commands to that particular user.

Examples

See examples at 'examples' folder.

License

Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.


All versions of telbot with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
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 shamanhead/telbot contains the following files

Loading the files please wait ....