Download the PHP package naftali100/async_bot without Composer

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

bot_lib

simple flexible and async library based on amphp for telegram bot api.

NOTE: this is an old project and very poorly written. I wouldn't recommend to use it.

installation

getting started

server.php

bot.php

set webhook to 127.0.0.1:8080/you_bot_file_name.php (or custom name passed in second argument to load_file).

you can add token parameter to the webhook url and the server will set it and use this token.

run php server.php.

a lot more handler, config and server options in examples folder.


explanation

there is 5 main objects in the library

  1. Server: extends Loader. load files, running the http-server and activating handlers.
  2. Config: configuration.
  3. Update: extends API and HTTP. contains all the method to send request to bot api.
  4. Handler: create handlers that will run asynchronously.
  5. Filter: static methods to create filters.

Server

the server is loading all of your robots files, take the handlers, and run a server listen to incoming requests. once there is a request to the server, it activates the handlers set in the request path. you can set any request path to any file.

Handler

all handlers run asynchronously on every request from the bot. there is a verity of handlers you can set and ways to control how they will activate.

to create handler, simply call the method on Handler instance as handler name you want $handler->handler_name().

you can give it any name you want (except the handler class methods). the name can control when the handler is activating.

handler accepts 4 parameter

you can pass the arguments by order (function, filter, last, name) or by name

special handlers names

this list of special handler activated in specific TBD.
this list of special handler activated in specific update types.

Config

you can config various things see src/config.php file. can be set in json file and load using load method as shown above.

Update

All bot api method and some more in this class. instance of this class is passed to the handlers.

telegram api methods - https://core.telegram.org/bots/api#available-methods

Added methods:

Also there is a lot of preset variables to many update parts. see update.php file.

variables

Partial list:

you can access the update as object or as array. $u->message->chat->id or $u['message']['chat']['id'].

you can skip the update type (message in above example).

$u->data will be the callback data in callback update. $u->message_id is the message_id.

Loader

The Server class extends the Loader. you shouldn't use it directly.

You can load file, folders or Handler.

extra access

File loaded with the ability to change handlers of other bots.

The handlers in file loaded with $this of bot_lib/Server.

The files prop in Server class contain the

of every file loaded by the server.

Examples what you can do with extra access in examples folder.

Helper

contain static helpers functions.

debugging

to enable debug logs for the server

to enable logging per bot you can add this to the bot file


use Psr\Log\LogLevel;

$config->setLevel(LogLevel::DEBUG);

All versions of async_bot with dependencies

PHP Build Version
Package Version
Requires amphp/http-client Version ^5.1
amphp/http-server Version ^3.3
amphp/log Version ^2.0
amphp/byte-stream Version ^2.1
amphp/http-server-router Version ^2.0
amphp/file Version ^3.1
respect/validation Version ^2.2.4
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 naftali100/async_bot contains the following files

Loading the files please wait ....